github.com/Lephar/snapd@v0.0.0-20210825215435-c7fba9cef4d2/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.51.6 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 BuildRequires: ca-certificates 128 BuildRequires: ca-certificates-mozilla 129 130 %if %{with apparmor} 131 BuildRequires: libapparmor-devel 132 BuildRequires: apparmor-rpm-macros 133 %endif 134 135 PreReq: permissions 136 137 Requires(post): permissions 138 %if %{with apparmor} 139 Requires: apparmor-parser 140 Requires: apparmor-profiles 141 %endif 142 Requires: gpg2 143 Requires: openssh 144 Requires: squashfs 145 Requires: system-user-daemon 146 147 # Old versions of xdg-document-portal can expose data belonging to 148 # other confied apps. Older OpenSUSE releases are unlikely to change, 149 # so for now limit this to Tumbleweed. 150 %if 0%{?suse_version} >= 1550 151 Conflicts: xdg-desktop-portal < 0.11 152 %endif 153 154 %{?systemd_requires} 155 156 %description 157 This package contains that snapd daemon and the snap command line tool. 158 Together they can be used to install, refresh (update), remove and configure 159 snap packages on a system. Snap packages are a novel format based on simple 160 principles. Bundle your dependencies, run in a predictable environment, use 161 modern kernel features for setting up the execution environment and security. 162 The same binary snap package can be installed and used on many diverse systems 163 such as Debian, Fedora and OpenSUSE as well as their multiple derivatives. 164 165 This package contains the official build, endorsed by snapd developers. It is 166 updated as soon as new upstream releases are made and is designed to live in 167 the system:snappy repository. 168 169 %prep 170 # NOTE: Instead of using setup -q we are unpacking a subdirectory of the source 171 # tarball into a directory that is automatically on the future GOPATH. This 172 # means that while go doesn't care at all the current working directory is not 173 # the top-level directory of the source tarball which some people may find 174 # unusual. 175 176 # Create indigo compatible build layout. 177 mkdir -p %{indigo_srcdir} 178 tar -axf %{_sourcedir}/%{name}_%{version}.vendor.tar.xz --strip-components=1 -C %{indigo_srcdir} 179 180 # Patch the source in the place it got extracted to. 181 pushd %{indigo_srcdir} 182 # Add patch0 -p1 ... as appropriate here. 183 popd 184 185 # Generate snapd.defines.mk, this file is included by snapd.mk. It contains a 186 # number of variable definitions that are set based on their RPM equivalents. 187 # Since we can apply any conditional overrides here in the spec file we can 188 # maintain one consistent set of variables across the spec and makefile worlds. 189 cat >snapd.defines.mk <<__DEFINES__ 190 # This file is generated by openSUSE's snapd.spec 191 # Directory variables. 192 prefix = %{_prefix} 193 bindir = %{_bindir} 194 sbindir = %{_sbindir} 195 libexecdir = %{_libexecdir} 196 mandir = %{_mandir} 197 datadir = %{_datadir} 198 localstatedir = %{_localstatedir} 199 sharedstatedir = %{_sharedstatedir} 200 unitdir = %{_unitdir} 201 # Build configuration 202 with_core_bits = 0 203 with_alt_snap_mount_dir = %{!?with_alt_snap_mount_dir:0}%{?with_alt_snap_mount_dir:1} 204 with_apparmor = %{with apparmor} 205 with_testkeys = %{with_testkeys} 206 __DEFINES__ 207 208 # Set the version that is compiled into the various executables/ 209 pushd %{indigo_srcdir} 210 ./mkversion.sh %{version}-%{release} 211 popd 212 213 # Sanity check, ensure that systemd system generator directory is in agreement between the build system and packaging. 214 if [ "$(pkg-config --variable=systemdsystemgeneratordir systemd)" != "%{_systemdgeneratordir}" ]; then 215 echo "pkg-confing and rpm macros disagree about the location of systemd system generator directory" 216 exit 1 217 fi 218 219 # Enable hardening; Also see https://bugzilla.redhat.com/show_bug.cgi?id=1343892 220 CFLAGS="$RPM_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now" 221 CXXFLAGS="$RPM_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now" 222 LDFLAGS="" 223 224 # On openSUSE Leap 15 or more recent build position independent executables. 225 # For a helpful guide about the versions and macros used below, please see: 226 # https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto 227 %if 0%{?suse_version} >= 1500 228 CFLAGS="$CFLAGS -fPIE" 229 CXXFLAGS="$CXXFLAGS -fPIE" 230 LDFLAGS="$LDFLAGS -pie" 231 %endif 232 233 export CFLAGS 234 export CXXFLAGS 235 export LDFLAGS 236 237 # Generate autotools build system files. 238 pushd %{indigo_srcdir}/cmd 239 autoreconf -i -f 240 241 %configure \ 242 %{!?with_apparmor:--disable-apparmor} \ 243 %{?with_apparmor:--enable-apparmor} \ 244 --libexecdir=%{_libexecdir}/snapd \ 245 --enable-nvidia-biarch \ 246 %{?with_multilib:--with-32bit-libdir=%{_prefix}/lib} \ 247 --with-snap-mount-dir=%{snap_mount_dir} \ 248 --enable-merged-usr 249 250 popd 251 252 %build 253 %make_build -C %{indigo_srcdir}/cmd 254 # Use the common packaging helper for building. 255 # 256 # NOTE: indigo_gopath takes priority over GOPATH. This ensures that we 257 # build the code that we intended in case GOPATH points to another copy. 258 %make_build -f %{indigo_srcdir}/packaging/snapd.mk GOPATH=%{indigo_gopath}:$GOPATH all 259 260 %check 261 for binary in snap-exec snap-update-ns snapctl; do 262 ldd $binary 2>&1 | grep 'not a dynamic executable' 263 done 264 265 %make_build -C %{indigo_srcdir}/cmd check 266 # Use the common packaging helper for testing. 267 %make_build -f %{indigo_srcdir}/packaging/snapd.mk GOPATH=%{indigo_gopath}:$GOPATH check 268 269 %install 270 # Install all systemd and dbus units, and env files. 271 %make_install -C %{indigo_srcdir}/data \ 272 BINDIR=%{_bindir} \ 273 LIBEXECDIR=%{_libexecdir} \ 274 SYSTEMDSYSTEMUNITDIR=%{_unitdir} \ 275 SNAP_MOUNT_DIR=%{snap_mount_dir} 276 # Install all the C executables. 277 %make_install -C %{indigo_srcdir}/cmd 278 # Use the common packaging helper for bulk of installation. 279 %make_install -f %{indigo_srcdir}/packaging/snapd.mk install 280 281 # Undo special permissions of the void directory. We handle that in RPM files 282 # section below. 283 chmod 755 %{buildroot}%{_localstatedir}/lib/snapd/void 284 285 # Install local permissions policy for snap-confine. This should be removed 286 # once snap-confine is added to the permissions package. This is done following 287 # the recommendations on 288 # https://en.opensuse.org/openSUSE:Package_security_guidelines 289 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions %{buildroot}%{_sysconfdir}/permissions.d/snapd 290 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions.paranoid %{buildroot}%{_sysconfdir}/permissions.d/snapd.paranoid 291 292 # See https://en.opensuse.org/openSUSE:Packaging_checks#suse-missing-rclink for details 293 install -d %{buildroot}%{_sbindir} 294 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd 295 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.seeded 296 %if %{with apparmor} 297 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.apparmor 298 %endif 299 300 # Install Polkit configuration. 301 # TODO: This should be handled by data makefile. 302 install -m 644 -D %{indigo_srcdir}/data/polkit/io.snapcraft.snapd.policy %{buildroot}%{_datadir}/polkit-1/actions 303 304 # Install the "info" data file with snapd version 305 # TODO: This should be handled by data makefile. 306 install -m 644 -D %{indigo_srcdir}/data/info %{buildroot}%{_libexecdir}/snapd/info 307 308 # Install bash completion for "snap" 309 # TODO: This should be handled by data makefile. 310 install -m 644 -D %{indigo_srcdir}/data/completion/bash/snap %{buildroot}%{_datadir}/bash-completion/completions/snap 311 install -m 644 -D %{indigo_srcdir}/data/completion/bash/complete.sh %{buildroot}%{_libexecdir}/snapd 312 install -m 644 -D %{indigo_srcdir}/data/completion/bash/etelpmoc.sh %{buildroot}%{_libexecdir}/snapd 313 # Install zsh completion for "snap" 314 install -d -p %{buildroot}%{_datadir}/zsh/site-functions 315 install -m 644 -D %{indigo_srcdir}/data/completion/zsh/_snap %{buildroot}%{_datadir}/zsh/site-functions/_snap 316 317 %verifyscript 318 %verify_permissions -e %{_libexecdir}/snapd/snap-confine 319 320 %pre 321 %service_add_pre %{systemd_services_list} 322 323 %post 324 %set_permissions %{_libexecdir}/snapd/snap-confine 325 %if %{with apparmor} 326 %apparmor_reload /etc/apparmor.d/%{apparmor_snapconfine_profile} 327 %endif 328 %service_add_post %{systemd_services_list} 329 %systemd_user_post %{systemd_user_services_list} 330 case ":$PATH:" in 331 *:/snap/bin:*) 332 ;; 333 *) 334 echo "Please reboot, logout/login or source /etc/profile to have /snap/bin added to PATH." 335 echo "On a Tumbleweed system you need to run: systemctl enable snapd.apparmor.service" 336 ;; 337 esac 338 339 %preun 340 %service_del_preun %{systemd_services_list} 341 %systemd_user_preun %{systemd_user_services_list} 342 if [ $1 -eq 0 ]; then 343 %{_libexecdir}/snapd/snap-mgmt --purge || : 344 fi 345 346 %postun 347 %service_del_postun %{systemd_services_list} 348 %systemd_user_postun %{systemd_user_services_list} 349 350 %files 351 352 # Configuration files 353 %config %{_sysconfdir}/permissions.d/snapd 354 %config %{_sysconfdir}/permissions.d/snapd.paranoid 355 %config %{_sysconfdir}/profile.d/snapd.sh 356 357 # Directories 358 %dir %attr(0111,root,root) %{_sharedstatedir}/snapd/void 359 %dir %{_datadir}/dbus-1 360 %dir %{_datadir}/dbus-1/services 361 %dir %{_datadir}/dbus-1/session.d 362 %dir %{_datadir}/dbus-1/system.d 363 %dir %{_datadir}/polkit-1 364 %dir %{_datadir}/polkit-1/actions 365 %dir %{_environmentdir} 366 %dir %{_libexecdir}/snapd 367 %dir %{_localstatedir}/cache/snapd 368 %dir %{_sharedstatedir}/snapd 369 %dir %{_sharedstatedir}/snapd/apparmor 370 %dir %{_sharedstatedir}/snapd/apparmor/profiles 371 %dir %{_sharedstatedir}/snapd/apparmor/snap-confine 372 %dir %{_sharedstatedir}/snapd/assertions 373 %dir %{_sharedstatedir}/snapd/cache 374 %dir %{_sharedstatedir}/snapd/cookie 375 %dir %{_sharedstatedir}/snapd/dbus-1 376 %dir %{_sharedstatedir}/snapd/dbus-1/services 377 %dir %{_sharedstatedir}/snapd/dbus-1/system-services 378 %dir %{_sharedstatedir}/snapd/desktop 379 %dir %{_sharedstatedir}/snapd/desktop/applications 380 %dir %{_sharedstatedir}/snapd/device 381 %dir %{_sharedstatedir}/snapd/hostfs 382 %dir %{_sharedstatedir}/snapd/inhibit 383 %dir %{_sharedstatedir}/snapd/lib 384 %dir %{_sharedstatedir}/snapd/lib/gl 385 %dir %{_sharedstatedir}/snapd/lib/gl32 386 %dir %{_sharedstatedir}/snapd/lib/glvnd 387 %dir %{_sharedstatedir}/snapd/lib/vulkan 388 %dir %{_sharedstatedir}/snapd/mount 389 %dir %{_sharedstatedir}/snapd/seccomp 390 %dir %{_sharedstatedir}/snapd/seccomp/bpf 391 %dir %{_sharedstatedir}/snapd/sequence 392 %dir %{_sharedstatedir}/snapd/snaps 393 %dir %{_systemd_system_env_generator_dir} 394 %dir %{_systemdgeneratordir} 395 %dir %{_userunitdir} 396 %dir %{snap_mount_dir} 397 %dir %{snap_mount_dir}/bin 398 # this is typically owned by zsh, but we do not want to explicitly require zsh 399 %dir %{_datadir}/zsh 400 %dir %{_datadir}/zsh/site-functions 401 402 # Ghost entries for things created at runtime 403 %ghost %dir %{_localstatedir}/snap 404 %ghost %{_localstatedir}/cache/snapd/commands 405 %ghost %{_localstatedir}/cache/snapd/names 406 %ghost %{_localstatedir}/cache/snapd/sections 407 %ghost %{_sharedstatedir}/snapd/seccomp/bpf/global.bin 408 %ghost %{_sharedstatedir}/snapd/state.json 409 %ghost %{_sharedstatedir}/snapd/system-key 410 %ghost %{snap_mount_dir}/README 411 %verify(not user group mode) %attr(04755,root,root) %{_libexecdir}/snapd/snap-confine 412 %{_bindir}/snap 413 %{_bindir}/snapctl 414 %{_datadir}/applications/io.snapcraft.SessionAgent.desktop 415 %{_datadir}/applications/snap-handle-link.desktop 416 %{_datadir}/bash-completion/completions/snap 417 %{_datadir}/zsh/site-functions/_snap 418 %{_datadir}/dbus-1/services/io.snapcraft.Launcher.service 419 %{_datadir}/dbus-1/services/io.snapcraft.SessionAgent.service 420 %{_datadir}/dbus-1/services/io.snapcraft.Settings.service 421 %{_datadir}/dbus-1/session.d/snapd.session-services.conf 422 %{_datadir}/dbus-1/system.d/snapd.system-services.conf 423 %{_datadir}/polkit-1/actions/io.snapcraft.snapd.policy 424 %{_environmentdir}/990-snapd.conf 425 %{_libexecdir}/snapd/complete.sh 426 %{_libexecdir}/snapd/etelpmoc.sh 427 %{_libexecdir}/snapd/info 428 %{_libexecdir}/snapd/snap-device-helper 429 %{_libexecdir}/snapd/snap-discard-ns 430 %{_libexecdir}/snapd/snap-exec 431 %{_libexecdir}/snapd/snap-gdb-shim 432 %{_libexecdir}/snapd/snap-gdbserver-shim 433 %{_libexecdir}/snapd/snap-mgmt 434 %{_libexecdir}/snapd/snap-seccomp 435 %{_libexecdir}/snapd/snap-update-ns 436 %{_libexecdir}/snapd/snapctl 437 %{_libexecdir}/snapd/snapd 438 %{_libexecdir}/snapd/snapd.run-from-snap 439 %{_mandir}/man8/snap-confine.8* 440 %{_mandir}/man8/snap-discard-ns.8* 441 %{_mandir}/man8/snap.8* 442 %{_mandir}/man8/snapd-env-generator.8* 443 %{_sbindir}/rcsnapd 444 %{_sbindir}/rcsnapd.seeded 445 %{_sysconfdir}/xdg/autostart/snap-userd-autostart.desktop 446 %{_systemd_system_env_generator_dir}/snapd-env-generator 447 %{_systemdgeneratordir}/snapd-generator 448 %{_unitdir}/snapd.failure.service 449 %{_unitdir}/snapd.seeded.service 450 %{_unitdir}/snapd.service 451 %{_unitdir}/snapd.socket 452 %{_userunitdir}/snapd.session-agent.service 453 %{_userunitdir}/snapd.session-agent.socket 454 455 # When apparmor is enabled there are some additional entries. 456 %if %{with apparmor} 457 %config %{_sysconfdir}/apparmor.d 458 %{_libexecdir}/snapd/snapd-apparmor 459 %{_sbindir}/rcsnapd.apparmor 460 %{_sysconfdir}/apparmor.d/%{apparmor_snapconfine_profile} 461 %{_unitdir}/snapd.apparmor.service 462 %endif 463 464 %changelog