summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2018-01-14 09:57:47 +0000
committerNiels Thykier <niels@thykier.net>2018-01-14 09:57:49 +0000
commitf0da234984b28bbaea297c643cfaa6714f0c4a79 (patch)
tree2a328fdf2fe373f60a4375955af8f75d20818e38
parent244954580b0c20dfc9625030dc07bf60c43859c6 (diff)
downloaddebhelper-f0da234984b28bbaea297c643cfaa6714f0c4a79.tar.gz
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@thykier.net>
-rw-r--r--autoscripts/postinst-emacsen7
-rw-r--r--autoscripts/postinst-modules2
-rw-r--r--autoscripts/postinst-systemd-dont-enable22
-rw-r--r--autoscripts/postinst-systemd-enable24
-rw-r--r--autoscripts/postinst-systemd-restart16
-rw-r--r--autoscripts/postinst-systemd-restartnostart10
-rw-r--r--autoscripts/postinst-systemd-start8
-rw-r--r--autoscripts/postinst-ucf2
-rw-r--r--autoscripts/postinst-usrlocal2
-rw-r--r--autoscripts/postinst-wm2
-rw-r--r--autoscripts/postinst-wm-noman2
-rw-r--r--debian/changelog8
12 files changed, 62 insertions, 43 deletions
diff --git a/autoscripts/postinst-emacsen b/autoscripts/postinst-emacsen
index 82ce9576..f6e92f6b 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 f17dc2da..0b930452 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 2dd86a1f..f88901e1 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 b9030380..4900fb8d 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 7d5b0da0..bf8c7d90 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 eb52e273..d41ef528 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 8134a040..ffc72165 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 05468310..7445e942 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 a2f004db..6c65e248 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 ee636287..7fa6aa2e 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 aef412a3..3c26ea48 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 84ebcf30..fe6ac577 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@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