Re: about dh_installsystemd...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This should provide the necessary backwards compatibility for Ubuntu
16.04 and Debian Stretch.  (BTW, if someone wants an updated
e2fsprogs.spec.in file for Red Hat/Fedora systems, that would be
great.  I haven't tested that built-in e2fsprogs.spec file in a long
time, so it's probably way out of date, and it certainly has no
support for e2scrub.)

						- Ted

commit 4cf064e051a5668e2e505c37d173141055e270ba
Author: Theodore Ts'o <tytso@xxxxxxx>
Date:   Sun Aug 12 00:30:07 2018 -0400

    debian: use debhelper compat level 11 with a fallback to compat level 9
    
    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@xxxxxxx>

diff --git a/debian/compat b/debian/compat
index ec635144f..b4de39476 100644
--- a/debian/compat
+++ b/debian/compat
@@ -1 +1 @@
-9
+11
diff --git a/debian/e2fsprogs.postinst.dh9 b/debian/e2fsprogs.postinst.dh9
new file mode 100644
index 000000000..e7acb0ea2
--- /dev/null
+++ b/debian/e2fsprogs.postinst.dh9
@@ -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
index 000000000..32cb64266
--- /dev/null
+++ b/debian/e2fsprogs.postrm.dh9
@@ -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
+
diff --git a/debian/rules b/debian/rules
index 9167a40fc..586a34cbf 100755
--- a/debian/rules
+++ b/debian/rules
@@ -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



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux