3 %bcond_with tests # build with tests
4 %bcond_with selinux # selinux
6 Summary: A transactional software package manager
12 Source0: https://github.com/snapcore/snapd/releases/download/%{version}/%{name}_%{version}.vendor.tar.xz
13 # Source0-md5: 9c6a50f07b33587519f2d1e0656c5f6f
14 # Script to implement certain package management actions
17 Source3: %{name}.sysconfig
18 Patch0: pld_is_like_fedora.patch
19 URL: https://github.com/snapcore/snapd
20 BuildRequires: %{_bindir}/rst2man
21 BuildRequires: autoconf
22 BuildRequires: automake
24 BuildRequires: gettext
25 BuildRequires: glib2-devel
26 BuildRequires: glibc-static
30 BuildRequires: libcap-devel
31 BuildRequires: libseccomp-static
32 BuildRequires: libtool
33 BuildRequires: pkgconfig
34 BuildRequires: systemd-devel
35 BuildRequires: systemd-units
36 BuildRequires: tar >= 1:1.22
37 BuildRequires: udev-devel
38 BuildRequires: valgrind
39 BuildRequires: xfsprogs-devel
43 Obsoletes: snap-confine
44 ExclusiveArch: %{ix86} %{x8664} %{arm} aarch64 ppc64le s390x
45 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
47 %define _udevrulesdir /lib/udev/rules.d
49 %define _enable_debug_packages 0
50 %define gobuild(o:) go build -ldflags "-extldflags '${LDFLAGS:-}' -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
51 %define gopath %{_libdir}/golang
52 %define import_path github.com/snapcore/snapd
54 %define snappy_svcs snapd.service snapd.socket snapd.apparmor.service snapd.core-fixup.service snapd.failure.service snapd.seeded.service snapd.autoimport.service snapd.snap-repair.timer
57 Snappy is a modern, cross-distribution, transactional package manager
58 designed for working with self-contained, immutable packages.
61 Summary: SELinux module for snapd
65 BuildRequires: selinux-policy
66 BuildRequires: selinux-policy-devel
68 Requires(post): selinux-policy-base >= %{_selinux_policy_version}
69 Requires(post): policycoreutils
70 Requires(post): policycoreutils-python-utils
71 Requires(pre): libselinux-utils
72 Requires(post): libselinux-utils
76 This package provides the SELinux policy module to ensure snapd runs
77 properly under an environment with SELinux enabled.
79 %package -n bash-completion-%{name}
80 Summary: bash-completion for %{name}
81 Group: Applications/Shells
82 Requires: %{name} = %{version}-%{release}
83 Requires: bash-completion
86 %description -n bash-completion-%{name}
87 bash-completion for %{name}.
93 # Generate version files
94 ./mkversion.sh "%{version}-%{release}"
97 mkdir -p src/github.com/snapcore
98 ln -s ../../../ src/github.com/snapcore/snapd
101 export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
103 LDFLAGS="%{rpmldflags}"
104 %gobuild -o bin/snap %{import_path}/cmd/snap
105 %gobuild -o bin/snapctl %{import_path}/cmd/snapctl
106 %gobuild -o bin/snapd %{import_path}/cmd/snapd
107 %gobuild -o bin/snap-failure %{import_path}/cmd/snap-failure
109 # these should be statically linked, for some reason
110 LDFLAGS="%{rpmldflags} -static"
111 %gobuild -o bin/snap-update-ns %{import_path}/cmd/snap-update-ns
112 %gobuild -o bin/snap-exec %{import_path}/cmd/snap-exec
113 %gobuild -o bin/snap-seccomp %{import_path}/cmd/snap-seccomp
116 LDFLAGS="%{rpmldflags}"
120 %{__make} SHARE="%{_datadir}" TARGETS="snappy"
126 autoreconf --force --install --verbose
127 # selinux support is not yet available, for now just disable apparmor
128 # FIXME: add --enable-caps-over-setuid as soon as possible (setuid discouraged!)
131 --libexecdir=%{_libexecdir}/snapd/ \
132 --with-snap-mount-dir=%{_sharedstatedir}/snapd/snap \
136 BINDIR="%{_bindir}" \
137 LIBEXECDIR="%{_libexecdir}"
140 # Build systemd units
143 BINDIR="%{_bindir}" \
144 LIBEXECDIR="%{_libexecdir}" \
145 SNAP_MOUNT_DIR="%{_sharedstatedir}/snapd/snap" \
146 SNAPD_ENVIRONMENT_FILE="%{_sysconfdir}/sysconfig/snapd"
150 export GOPATH=$RPM_BUILD_ROOT/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
151 %gotest %{import_path}/...
153 # snap-confine tests (these always run!)
160 rm -rf $RPM_BUILD_ROOT
161 install -d -p $RPM_BUILD_ROOT%{_bindir}
162 install -d -p $RPM_BUILD_ROOT%{_libexecdir}/snapd
163 install -d -p $RPM_BUILD_ROOT%{_mandir}/man1
164 install -d -p $RPM_BUILD_ROOT%{systemdunitdir}
165 install -d -p $RPM_BUILD_ROOT/etc/profile.d
166 install -d -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
167 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/assertions
168 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/desktop/applications
169 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/device
170 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/hostfs
171 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/mount
172 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/seccomp/profiles
173 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/snaps
174 install -d -p $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/snap/bin
175 install -d -p $RPM_BUILD_ROOT%{_localstatedir}/snap
176 install -d -p $RPM_BUILD_ROOT%{_prefix}/lib
178 # Install snap and snapd
179 install -p bin/snap $RPM_BUILD_ROOT%{_bindir}
180 install -p bin/snap-exec $RPM_BUILD_ROOT%{_libexecdir}/snapd
181 install -p bin/snapctl $RPM_BUILD_ROOT%{_bindir}/snapctl
182 install -p bin/snapd $RPM_BUILD_ROOT%{_libexecdir}/snapd
183 install -p bin/snap-update-ns $RPM_BUILD_ROOT%{_libexecdir}/snapd
184 install -p bin/snap-seccomp $RPM_BUILD_ROOT%{_libexecdir}/snapd
185 install -p bin/snap-failure $RPM_BUILD_ROOT%{_libexecdir}/snapd
188 install -d -p $RPM_BUILD_ROOT%{_datadir}/selinux/devel/include/contrib
189 install -d -p $RPM_BUILD_ROOT%{_datadir}/selinux/packages
190 install -p data/selinux/snappy.if $RPM_BUILD_ROOT%{_datadir}/selinux/devel/include/contrib
191 install -p data/selinux/snappy.pp.bz2 $RPM_BUILD_ROOT%{_datadir}/selinux/packages
194 # Install snap(1) man page
195 bin/snap help --man > $RPM_BUILD_ROOT%{_mandir}/man1/snap.1
197 # Install the "info" data file with snapd version
198 install -D data/info $RPM_BUILD_ROOT%{_libexecdir}/snapd/info
200 # Install bash completion for "snap"
201 install -D data/completion/snap $RPM_BUILD_ROOT%{bash_compdir}/snap
203 # Install snap-confine
206 LIBEXECDIR="%{_libexecdir}" \
207 DESTDIR=$RPM_BUILD_ROOT
208 # Undo the 0000 permissions, they are restored in the files section
209 chmod 0755 $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/void
210 # We don't use AppArmor
211 rm -rfv $RPM_BUILD_ROOT%{_sysconfdir}/apparmor.d
212 # ubuntu-core-launcher is dead
213 rm -fv $RPM_BUILD_ROOT%{_bindir}/ubuntu-core-launcher
216 # Install all systemd units
219 LIBEXECDIR="%{_libexecdir}" \
220 DESTDIR=$RPM_BUILD_ROOT SYSTEMDSYSTEMUNITDIR="%{systemdunitdir}"
221 # Remove snappy core specific units
222 rm -fv $RPM_BUILD_ROOT%{systemdunitdir}/snapd.system-shutdown.service
225 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/profile.d/snapd.sh
226 cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/snapd
228 # Install snap management script
229 install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_libexecdir}/snapd/snap-mgmt
231 # Create state.json file to be ghosted
232 touch $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/state.json
234 # some things are still looked for in the wrong dir
235 ln -s "%{_libexecdir}/snapd" "$RPM_BUILD_ROOT%{_prefix}/lib/snapd"
238 rm -rf $RPM_BUILD_ROOT
241 %systemd_post %{snappy_svcs}
242 # If install, test if snapd socket and timer are enabled.
243 # If enabled, then attempt to start them. This will silently fail
244 # in chroots or other environments where services aren't expected
246 if [ $1 -eq 1 ] ; then
247 if systemctl -q is-enabled snapd.socket > /dev/null 2>&1 ; then
248 systemctl start snapd.socket > /dev/null 2>&1 || :
250 if systemctl -q is-enabled snapd.snap-repair.timer > /dev/null 2>&1 ; then
251 systemctl start snapd.snap-repair.timer > /dev/null 2>&1 || :
256 %systemd_preun %{snappy_svcs}
258 # Remove all Snappy content if snapd is being fully uninstalled
259 if [ $1 -eq 0 ]; then
260 %{_libexecdir}/snapd/snap-mgmt purge || :
270 %selinux_modules_install %{_datadir}/selinux/packages/snappy.pp.bz2
271 %selinux_relabel_post
274 %selinux_modules_uninstall snappy
275 if [ $1 -eq 0 ]; then
276 %selinux_relabel_post
280 %defattr(644,root,root,755)
281 %doc README.md docs/*
282 %attr(755,root,root) %{_bindir}/snap
283 %attr(755,root,root) %{_bindir}/snapctl
285 %dir %{_libexecdir}/snapd
286 %attr(755,root,root) %{_libexecdir}/snapd/info
287 %attr(6755,root,root) %{_libexecdir}/snapd/snap-confine
288 %attr(755,root,root) %{_libexecdir}/snapd/snapd
289 %attr(755,root,root) %{_libexecdir}/snapd/snapd.core-fixup.sh
290 %attr(755,root,root) %{_libexecdir}/snapd/snap-device-helper
291 %attr(755,root,root) %{_libexecdir}/snapd/snap-discard-ns
292 %attr(755,root,root) %{_libexecdir}/snapd/snapd.run-from-snap
293 %attr(755,root,root) %{_libexecdir}/snapd/snap-exec
294 %attr(755,root,root) %{_libexecdir}/snapd/snap-failure
295 %attr(755,root,root) %{_libexecdir}/snapd/snap-gdb-shim
296 %attr(755,root,root) %{_libexecdir}/snapd/snap-mgmt
297 %attr(755,root,root) %{_libexecdir}/snapd/snap-seccomp
298 %attr(755,root,root) %{_libexecdir}/snapd/snap-update-ns
299 %attr(755,root,root) %{_libexecdir}/snapd/system-shutdown
300 %{_mandir}/man1/snap.1*
301 /etc/profile.d/snapd.sh
302 %attr(755,root,root) /usr/lib/systemd/system-environment-generators/snapd-env-generator
303 %attr(755,root,root) %{systemdunitdir}-generators/snapd-generator
304 %{systemdunitdir}/snapd.apparmor.service
305 %{systemdunitdir}/snapd.core-fixup.service
306 %{systemdunitdir}/snapd.failure.service
307 %{systemdunitdir}/snapd.seeded.service
308 %{systemdunitdir}/snapd.snap-repair.service
309 %{systemdunitdir}/snapd.snap-repair.timer
310 %{systemdunitdir}/snapd.socket
311 %{systemdunitdir}/snapd.service
312 %{systemdunitdir}/snapd.autoimport.service
313 %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/snapd
314 %dir %{_sharedstatedir}/snapd
315 %dir %{_sharedstatedir}/snapd/assertions
316 %dir %{_sharedstatedir}/snapd/desktop
317 %dir %{_sharedstatedir}/snapd/desktop/applications
318 %dir %{_sharedstatedir}/snapd/device
319 %dir %{_sharedstatedir}/snapd/hostfs
320 %dir %{_sharedstatedir}/snapd/mount
321 %dir %{_sharedstatedir}/snapd/seccomp
322 %dir %{_sharedstatedir}/snapd/seccomp/profiles
323 %dir %{_sharedstatedir}/snapd/snaps
324 %dir %{_sharedstatedir}/snapd/snap
325 %ghost %dir %{_sharedstatedir}/snapd/snap/bin
326 %dir %{_localstatedir}/snap
327 %ghost %{_sharedstatedir}/snapd/state.json
328 %{_mandir}/man8/snapd-env-generator.8*
329 %{_mandir}/man8/snap-confine.8*
330 %{_mandir}/man8/snap-discard-ns.8*
331 %attr(0000,root,root) %{_sharedstatedir}/snapd/void
335 %defattr(644,root,root,755)
336 %doc data/selinux/COPYING
337 %doc data/selinux/README.md
338 %{_datadir}/selinux/packages/snappy.pp.bz2
339 %{_datadir}/selinux/devel/include/contrib/snappy.if
342 %files -n bash-completion-%{name}
343 %defattr(644,root,root,755)