github.com/kubiko/snapd@v0.0.0-20201013125620-d4f3094d9ddf/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.47.1 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 %make_build -C %{indigo_srcdir}/cmd check 260 # Use the common packaging helper for testing. 261 %make_build -f %{indigo_srcdir}/packaging/snapd.mk GOPATH=%{indigo_gopath}:$GOPATH check 262 263 %install 264 # Install all systemd and dbus units, and env files. 265 %make_install -C %{indigo_srcdir}/data \ 266 BINDIR=%{_bindir} \ 267 LIBEXECDIR=%{_libexecdir} \ 268 SYSTEMDSYSTEMUNITDIR=%{_unitdir} \ 269 SNAP_MOUNT_DIR=%{snap_mount_dir} 270 # Install all the C executables. 271 %make_install -C %{indigo_srcdir}/cmd 272 # Use the common packaging helper for bulk of installation. 273 %make_install -f %{indigo_srcdir}/packaging/snapd.mk install 274 275 # Undo special permissions of the void directory. We handle that in RPM files 276 # section below. 277 chmod 755 %{buildroot}%{_localstatedir}/lib/snapd/void 278 279 # Install local permissions policy for snap-confine. This should be removed 280 # once snap-confine is added to the permissions package. This is done following 281 # the recommendations on 282 # https://en.opensuse.org/openSUSE:Package_security_guidelines 283 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions %{buildroot}%{_sysconfdir}/permissions.d/snapd 284 install -m 644 -D %{indigo_srcdir}/packaging/opensuse/permissions.paranoid %{buildroot}%{_sysconfdir}/permissions.d/snapd.paranoid 285 286 # See https://en.opensuse.org/openSUSE:Packaging_checks#suse-missing-rclink for details 287 install -d %{buildroot}%{_sbindir} 288 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd 289 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.seeded 290 %if %{with apparmor} 291 ln -sf %{_sbindir}/service %{buildroot}%{_sbindir}/rcsnapd.apparmor 292 %endif 293 294 # Install Polkit configuration. 295 # TODO: This should be handled by data makefile. 296 install -m 644 -D %{indigo_srcdir}/data/polkit/io.snapcraft.snapd.policy %{buildroot}%{_datadir}/polkit-1/actions 297 298 # Install the "info" data file with snapd version 299 # TODO: This should be handled by data makefile. 300 install -m 644 -D %{indigo_srcdir}/data/info %{buildroot}%{_libexecdir}/snapd/info 301 302 # Install bash completion for "snap" 303 # TODO: This should be handled by data makefile. 304 install -m 644 -D %{indigo_srcdir}/data/completion/bash/snap %{buildroot}%{_datadir}/bash-completion/completions/snap 305 install -m 644 -D %{indigo_srcdir}/data/completion/bash/complete.sh %{buildroot}%{_libexecdir}/snapd 306 install -m 644 -D %{indigo_srcdir}/data/completion/bash/etelpmoc.sh %{buildroot}%{_libexecdir}/snapd 307 # Install zsh completion for "snap" 308 install -d -p %{buildroot}%{_datadir}/zsh/site-functions 309 install -m 644 -D %{indigo_srcdir}/data/completion/zsh/_snap %{buildroot}%{_datadir}/zsh/site-functions/_snap 310 311 %verifyscript 312 %verify_permissions -e %{_libexecdir}/snapd/snap-confine 313 314 %pre 315 %service_add_pre %{systemd_services_list} 316 317 %post 318 %set_permissions %{_libexecdir}/snapd/snap-confine 319 %if %{with apparmor} 320 %apparmor_reload /etc/apparmor.d/usr.lib.snapd.snap-confine 321 %endif 322 %service_add_post %{systemd_services_list} 323 %systemd_user_post %{systemd_user_services_list} 324 case ":$PATH:" in 325 *:/snap/bin:*) 326 ;; 327 *) 328 echo "Please reboot, logout/login or source /etc/profile to have /snap/bin added to PATH." 329 echo "On a Tumbleweed system you need to run: systemctl enable snapd.apparmor.service" 330 ;; 331 esac 332 333 %preun 334 %service_del_preun %{systemd_services_list} 335 %systemd_user_preun %{systemd_user_services_list} 336 if [ $1 -eq 0 ]; then 337 %{_libexecdir}/snapd/snap-mgmt --purge || : 338 fi 339 340 %postun 341 %service_del_postun %{systemd_services_list} 342 %systemd_user_postun %{systemd_user_services_list} 343 344 %files 345 346 # Configuration files 347 %config %{_sysconfdir}/permissions.d/snapd 348 %config %{_sysconfdir}/permissions.d/snapd.paranoid 349 %config %{_sysconfdir}/profile.d/snapd.sh 350 351 # Directories 352 %dir %attr(0111,root,root) %{_sharedstatedir}/snapd/void 353 %dir %{_datadir}/dbus-1 354 %dir %{_datadir}/dbus-1/services 355 %dir %{_datadir}/dbus-1/session.d 356 %dir %{_datadir}/dbus-1/system.d 357 %dir %{_datadir}/polkit-1 358 %dir %{_datadir}/polkit-1/actions 359 %dir %{_environmentdir} 360 %dir %{_libexecdir}/snapd 361 %dir %{_localstatedir}/cache/snapd 362 %dir %{_sharedstatedir}/snapd 363 %dir %{_sharedstatedir}/snapd/apparmor 364 %dir %{_sharedstatedir}/snapd/apparmor/profiles 365 %dir %{_sharedstatedir}/snapd/apparmor/snap-confine 366 %dir %{_sharedstatedir}/snapd/assertions 367 %dir %{_sharedstatedir}/snapd/cache 368 %dir %{_sharedstatedir}/snapd/cookie 369 %dir %{_sharedstatedir}/snapd/dbus-1 370 %dir %{_sharedstatedir}/snapd/dbus-1/services 371 %dir %{_sharedstatedir}/snapd/dbus-1/system-services 372 %dir %{_sharedstatedir}/snapd/desktop 373 %dir %{_sharedstatedir}/snapd/desktop/applications 374 %dir %{_sharedstatedir}/snapd/device 375 %dir %{_sharedstatedir}/snapd/hostfs 376 %dir %{_sharedstatedir}/snapd/inhibit 377 %dir %{_sharedstatedir}/snapd/lib 378 %dir %{_sharedstatedir}/snapd/lib/gl 379 %dir %{_sharedstatedir}/snapd/lib/gl32 380 %dir %{_sharedstatedir}/snapd/lib/glvnd 381 %dir %{_sharedstatedir}/snapd/lib/vulkan 382 %dir %{_sharedstatedir}/snapd/mount 383 %dir %{_sharedstatedir}/snapd/seccomp 384 %dir %{_sharedstatedir}/snapd/seccomp/bpf 385 %dir %{_sharedstatedir}/snapd/sequence 386 %dir %{_sharedstatedir}/snapd/snaps 387 %dir %{_systemd_system_env_generator_dir} 388 %dir %{_systemdgeneratordir} 389 %dir %{_userunitdir} 390 %dir %{snap_mount_dir} 391 %dir %{snap_mount_dir}/bin 392 # this is typically owned by zsh, but we do not want to explicitly require zsh 393 %dir %{_datadir}/zsh 394 %dir %{_datadir}/zsh/site-functions 395 396 # Ghost entries for things created at runtime 397 %ghost %dir %{_localstatedir}/snap 398 %ghost %{_localstatedir}/cache/snapd/commands 399 %ghost %{_localstatedir}/cache/snapd/names 400 %ghost %{_localstatedir}/cache/snapd/sections 401 %ghost %{_sharedstatedir}/snapd/seccomp/bpf/global.bin 402 %ghost %{_sharedstatedir}/snapd/state.json 403 %ghost %{_sharedstatedir}/snapd/system-key 404 %ghost %{snap_mount_dir}/README 405 %verify(not user group mode) %attr(04755,root,root) %{_libexecdir}/snapd/snap-confine 406 %{_bindir}/snap 407 %{_bindir}/snapctl 408 %{_datadir}/applications/snap-handle-link.desktop 409 %{_datadir}/bash-completion/completions/snap 410 %{_datadir}/zsh/site-functions/_snap 411 %{_datadir}/dbus-1/services/io.snapcraft.Launcher.service 412 %{_datadir}/dbus-1/services/io.snapcraft.Settings.service 413 %{_datadir}/dbus-1/session.d/snapd.session-services.conf 414 %{_datadir}/dbus-1/system.d/snapd.system-services.conf 415 %{_datadir}/polkit-1/actions/io.snapcraft.snapd.policy 416 %{_environmentdir}/990-snapd.conf 417 %{_libexecdir}/snapd/complete.sh 418 %{_libexecdir}/snapd/etelpmoc.sh 419 %{_libexecdir}/snapd/info 420 %{_libexecdir}/snapd/snap-device-helper 421 %{_libexecdir}/snapd/snap-discard-ns 422 %{_libexecdir}/snapd/snap-exec 423 %{_libexecdir}/snapd/snap-gdb-shim 424 %{_libexecdir}/snapd/snap-gdbserver-shim 425 %{_libexecdir}/snapd/snap-mgmt 426 %{_libexecdir}/snapd/snap-seccomp 427 %{_libexecdir}/snapd/snap-update-ns 428 %{_libexecdir}/snapd/snapctl 429 %{_libexecdir}/snapd/snapd 430 %{_libexecdir}/snapd/snapd.run-from-snap 431 %{_mandir}/man8/snap-confine.8* 432 %{_mandir}/man8/snap-discard-ns.8* 433 %{_mandir}/man8/snap.8* 434 %{_mandir}/man8/snapd-env-generator.8* 435 %{_sbindir}/rcsnapd 436 %{_sbindir}/rcsnapd.seeded 437 %{_sysconfdir}/xdg/autostart/snap-userd-autostart.desktop 438 %{_systemd_system_env_generator_dir}/snapd-env-generator 439 %{_systemdgeneratordir}/snapd-generator 440 %{_unitdir}/snapd.failure.service 441 %{_unitdir}/snapd.seeded.service 442 %{_unitdir}/snapd.service 443 %{_unitdir}/snapd.socket 444 %{_userunitdir}/snapd.session-agent.service 445 %{_userunitdir}/snapd.session-agent.socket 446 447 # When apparmor is enabled there are some additional entries. 448 %if %{with apparmor} 449 %config %{_sysconfdir}/apparmor.d 450 %{_libexecdir}/snapd/snapd-apparmor 451 %{_sbindir}/rcsnapd.apparmor 452 %{_sysconfdir}/apparmor.d/%{apparmor_snapconfine_profile} 453 %{_unitdir}/snapd.apparmor.service 454 %endif 455 456 %changelog