Skip to content

Commit fbd4254

Browse files
loli10Kbehlendorf
authored andcommitted
Fix systemd_ RPM macros usage on Debian-based distributions
Debian-based distributions do not seem to provide RPM macros for dealing with systemd pre- and post- (un)install actions: this results in errors when installing or upgrading .deb packages because the resulting control scripts contain the following unresolved macros: * %systemd_post * %systemd_preun * %systemd_postun Fix this by providing default values for postinstall, preuninstall and postuninstall scripts when these macros are not defined. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7074 Closes #7100
1 parent 1b66810 commit fbd4254

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

rpm/generic/zfs.spec.in

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,15 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
266266

267267
%post
268268
%if 0%{?_systemd}
269+
%if 0%{?systemd_post:1}
269270
%systemd_post %{systemd_svcs}
270271
%else
272+
if [ "$1" = "1" -o "$1" = "install" ] ; then
273+
# Initial installation
274+
systemctl preset %{systemd_svcs} >/dev/null || true
275+
fi
276+
%endif
277+
%else
271278
if [ -x /sbin/chkconfig ]; then
272279
/sbin/chkconfig --add zfs-import
273280
/sbin/chkconfig --add zfs-mount
@@ -279,9 +286,17 @@ exit 0
279286

280287
%preun
281288
%if 0%{?_systemd}
289+
%if 0%{?systemd_preun:1}
282290
%systemd_preun %{systemd_svcs}
283291
%else
284-
if [ "$1" = "0" ] && [ -x /sbin/chkconfig ]; then
292+
if [ "$1" = "0" -o "$1" = "remove" ] ; then
293+
# Package removal, not upgrade
294+
systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
295+
systemctl stop %{systemd_svcs} >/dev/null || true
296+
fi
297+
%endif
298+
%else
299+
if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
285300
/sbin/chkconfig --del zfs-import
286301
/sbin/chkconfig --del zfs-mount
287302
/sbin/chkconfig --del zfs-share
@@ -292,7 +307,11 @@ exit 0
292307

293308
%postun
294309
%if 0%{?_systemd}
310+
%if 0%{?systemd_postun:1}
295311
%systemd_postun %{systemd_svcs}
312+
%else
313+
systemctl --system daemon-reload >/dev/null || true
314+
%endif
296315
%endif
297316

298317
%files

0 commit comments

Comments
 (0)