]> git.pld-linux.org Git - SPECS.git/blob - snapd.spec
SPECS updated Wed 28 Jul 14:48:01 CEST 2021
[SPECS.git] / snapd.spec
1 #
2 # Conditional build:
3 %bcond_with     tests           # build with tests
4 %bcond_with     selinux         # selinux
5
6 Summary:        A transactional software package manager
7 Name:           snapd
8 Version:        2.42.5
9 Release:        1
10 License:        GPL v3
11 Group:          Base
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
15 Source1:        snap-mgmt.sh
16 Source2:        profile.d.sh
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
23 BuildRequires:  gcc
24 BuildRequires:  gettext
25 BuildRequires:  glib2-devel
26 BuildRequires:  glibc-static
27 BuildRequires:  gnupg
28 BuildRequires:  golang
29 BuildRequires:  indent
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
40 BuildRequires:  xz
41 Requires:       pld-release
42 Requires:       squashfs
43 Obsoletes:      snap-confine
44 ExclusiveArch:  %{ix86} %{x8664} %{arm} aarch64 ppc64le s390x
45 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
46
47 %define         _udevrulesdir /lib/udev/rules.d
48
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
53
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
55
56 %description
57 Snappy is a modern, cross-distribution, transactional package manager
58 designed for working with self-contained, immutable packages.
59
60 %package selinux
61 Summary:        SELinux module for snapd
62 License:        GPL v2+
63 Group:          Base
64 %if %{with selinux}
65 BuildRequires:  selinux-policy
66 BuildRequires:  selinux-policy-devel
67 %endif
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
73 BuildArch:      noarch
74
75 %description selinux
76 This package provides the SELinux policy module to ensure snapd runs
77 properly under an environment with SELinux enabled.
78
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
84 BuildArch:      noarch
85
86 %description -n bash-completion-%{name}
87 bash-completion for %{name}.
88
89 %prep
90 %setup -q
91 %patch0 -p1
92
93 # Generate version files
94 ./mkversion.sh "%{version}-%{release}"
95
96 # Build snapd
97 mkdir -p src/github.com/snapcore
98 ln -s ../../../ src/github.com/snapcore/snapd
99
100 %build
101 export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath}
102
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
108
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
114
115 # back to normal
116 LDFLAGS="%{rpmldflags}"
117
118 %if %{with selinux}
119 cd data/selinux
120 %{__make} SHARE="%{_datadir}" TARGETS="snappy"
121 cd -
122 %endif
123
124 # Build snap-confine
125 cd cmd
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!)
129 %configure \
130         --disable-apparmor \
131         --libexecdir=%{_libexecdir}/snapd/ \
132         --with-snap-mount-dir=%{_sharedstatedir}/snapd/snap \
133         --without-merged-usr
134
135 %{__make} \
136         BINDIR="%{_bindir}" \
137         LIBEXECDIR="%{_libexecdir}"
138 cd -
139
140 # Build systemd units
141 cd data/systemd
142 %{__make} \
143         BINDIR="%{_bindir}" \
144         LIBEXECDIR="%{_libexecdir}" \
145         SNAP_MOUNT_DIR="%{_sharedstatedir}/snapd/snap" \
146         SNAPD_ENVIRONMENT_FILE="%{_sysconfdir}/sysconfig/snapd"
147
148 %if %{with tests}
149 # snapd tests
150 export GOPATH=$RPM_BUILD_ROOT/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath}
151 %gotest %{import_path}/...
152
153 # snap-confine tests (these always run!)
154 cd cmd
155 %{__make} check
156 cd -
157 %endif
158
159 %install
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
177
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
186
187 %if %{with selinux}
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
192 %endif
193
194 # Install snap(1) man page
195 bin/snap help --man > $RPM_BUILD_ROOT%{_mandir}/man1/snap.1
196
197 # Install the "info" data file with snapd version
198 install -D data/info $RPM_BUILD_ROOT%{_libexecdir}/snapd/info
199
200 # Install bash completion for "snap"
201 install -D data/completion/snap $RPM_BUILD_ROOT%{bash_compdir}/snap
202
203 # Install snap-confine
204 cd cmd
205 %{__make} install \
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
214 cd -
215
216 # Install all systemd units
217 cd data/systemd
218 %{__make} install \
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
223 cd -
224
225 cp -p %{SOURCE2} $RPM_BUILD_ROOT/etc/profile.d/snapd.sh
226 cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/snapd
227
228 # Install snap management script
229 install -pm 0755 %{SOURCE1} $RPM_BUILD_ROOT%{_libexecdir}/snapd/snap-mgmt
230
231 # Create state.json file to be ghosted
232 touch $RPM_BUILD_ROOT%{_sharedstatedir}/snapd/state.json
233
234 # some things are still looked for in the wrong dir
235 ln -s "%{_libexecdir}/snapd" "$RPM_BUILD_ROOT%{_prefix}/lib/snapd"
236
237 %clean
238 rm -rf $RPM_BUILD_ROOT
239
240 %post
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
245 # to be started.
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 || :
249         fi
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 || :
252         fi
253 fi
254
255 %preun
256 %systemd_preun %{snappy_svcs}
257
258 # Remove all Snappy content if snapd is being fully uninstalled
259 if [ $1 -eq 0 ]; then
260         %{_libexecdir}/snapd/snap-mgmt purge || :
261 fi
262
263 %postun
264 %systemd_reload
265
266 %pre selinux
267 %selinux_relabel_pre
268
269 %post selinux
270 %selinux_modules_install %{_datadir}/selinux/packages/snappy.pp.bz2
271 %selinux_relabel_post
272
273 %postun selinux
274 %selinux_modules_uninstall snappy
275 if [ $1 -eq 0 ]; then
276         %selinux_relabel_post
277 fi
278
279 %files
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
284 %{_prefix}/lib/snapd
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
332
333 %if %{with selinux}
334 %files selinux
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
340 %endif
341
342 %files -n bash-completion-%{name}
343 %defattr(644,root,root,755)
344 %{bash_compdir}/snap
This page took 1.069931 seconds and 3 git commands to generate.