Whamcloud - gitweb
debian: use debhelper compat level 11 with a fallback to compat level 9
authorTheodore Ts'o <tytso@mit.edu>
Sun, 12 Aug 2018 04:30:07 +0000 (00:30 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 12 Aug 2018 04:30:07 +0000 (00:30 -0400)
The dh_installsystemd command is only available with Debhelper v11 and
higher.  So explicitly declare that we need debhelper 11, and create a
fallback for debhelper compat level 9 (so we can easily backport to
Debian Stretch and Ubuntu 16.04).

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian/compat
debian/e2fsprogs.postinst.dh9 [new file with mode: 0644]
debian/e2fsprogs.postrm.dh9 [new file with mode: 0644]
debian/rules

index ec63514..b4de394 100644 (file)
@@ -1 +1 @@
-9
+11
diff --git a/debian/e2fsprogs.postinst.dh9 b/debian/e2fsprogs.postinst.dh9
new file mode 100644 (file)
index 0000000..e7acb0e
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# Abort on error.
+set -e
+
+if [ -x /usr/sbin/update-initramfs -a \
+       -e /etc/initramfs-tools/initramfs.conf ]; then
+    update-initramfs -u
+fi
+
+#DEBHELPER#
+
+# debhelper doesn't know what timers are...
+update_svc() {
+       deb-systemd-helper unmask "$1" >/dev/null || true
+
+       if deb-systemd-helper --quiet was-enabled "$1"; then
+               deb-systemd-helper enable "$1" >/dev/null || true
+       else
+               deb-systemd-helper update-state "$1" >/dev/null || true
+       fi
+}
+update_svc e2scrub_all.timer
+update_svc e2scrub_reap.service
+
+# Start our new services
+if [ -d /run/systemd/system ]; then
+       systemctl --system daemon-reload >/dev/null || true
+       deb-systemd-invoke start e2scrub_all.timer >/dev/null || true
+fi
+
+exit 0
diff --git a/debian/e2fsprogs.postrm.dh9 b/debian/e2fsprogs.postrm.dh9
new file mode 100644 (file)
index 0000000..32cb642
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+update_svc() {
+       deb-systemd-helper mask "$1" >/dev/null || true
+
+       if deb-systemd-helper --quiet was-enabled "$1"; then
+               # Enables the unit on first installation, creates new
+               # symlinks on upgrades if the unit file has changed.
+               deb-systemd-helper disable "$1" >/dev/null || true
+       fi
+}
+
+if [ "$1" != "upgrade" ]; then
+       # Abort on error.
+       set -e
+
+       if [ -x /usr/sbin/update-initramfs -a \
+               -e /etc/initramfs-tools/initramfs.conf ]; then
+           update-initramfs -u
+       fi
+
+       #DEBHELPER#
+
+       # debhelper doesn't know what timers are...
+       update_svc e2scrub_all.timer
+       update_svc e2scrub_reap.service
+
+       # Start our new services
+       if [ -d /run/systemd/system ]; then
+               deb-systemd-invoke stop e2scrub_all.timer >/dev/null || true
+       fi
+fi
+
+exit 0
+
index 9167a40..586a34c 100755 (executable)
@@ -47,6 +47,8 @@ endif
 
 DH_VERSION := $(shell dpkg-query -W -f '$${Version}' debhelper)
 
+USE_DH9 ?= $(shell if dpkg --compare-versions $(DH_VERSION) lt 11 ; then echo yes ; fi)
+
 # USE_DBGSYM :=
 USE_DBGSYM ?= $(shell if dpkg --compare-versions $(DH_VERSION) ">=" 9.20160114 ; then echo yes ; fi)
 
@@ -99,6 +101,7 @@ UDEB_NAME    ?= $(package)-udeb_$(MAIN_VERSION)_$(DEB_HOST_ARCH).udeb
 UDEB_PRIORITY  ?= $(shell grep '^Package: e2fsprogs-udeb' debian/control -A 10 | grep ^Priority: | cut -d ' ' -f 2)
 
 STAMPSDIR      ?= debian/stampdir
+CFGDH          ?= ${STAMPSDIR}/configure-dh
 CFGSTDSTAMP    ?= ${STAMPSDIR}/configure-std-stamp
 CFGBFSTAMP     ?= ${STAMPSDIR}/configure-bf-stamp
 BUILDSTDSTAMP  ?= ${STAMPSDIR}/build-std-stamp
@@ -196,7 +199,18 @@ mrproper: clean
                mv debian/control.save debian/control ; \
        fi
 
-${CFGSTDSTAMP}:
+${CFGDH}:
+ifeq ($(USE_DH9),yes)
+       mv debian/compat debian/compat.save
+       echo 9 > debian/compat
+       mv debian/e2fsprogs.postinst debian/e2fsprogs.postinst.save
+       cp debian/e2fsprogs.postinst.dh9 debian/e2fsprogs.postinst
+       cp debian/e2fsprogs.postrm.dh9 debian/e2fsprogs.postrm
+endif
+       mkdir -p ${STAMPSDIR}
+       touch ${CFGDH}
+
+${CFGSTDSTAMP}: ${CFGDH}
        dh_testdir
        if which dh_update_autotools_config > /dev/null 2>&1 ; then \
                dh_update_autotools_config ;\
@@ -229,7 +243,7 @@ endif
        mkdir -p ${STAMPSDIR}
        touch ${CFGSTDSTAMP}
 
-${CFGBFSTAMP}:
+${CFGBFSTAMP}: ${CFGDH}
        dh_testdir
        if which dh_update_autotools_config > /dev/null 2>&1 ; then \
                dh_update_autotools_config ;\
@@ -299,6 +313,15 @@ clean:
                mv debian/orig-gmo/* po ; \
                rmdir debian/orig-gmo ; \
        fi
+       if test -f debian/compat.save; then \
+               mv debian/compat.save debian/compat ; \
+       fi
+       if test -f debian/e2fsprogs.postinst.save; then \
+               mv debian/e2fsprogs.postinst.save debian/e2fsprogs.postinst ; \
+       fi
+       if test -f debian/e2fsprogs.postrm; then \
+               rm -f debian/e2fsprogs.postrm ; \
+       fi
        rm -rf ${STAMPSDIR}
        [ ! -f ${stdbuilddir}/Makefile ] || $(MAKE) -C ${stdbuilddir} V=1 distclean
        [ ! -f ${bfbuilddir}/Makefile ] || $(MAKE) -C ${bfbuilddir} V=1 distclean
@@ -437,8 +460,9 @@ endif
        dh_compress -a
 
        dh_makeshlibs -a --add-udeb=e2fsprogs-udeb
+ifneq ($(USE_DH9),yes)
        dh_installsystemd -p e2fsprogs
-
+endif
        $(INSTALL) -D -p -m644 debian/e2fsprogs-udeb.lintian-overrides \
            debian/e2fsprogs-udeb/usr/share/lintian/overrides/e2fsprogs-udeb
        dh_installdeb -a