[debhelper-devel] [debhelper] 01/01: autoscripts: Improve rollback handling

Niels Thykier nthykier at moszumanska.debian.org
Sun Jan 14 10:00:27 UTC 2018


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit f0da234984b28bbaea297c643cfaa6714f0c4a79
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jan 14 09:57:47 2018 +0000

    autoscripts: Improve rollback handling
    
    On failed upgrades, dpkg can potentially roll back to the existing
    version of a package.  Improve the scripts to handle this case better.
    In particularly, ensure that the "postinst" snippets are also run on
    an "abort-upgrade".
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 autoscripts/postinst-emacsen                |  7 ++++---
 autoscripts/postinst-modules                |  2 +-
 autoscripts/postinst-systemd-dont-enable    | 22 ++++++++++++----------
 autoscripts/postinst-systemd-enable         | 24 +++++++++++++-----------
 autoscripts/postinst-systemd-restart        | 16 +++++++++-------
 autoscripts/postinst-systemd-restartnostart | 10 ++++++----
 autoscripts/postinst-systemd-start          |  8 +++++---
 autoscripts/postinst-ucf                    |  2 +-
 autoscripts/postinst-usrlocal               |  2 +-
 autoscripts/postinst-wm                     |  2 +-
 autoscripts/postinst-wm-noman               |  2 +-
 debian/changelog                            |  8 ++++++++
 12 files changed, 62 insertions(+), 43 deletions(-)

diff --git a/autoscripts/postinst-emacsen b/autoscripts/postinst-emacsen
index 82ce957..f6e92f6 100644
--- a/autoscripts/postinst-emacsen
+++ b/autoscripts/postinst-emacsen
@@ -1,4 +1,5 @@
-if [ "$1" = "configure" ] && [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a -x /usr/lib/emacsen-common/emacs-package-install ]
-then
-	/usr/lib/emacsen-common/emacs-package-install --postinst #PACKAGE#
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] ; then
+	if [ -e /var/lib/emacsen-common/state/package/installed/emacsen-common -a -x /usr/lib/emacsen-common/emacs-package-install ] ; then
+		/usr/lib/emacsen-common/emacs-package-install --postinst #PACKAGE#
+	fi
 fi
diff --git a/autoscripts/postinst-modules b/autoscripts/postinst-modules
index f17dc2d..0b93045 100644
--- a/autoscripts/postinst-modules
+++ b/autoscripts/postinst-modules
@@ -1,4 +1,4 @@
-if [ "$1" = "configure" ]; then
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] ; then
 	if [ -e /boot/System.map-#KVERS# ]; then
 		depmod -a -F /boot/System.map-#KVERS# #KVERS# || true
 	fi
diff --git a/autoscripts/postinst-systemd-dont-enable b/autoscripts/postinst-systemd-dont-enable
index 2dd86a1..f88901e 100644
--- a/autoscripts/postinst-systemd-dont-enable
+++ b/autoscripts/postinst-systemd-dont-enable
@@ -1,13 +1,15 @@
-if deb-systemd-helper debian-installed #UNITFILE#; then
-	# This will only remove masks created by d-s-h on package removal.
-	deb-systemd-helper unmask #UNITFILE# >/dev/null || true
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+	if deb-systemd-helper debian-installed #UNITFILE#; then
+		# This will only remove masks created by d-s-h on package removal.
+		deb-systemd-helper unmask #UNITFILE# >/dev/null || true
 
-	if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
-		# Create new symlinks, if any.
-		deb-systemd-helper enable #UNITFILE# >/dev/null || true
+		if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
+			# Create new symlinks, if any.
+			deb-systemd-helper enable #UNITFILE# >/dev/null || true
+		fi
 	fi
-fi
 
-# Update the statefile to add new symlinks (if any), which need to be cleaned
-# up on purge. Also remove old symlinks.
-deb-systemd-helper update-state #UNITFILE# >/dev/null || true
+	# Update the statefile to add new symlinks (if any), which need to be cleaned
+	# up on purge. Also remove old symlinks.
+	deb-systemd-helper update-state #UNITFILE# >/dev/null || true
+fi
diff --git a/autoscripts/postinst-systemd-enable b/autoscripts/postinst-systemd-enable
index b903038..4900fb8 100644
--- a/autoscripts/postinst-systemd-enable
+++ b/autoscripts/postinst-systemd-enable
@@ -1,13 +1,15 @@
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask #UNITFILE# >/dev/null || true
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+	# This will only remove masks created by d-s-h on package removal.
+	deb-systemd-helper unmask #UNITFILE# >/dev/null || true
 
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
-	# Enables the unit on first installation, creates new
-	# symlinks on upgrades if the unit file has changed.
-	deb-systemd-helper enable #UNITFILE# >/dev/null || true
-else
-	# Update the statefile to add new symlinks (if any), which need to be
-	# cleaned up on purge. Also remove old symlinks.
-	deb-systemd-helper update-state #UNITFILE# >/dev/null || true
+	# was-enabled defaults to true, so new installations run enable.
+	if deb-systemd-helper --quiet was-enabled #UNITFILE#; then
+		# Enables the unit on first installation, creates new
+		# symlinks on upgrades if the unit file has changed.
+		deb-systemd-helper enable #UNITFILE# >/dev/null || true
+	else
+		# Update the statefile to add new symlinks (if any), which need to be
+		# cleaned up on purge. Also remove old symlinks.
+		deb-systemd-helper update-state #UNITFILE# >/dev/null || true
+	fi
 fi
diff --git a/autoscripts/postinst-systemd-restart b/autoscripts/postinst-systemd-restart
index 7d5b0da..bf8c7d9 100644
--- a/autoscripts/postinst-systemd-restart
+++ b/autoscripts/postinst-systemd-restart
@@ -1,9 +1,11 @@
-if [ -d /run/systemd/system ]; then
-	systemctl --system daemon-reload >/dev/null || true
-	if [ -n "$2" ]; then
-		_dh_action=restart
-	else
-		_dh_action=start
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+		if [ -d /run/systemd/system ]; then
+		systemctl --system daemon-reload >/dev/null || true
+		if [ -n "$2" ]; then
+			_dh_action=restart
+		else
+			_dh_action=start
+		fi
+		deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true
 	fi
-	deb-systemd-invoke $_dh_action #UNITFILES# >/dev/null || true
 fi
diff --git a/autoscripts/postinst-systemd-restartnostart b/autoscripts/postinst-systemd-restartnostart
index eb52e27..d41ef52 100644
--- a/autoscripts/postinst-systemd-restartnostart
+++ b/autoscripts/postinst-systemd-restartnostart
@@ -1,6 +1,8 @@
-if [ -d /run/systemd/system ]; then
-	systemctl --system daemon-reload >/dev/null || true
-	if [ -n "$2" ]; then
-		deb-systemd-invoke try-restart #UNITFILES# >/dev/null || true
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+	if [ -d /run/systemd/system ]; then
+		systemctl --system daemon-reload >/dev/null || true
+		if [ -n "$2" ]; then
+			deb-systemd-invoke try-restart #UNITFILES# >/dev/null || true
+		fi
 	fi
 fi
diff --git a/autoscripts/postinst-systemd-start b/autoscripts/postinst-systemd-start
index 8134a04..ffc7216 100644
--- a/autoscripts/postinst-systemd-start
+++ b/autoscripts/postinst-systemd-start
@@ -1,4 +1,6 @@
-if [ -d /run/systemd/system ]; then
-	systemctl --system daemon-reload >/dev/null || true
-	deb-systemd-invoke start #UNITFILES# >/dev/null || true
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] ; then
+	if [ -d /run/systemd/system ]; then
+		systemctl --system daemon-reload >/dev/null || true
+		deb-systemd-invoke start #UNITFILES# >/dev/null || true
+	fi
 fi
