1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: LOLi <loli10K@users.noreply.github.com>
3 Date: Fri, 2 Feb 2018 22:50:42 +0100
4 Subject: [PATCH] Fix systemd_ RPM macros usage on Debian-based distributions
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 Debian-based distributions do not seem to provide RPM macros for
10 dealing with systemd pre- and post- (un)install actions: this results
11 in errors when installing or upgrading .deb packages because the
12 resulting control scripts contain the following unresolved macros:
18 Fix this by providing default values for postinstall, preuninstall and
19 postuninstall scripts when these macros are not defined.
21 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
22 Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
23 Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
26 (cherry picked from commit 29b79dcfe90a67a919c2f42fbaa2e557ea484bd5)
27 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
29 rpm/generic/zfs.spec.in | 21 ++++++++++++++++++++-
30 1 file changed, 20 insertions(+), 1 deletion(-)
32 diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
33 index 4a911b4c2..ce028794c 100644
34 --- a/rpm/generic/zfs.spec.in
35 +++ b/rpm/generic/zfs.spec.in
36 @@ -245,8 +245,15 @@ find %{?buildroot}%{_libdir} -name '*.la' -exec rm -f {} \;
40 +%if 0%{?systemd_post:1}
41 %systemd_post %{systemd_svcs}
43 +if [ "$1" = "1" -o "$1" = "install" ] ; then
44 + # Initial installation
45 + systemctl preset %{systemd_svcs} >/dev/null || true
49 if [ -x /sbin/chkconfig ]; then
50 /sbin/chkconfig --add zfs-import
51 /sbin/chkconfig --add zfs-mount
52 @@ -258,9 +265,17 @@ exit 0
56 +%if 0%{?systemd_preun:1}
57 %systemd_preun %{systemd_svcs}
59 -if [ "$1" = "0" ] && [ -x /sbin/chkconfig ]; then
60 +if [ "$1" = "0" -o "$1" = "remove" ] ; then
61 + # Package removal, not upgrade
62 + systemctl --no-reload disable %{systemd_svcs} >/dev/null || true
63 + systemctl stop %{systemd_svcs} >/dev/null || true
67 +if [ "$1" = "0" -o "$1" = "remove" ] && [ -x /sbin/chkconfig ]; then
68 /sbin/chkconfig --del zfs-import
69 /sbin/chkconfig --del zfs-mount
70 /sbin/chkconfig --del zfs-share
71 @@ -271,7 +286,11 @@ exit 0
75 +%if 0%{?systemd_postun:1}
76 %systemd_postun %{systemd_svcs}
78 +systemctl --system daemon-reload >/dev/null || true