aboutsummaryrefslogtreecommitdiffstats
path: root/rpm/generic
diff options
context:
space:
mode:
authorLOLi <[email protected]>2018-02-02 22:50:42 +0100
committerBrian Behlendorf <[email protected]>2018-02-02 13:50:42 -0800
commitfbd42542686af053f0d162ec4630ffd4fff1cc30 (patch)
treea3ada75c16128038832ffa4b1afcc4b6564af8b6 /rpm/generic
parent1b66810bad0a893031c6d49613aa83dc359bf034 (diff)
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
Diffstat (limited to 'rpm/generic')
-rw-r--r--rpm/generic/zfs.spec.in21
1 files changed, 20 insertions, 1 deletions
diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
index faa73e3b7..27a2424df 100644
--- a/rpm/generic/zfs.spec.in
+++ b/rpm/generic/zfs.spec.in
@@ -266,8 +266,15 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
%post
%if 0%{?_systemd}
+%if 0%{?systemd_post:1}
%systemd_post %{systemd_svcs}
%else
+if [ "$1" = "1" -o "$1" = "install" ] ; then
+ # Initial installation
+ systemctl preset %{systemd_svcs} >/dev/null || true
+fi
+%endif
+%else
if [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --add zfs-import
/sbin/chkconfig --add zfs-mount
@@ -279,9 +286,17 @@ exit 0
%preun
%if 0%{?_systemd}
+%if 0%{?systemd_preun:1}
%systemd_preun %{systemd_svcs}
%else
-if [ "$1" = "0" ] && [ -x /sbin/chkconfig ]; then
+if [ "$1" = "0" -o "$1" = "remove" ] ; then
+ # Package removal, not upgrade
+ systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
+ systemctl stop %{systemd_svcs} >/dev/null || true
+fi
+%endif
+%else
+if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
/sbin/chkconfig --del zfs-import
/sbin/chkconfig --del zfs-mount
/sbin/chkconfig --del zfs-share
@@ -292,7 +307,11 @@ exit 0
%postun
%if 0%{?_systemd}
+%if 0%{?systemd_postun:1}
%systemd_postun %{systemd_svcs}
+%else
+systemctl --system daemon-reload >/dev/null || true
+%endif
%endif
%files