diff --git a/autoscripts/postinst-ucf b/autoscripts/postinst-ucf
index 0546831..7445e94 100644
--- a/autoscripts/postinst-ucf
+++ b/autoscripts/postinst-ucf
@@ -1,4 +1,4 @@
-if [ "$1" = "configure" ]; then
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
 	ucf "#UCFSRC#" "#UCFDEST#"
 	ucfr #PACKAGE# "#UCFDEST#"
 fi
diff --git a/autoscripts/postinst-usrlocal b/autoscripts/postinst-usrlocal
index a2f004d..6c65e24 100644
--- a/autoscripts/postinst-usrlocal
+++ b/autoscripts/postinst-usrlocal
@@ -1,4 +1,4 @@
-if [ "$1" = configure ]; then
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
 (
 	while read line; do
 		set -- $line
diff --git a/autoscripts/postinst-wm b/autoscripts/postinst-wm
index ee63628..7fa6aa2 100644
--- a/autoscripts/postinst-wm
+++ b/autoscripts/postinst-wm
@@ -1,4 +1,4 @@
-if [ "$1" = "configure" ]; then
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
 	update-alternatives --install /usr/bin/x-window-manager \
 		x-window-manager #WM# #PRIORITY# \
 		--slave /usr/share/man/man1/x-window-manager.1.gz \
diff --git a/autoscripts/postinst-wm-noman b/autoscripts/postinst-wm-noman
index aef412a..3c26ea4 100644
--- a/autoscripts/postinst-wm-noman
+++ b/autoscripts/postinst-wm-noman
@@ -1,4 +1,4 @@
-if [ "$1" = "configure" ]; then
+if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
 	update-alternatives --install /usr/bin/x-window-manager \
 		x-window-manager #WM# #PRIORITY#
 fi
diff --git a/debian/changelog b/debian/changelog
index 84ebcf3..fe6ac57 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+debhelper (11.1.3) UNRELEASED; urgency=medium
+
+  * autoscripts/*: Improve rollback handling of many scripts.
+    Notably a lot of scripts failed to rerun the postinst parts
+    on an "abort-upgrade".  (Closes: #446856)
+
+ -- Niels Thykier <niels at thykier.net>  Sun, 14 Jan 2018 09:54:57 +0000
+
 debhelper (11.1.2) unstable; urgency=medium
 
   * dh: Fix non-sense error about a missing "startpoint object

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list