github.com/chipaca/snappy@v0.0.0-20210104084008-1f06296fe8ad/packaging/opensuse/snapd.spec (about) 1 # spec file for package snapd 2 # 3 # Copyright (c) 2017 Zygmunt Krynicki <zygmunt.krynicki@canonical.com> 4 # Copyright (c) 2018 Neal Gompa <ngompa13@gmail.com> 5 # 6 # All modifications and additions to the file contributed by third parties 7 # remain the property of their copyright owners, unless otherwise agreed 8 # upon. The license for this file, and modifications and additions to the 9 # file, is the same license as for the pristine package itself (unless the 10 # license for the pristine package is not an Open Source License, in which 11 # case the license is the MIT License). An "Open Source License" is a 12 # license that conforms to the Open Source Definition (Version 1.9) 13 # published by the Open Source Initiative. 14 15 # Please submit bugfixes or comments via http://bugs.opensuse.org/ 16 17 # takes an absolute path with slashes and turns it into an AppArmor profile path 18 %define as_apparmor_path() %(echo "%1" | tr / . | cut -c2-) 19 20 # Test keys: used for internal testing in snapd. 21 %bcond_with testkeys 22 23 # Enable AppArmor on openSUSE Tumbleweed (post 15.0) or higher 24 # N.B.: Prior to openSUSE Tumbleweed in May 2018, the AppArmor userspace in SUSE 25 # did not support what we needed to be able to turn on basic integration. 26 %if 0%{?suse_version} >= 1550 27 %bcond_without apparmor 28 %else 29 %bcond_with apparmor 30 %endif 31 32 # The list of systemd services we are expected to ship. Note that this does 33 # not include services that are only required on core systems. 34 %global systemd_services_list snapd.socket snapd.service snapd.seeded.service snapd.failure.service %{?with_apparmor:snapd.apparmor.service} 35 %global systemd_user_services_list snapd.session-agent.socket 36 37 # Alternate snap mount directory: not used by openSUSE. 38 # If this spec file is integrated into Fedora then consider 39 # adding global with_alt_snap_mount_dir 1 then. 40 %global snap_mount_dir /snap 41 42 # Compat macros 43 %{!?make_build: %global make_build %{__make} %{?_smp_mflags}} 44 %{?!_environmentdir: %global _environmentdir %{_prefix}/lib/environment.d} 45 %{?!_userunitdir: %global _userunitdir %{_prefix}/lib/systemd/user} 46 47 # Define the variable for systemd generators, if missing. 48 %{?!_systemdgeneratordir: %global _systemdgeneratordir %{_prefix}/lib/systemd/system-generators} 49 %{?!_systemdusergeneratordir: %global _systemdusergeneratordir %{_prefix}/lib/systemd/user-generators} 50 %{?!_systemd_system_env_generator_dir: %global _systemd_system_env_generator_dir %{_prefix}/lib/systemd/system-environment-generators} 51 %{?!_systemd_user_env_generator_dir: %global _systemd_user_env_generator_dir %{_prefix}/lib/systemd/user-environment-generators} 52 53 # This is fixed in SUSE Linux 15 54 # Cf. https://build.opensuse.org/package/rdiff/Base:System/rpm?linkrev=base&rev=396 55 %if 0%{?suse_version} < 1500 56 %global _sharedstatedir %{_localstatedir}/lib 57 %endif 58 59 %global provider github 60 %global provider_tld com 61 %global project snapcore 62 %global repo snapd 63 %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} 64 %global import_path %{provider_prefix} 65 66 # Additional entry of $GOPATH during the build process. 67 # This is designed to be a sub-directory of {_builddir}/{name}-{version} 68 # because that directory is automatically cleaned-up by the build process. 69 %global indigo_gopath %{_builddir}/%{name}-%{version}/gopath 70 71 # Directory where "name-version" directory from upstream taball is unpacked to. 72 # This directory is arranged so that it is already contained inside the future 73 # GOPATH so that nothing needs to be moved or copied for "go build" to work. 74 %global indigo_srcdir %{indigo_gopath}/src/%{import_path} 75 76 # path to snap-confine encoded as AppArmor profile 77 %define apparmor_snapconfine_profile %as_apparmor_path %{_libexecdir}/snapd/snap-confine 78 79 # Set if multilib is enabled for supported arches 80 %ifarch x86_64 aarch64 %{power64} s390x 81 %global with_multilib 1 82 %endif 83 84 85 Name: snapd 86 Version: 2.48.2 87 Release: 0 88 Summary: Tools enabling systems to work with .snap files 89 License: GPL-3.0 90 Group: System/Packages 91 Url: https://%{import_path} 92 Source0: https://github.com/snapcore/snapd/releases/download/%{version}/%{name}_%{version}.vendor.tar.xz 93 Source1: snapd-rpmlintrc 94 %if (0%{?sle_version} >= 120200 || 0%{?suse_version} >= 1500) && 0%{?is_opensuse} 95 BuildRequires: ShellCheck 96 %endif 97 BuildRequires: autoconf 98 BuildRequires: automake 99 BuildRequires: glib2-devel 100 BuildRequires: glibc-devel-static 101 BuildRequires: go >= 1.9 102 BuildRequires: gpg2 103 BuildRequires: indent 104 BuildRequires: libcap-devel 105 BuildRequires: libseccomp-devel 106 BuildRequires: libtool 107 BuildRequires: libudev-devel 108 BuildRequires: libuuid-devel 109 BuildRequires: make 110 BuildRequires: openssh 111 BuildRequires: pkg-config 112 BuildRequires: python3-docutils 113 BuildRequires: squashfs 114 # Due to: rpm -q --whatprovides /usr/share/pkgconfig/systemd.pc 115 BuildRequires: systemd 116 BuildRequires: systemd-rpm-macros 117 BuildRequires: timezone 118 BuildRequires: udev 119 BuildRequires: xfsprogs-devel 120 BuildRequires: xz 121 %ifarch x86_64 122 # This is needed for seccomp tests 123 BuildRequires: glibc-devel-32bit 124 BuildRequires: glibc-devel-static-32bit 125 BuildRequires: gcc-32bit 126 %endif 127 128 %if %{with apparmor} 129 BuildRequires: libapparmor-devel 130 BuildRequires: apparmor-rpm-macros 131 %endif 132 133 PreReq: permissions 134 135 Requires(post): permissions 136 %if %{with apparmor} 137 Requires: apparmor-parser 138 Requires: apparmor-profiles 139 %endif 140 Requires: gpg2 141 Requires: openssh 142 Requires: squashfs 143 Requires: system-user-daemon 144 145 # Old versions of xdg-document-portal can expose data belonging to 146 # other confied apps. Older OpenSUSE releases are unlikely to change, 147 # so for now limit this to Tumbleweed. 148 %if 0%{?suse_version} >= 1550 149 Conflicts: xdg-desktop-portal < 0.11 150 %endif 151 152 %{?systemd_requires} 153 154 %description 155 This package contains that snapd daemon and the snap command line tool. 156 Together they can be used to install, refresh (update), remove and configure 157 snap packages on a system. Snap packages are a novel format based on simple 158 principles. Bundle your dependencies, run in a predictable environment, use 159 modern kernel features for setting up the execution environment and security. 160 The same binary snap package can be installed and used on many diverse systems 161 such as Debian, Fedora and OpenSUSE as well as their multiple derivatives. 162 163 This package contains the official build, endorsed by snapd developers. It is 164 updated as soon as new upstream releases are made and is designed to live in 165 the system:snappy repository. 166 167 %prep 168 # NOTE: Instead of using setup -q we are unpacking a subdirectory of the source 169 # tarball into a directory that is automatically on the future GOPATH. This 170 # means that while go doesn't care at all the current working directory is not 171 # the top-level directory of the source tarball which some people may find 172 # unusual. 173 174 # Create indigo compatible build layout. 175 mkdir -p %{indigo_srcdir} 176 tar -axf %{_sourcedir}/%{name}_%{version}.vendor.tar.xz --strip-components=1 -C %{indigo_srcdir} 177 178 # Patch the source in the place it got extracted to. 179 pushd %{indigo_srcdir} 180 # Add patch0 -p1 ... as appropriate here. 181 popd 182 183 # Generate snapd.defines.mk, this file is included by snapd.mk. It contains a 184 # number of variable definitions that are set based on their RPM equivalents. 185 # Since we can apply any conditional overrides here in the spec file we can 186 # maintain one consistent set of variables across the spec and makefile worlds. 187 cat >snapd.defines.mk <<__DEFINES__ 188 # This file is generated by openSUSE's snapd.spec 189 # Directory variables. 190 prefix = %{_prefix} 191 bindir = %{_bindir} 192 sbindir = %{_sbindir} 193 libexecdir = %{_libexecdir} 194 mandir = %{_mandir} 195 datadir = %{_datadir} 196 localstatedir = %{_localstatedir} 197 sharedstatedir = %{_sharedstatedir} 198 unitdir = %{_unitdir} 199 # Build configuration 200 with_core_bits = 0 201 with_alt_snap_mount_dir = %{!?with_alt_snap_mount_dir:0}%{?with_alt_snap_mount_dir:1} 202 with_apparmor = %{with apparmor} 203 with_testkeys = %{with_testkeys} 204 __DEFINES__ 205 206 # Set the version that is compiled into the various executables/ 207 pushd %{indigo_srcdir} 208 ./mkversion.sh %{version}-%{release} 209 popd 210 211 # Sanity check, ensure that systemd system generator directory is in agreement between the build system and packaging. 212 if [ "$(pkg-config --variable=systemdsystemgeneratordir systemd)" != "%{_systemdgeneratordir}" ]; then 213 echo "pkg-confing and rpm macros disagree about the location of systemd system generator directory" 214 exit 1 215 fi 216 217 # Enable hardening; Also see https://bugzilla.redhat.com/show_bug.cgi?id=1343892 218 CFLAGS="$RPM_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now" 219 CXXFLAGS="$RPM_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now" 220 LDFLAGS="" 221 222 # On openSUSE Leap 15 or more recent build position independent executables. 223 # For a helpful guide about the versions and macros used below, please see: 224 # https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto 225 %if 0%{?suse_version} >= 1500 226 CFLAGS="$CFLAGS -fPIE" 227 CXXFLAGS="$CXXFLAGS -fPIE" 228 LDFLAGS="$LDFLAGS -pie" 229 %endif 230 231 export CFLAGS 232 export CXXFLAGS 233 export LDFLAGS 234 235 # Generate autotools build system files. 236 pushd %{indigo_srcdir}/cmd 237 autoreconf -i -f 238 239 %configure \ 240 %{!?with_apparmor:--disable-apparmor} \ 241 %{?with_apparmor:--enable-apparmor} \ 242 --libexecdir=%{_libexecdir}/snapd \ 243 --enable-nvidia-biarch \ 244 %{?with_multilib:--with-32bit-libdir=%{_prefix}/lib} \ 245 --with-snap-mount-dir=%{snap_mount_dir} \ 246 --enable-merged-usr 247 248 popd 249 250 %build 251 %make_build -C %{indigo_srcdir}/cmd 252 # Use the common packaging helper for building. 253 # 254 # NOTE: indigo_gopath takes priority over GOPATH. This ensures that we 255 # build the code that we intended in case GOPATH points to another copy. 256 %make_build -f %{indigo_srcdir}/packaging/snapd.mk GOPATH=%{indigo_gopath}:$GOPATH all 257 258 %check 259 for binary in snap-exec snap-update-ns snapctl; do 260 ldd $binary 2>&1 | grep 'not a dynamic executable' 261 done 262 263 %make_build -C %{indigo_srcdir}/cmd check 264 # Use the common packaging helper for testing. 265 %make_build -f %{indigo_srcdir}/packaging/snapd.mk GOPATH=%{indigo_gopath}:$GOPATH check 266 267 %install 268 # Install all systemd and dbus units, and env files. 269 %make_install -C %{indigo_srcdir}/data \ 270 BINDIR=%{_bindir} \ 271 LIBEXECDIR=%{_libexecdir} \ 272 SYSTEMDSYSTEMUNITDIR=%{_unitdir} \ 273 SNAP_MOUNT_DIR=%{snap_mount_dir} 274 # Install all the C executables. 275 %make_install -C %{indigo_srcdir}/cmd 276 # Use the common packaging helper for bulk of installation. 277 %make_install -f %{indigo_srcdir}/packaging/snapd.mk install 278 279 # Undo special permissions of the void directory. We handle that in RPM files 280 # section below. 281 chmod 755 %{buildroot}%{_localstatedir}/lib/snapd/void 282 283 # Install local permissions policy for snap-confine. This should be removed 284 # once snap-confine is added to the permissions package. This is done following 285 # the recommendations on 286 # https://en.opensuse.org/openSUSE:Package_security_guidelines 287 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions %{buildroot}%{_sysconfdir}/permissions.d/snapd 288 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions.paranoid %{buildroot}%{_sysconfdir}/permissions.d/snapd.paranoid 289 290 # See https://en.opensuse.org/openSUSE:Packaging_checks#suse-missing-rclink for details 291 install -d %{buildroot}%{_sbindir} 292 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd 293 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.seeded 294 %if %{with apparmor} 295 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.apparmor 296 %endif 297 298 # Install Polkit configuration. 299 # TODO: This should be handled by data makefile. 300 install -m 644 -D %{indigo_srcdir}/data/polkit/io.snapcraft.snapd.policy %{buildroot}%{_datadir}/polkit-1/actions 301 302 # Install the "info" data file with snapd version 303 # TODO: This should be handled by data makefile. 304 install -m 644 -D %{indigo_srcdir}/data/info %{buildroot}%{_libexecdir}/snapd/info 305 306 # Install bash completion for "snap" 307 # TODO: This should be handled by data makefile. 308 install -m 644 -D %{indigo_srcdir}/data/completion/bash/snap %{buildroot}%{_datadir}/bash-completion/completions/snap 309 install -m 644 -D %{indigo_srcdir}/data/completion/bash/complete.sh %{buildroot}%{_libexecdir}/snapd 310 install -m 644 -D %{indigo_srcdir}/data/completion/bash/etelpmoc.sh %{buildroot}%{_libexecdir}/snapd 311 # Install zsh completion for "snap" 312 install -d -p %{buildroot}%{_datadir}/zsh/site-functions 313 install -m 644 -D %{indigo_srcdir}/data/completion/zsh/_snap %{buildroot}%{_datadir}/zsh/site-functions/_snap 314 315 %verifyscript 316 %verify_permissions -e %{_libexecdir}/snapd/snap-confine 317 318 %pre 319 %service_add_pre %{systemd_services_list} 320 321 %post 322 %set_permissions %{_libexecdir}/snapd/snap-confine 323 %if %{with apparmor} 324 %apparmor_reload /etc/apparmor.d/%{apparmor_snapconfine_profile} 325 %endif 326 %service_add_post %{systemd_services_list} 327 %systemd_user_post %{systemd_user_services_list} 328 case ":$PATH:" in 329 *:/snap/bin:*) 330 ;; 331 *) 332 echo "Please reboot, logout/login or source /etc/profile to have /snap/bin added to PATH." 333 echo "On a Tumbleweed system you need to run: systemctl enable snapd.apparmor.service" 334 ;; 335 esac 336 337 %preun 338 %service_del_preun %{systemd_services_list} 339 %systemd_user_preun %{systemd_user_services_list} 340 if [ $1 -eq 0 ]; then 341 %{_libexecdir}/snapd/snap-mgmt --purge || : 342 fi 343 344 %postun 345 %service_del_postun %{systemd_services_list} 346 %systemd_user_postun %{systemd_user_services_list} 347 348 %files 349 350 # Configuration files 351 %config %{_sysconfdir}/permissions.d/snapd 352 %config %{_sysconfdir}/permissions.d/snapd.paranoid 353 %config %{_sysconfdir}/profile.d/snapd.sh 354 355 # Directories 356 %dir %attr(0111,root,root) %{_sharedstatedir}/snapd/void 357 %dir %{_datadir}/dbus-1 358 %dir %{_datadir}/dbus-1/services 359 %dir %{_datadir}/dbus-1/session.d 360 %dir %{_datadir}/dbus-1/system.d 361 %dir %{_datadir}/polkit-1 362 %dir %{_datadir}/polkit-1/actions 363 %dir %{_environmentdir} 364 %dir %{_libexecdir}/snapd 365 %dir %{_localstatedir}/cache/snapd 366 %dir %{_sharedstatedir}/snapd 367 %dir %{_sharedstatedir}/snapd/apparmor 368 %dir %{_sharedstatedir}/snapd/apparmor/profiles 369 %dir %{_sharedstatedir}/snapd/apparmor/snap-confine 370 %dir %{_sharedstatedir}/snapd/assertions 371 %dir %{_sharedstatedir}/snapd/cache 372 %dir %{_sharedstatedir}/snapd/cookie 373 %dir %{_sharedstatedir}/snapd/dbus-1 374 %dir %{_sharedstatedir}/snapd/dbus-1/services 375 %dir %{_sharedstatedir}/snapd/dbus-1/system-services 376 %dir %{_sharedstatedir}/snapd/desktop 377 %dir %{_sharedstatedir}/snapd/desktop/applications 378 %dir %{_sharedstatedir}/snapd/device 379 %dir %{_sharedstatedir}/snapd/hostfs 380 %dir %{_sharedstatedir}/snapd/inhibit 381 %dir %{_sharedstatedir}/snapd/lib 382 %dir %{_sharedstatedir}/snapd/lib/gl 383 %dir %{_sharedstatedir}/snapd/lib/gl32 384 %dir %{_sharedstatedir}/snapd/lib/glvnd 385 %dir %{_sharedstatedir}/snapd/lib/vulkan 386 %dir %{_sharedstatedir}/snapd/mount 387 %dir %{_sharedstatedir}/snapd/seccomp 388 %dir %{_sharedstatedir}/snapd/seccomp/bpf 389 %dir %{_sharedstatedir}/snapd/sequence 390 %dir %{_sharedstatedir}/snapd/snaps 391 %dir %{_systemd_system_env_generator_dir} 392 %dir %{_systemdgeneratordir} 393 %dir %{_userunitdir} 394 %dir %{snap_mount_dir} 395 %dir %{snap_mount_dir}/bin 396 # this is typically owned by zsh, but we do not want to explicitly require zsh 397 %dir %{_datadir}/zsh 398 %dir %{_datadir}/zsh/site-functions 399 400 # Ghost entries for things created at runtime 401 %ghost %dir %{_localstatedir}/snap 402 %ghost %{_localstatedir}/cache/snapd/commands 403 %ghost %{_localstatedir}/cache/snapd/names 404 %ghost %{_localstatedir}/cache/snapd/sections 405 %ghost %{_sharedstatedir}/snapd/seccomp/bpf/global.bin 406 %ghost %{_sharedstatedir}/snapd/state.json 407 %ghost %{_sharedstatedir}/snapd/system-key 408 %ghost %{snap_mount_dir}/README 409 %verify(not user group mode) %attr(04755,root,root) %{_libexecdir}/snapd/snap-confine 410 %{_bindir}/snap 411 %{_bindir}/snapctl 412 %{_datadir}/applications/io.snapcraft.SessionAgent.desktop 413 %{_datadir}/applications/snap-handle-link.desktop 414 %{_datadir}/bash-completion/completions/snap 415 %{_datadir}/zsh/site-functions/_snap 416 %{_datadir}/dbus-1/services/io.snapcraft.Launcher.service 417 %{_datadir}/dbus-1/services/io.snapcraft.SessionAgent.service 418 %{_datadir}/dbus-1/services/io.snapcraft.Settings.service 419 %{_datadir}/dbus-1/session.d/snapd.session-services.conf 420 %{_datadir}/dbus-1/system.d/snapd.system-services.conf 421 %{_datadir}/polkit-1/actions/io.snapcraft.snapd.policy 422 %{_environmentdir}/990-snapd.conf 423 %{_libexecdir}/snapd/complete.sh 424 %{_libexecdir}/snapd/etelpmoc.sh 425 %{_libexecdir}/snapd/info 426 %{_libexecdir}/snapd/snap-device-helper 427 %{_libexecdir}/snapd/snap-discard-ns 428 %{_libexecdir}/snapd/snap-exec 429 %{_libexecdir}/snapd/snap-gdb-shim 430 %{_libexecdir}/snapd/snap-gdbserver-shim 431 %{_libexecdir}/snapd/snap-mgmt 432 %{_libexecdir}/snapd/snap-seccomp 433 %{_libexecdir}/snapd/snap-update-ns 434 %{_libexecdir}/snapd/snapctl 435 %{_libexecdir}/snapd/snapd 436 %{_libexecdir}/snapd/snapd.run-from-snap 437 %{_mandir}/man8/snap-confine.8* 438 %{_mandir}/man8/snap-discard-ns.8* 439 %{_mandir}/man8/snap.8* 440 %{_mandir}/man8/snapd-env-generator.8* 441 %{_sbindir}/rcsnapd 442 %{_sbindir}/rcsnapd.seeded 443 %{_sysconfdir}/xdg/autostart/snap-userd-autostart.desktop 444 %{_systemd_system_env_generator_dir}/snapd-env-generator 445 %{_systemdgeneratordir}/snapd-generator 446 %{_unitdir}/snapd.failure.service 447 %{_unitdir}/snapd.seeded.service 448 %{_unitdir}/snapd.service 449 %{_unitdir}/snapd.socket 450 %{_userunitdir}/snapd.session-agent.service 451 %{_userunitdir}/snapd.session-agent.socket 452 453 # When apparmor is enabled there are some additional entries. 454 %if %{with apparmor} 455 %config %{_sysconfdir}/apparmor.d 456 %{_libexecdir}/snapd/snapd-apparmor 457 %{_sbindir}/rcsnapd.apparmor 458 %{_sysconfdir}/apparmor.d/%{apparmor_snapconfine_profile} 459 %{_unitdir}/snapd.apparmor.service 460 %endif 461 462 %changelog