Package: debhelper
Version: 13.3.3
Tags: patch
User: debian-d...@lists.debian.org
Usertags: dpkg-root-support

We're working on a way to install packages into a chroot without
actually using the chroot system call. A consequence of doing so is that
maintainer scripts are run outside the chroot and are supposed to still
operate on the chroot whose location is communicated via the DPKG_ROOT
environment variable.

debhelper generates parts of maintainer scripts related to (re)starting
services. When run in this setting, maintainer scripts would usually
detect the presence of the outer supervisor and would proceed to
(re)starting services outside the chroot to be operated on. Doing so
would be bad.

When we operate on a chroot without being able to chroot into it, it
seems like a pretty safe assumption that no services will be running
inside. Thus we can skip all those snippets in the setting described. An
easy test for the setting is a non-empty DPKG_ROOT environment variable.

Please refer to https://wiki.debian.org/Teams/Dpkg/Spec/InstallBootstrap
for more information.

Please consider applying the attached patch (post bullseye).

Helmut
diff --minimal -Nru 
debhelper-13.3.3/autoscripts/postinst-systemd-restartnostart 
debhelper-13.3.3+nmu1/autoscripts/postinst-systemd-restartnostart
--- debhelper-13.3.3/autoscripts/postinst-systemd-restartnostart        
2020-07-17 18:52:19.000000000 +0200
+++ debhelper-13.3.3+nmu1/autoscripts/postinst-systemd-restartnostart   
2021-02-26 11:25:46.000000000 +0100
@@ -1,5 +1,5 @@
 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = 
"abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
-       if [ -d /run/systemd/system ]; then
+       if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
                systemctl --system daemon-reload >/dev/null || true
                if [ -n "$2" ]; then
                        deb-systemd-invoke #RESTART_ACTION# #UNITFILES# 
>/dev/null || true
diff --minimal -Nru debhelper-13.3.3/autoscripts/postinst-systemd-start 
debhelper-13.3.3+nmu1/autoscripts/postinst-systemd-start
--- debhelper-13.3.3/autoscripts/postinst-systemd-start 2020-07-17 
18:52:19.000000000 +0200
+++ debhelper-13.3.3+nmu1/autoscripts/postinst-systemd-start    2021-02-26 
11:26:02.000000000 +0100
@@ -1,5 +1,5 @@
 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = 
"abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
-       if [ -d /run/systemd/system ]; then
+       if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
                systemctl --system daemon-reload >/dev/null || true
                deb-systemd-invoke start #UNITFILES# >/dev/null || true
        fi
diff --minimal -Nru debhelper-13.3.3/autoscripts/prerm-systemd 
debhelper-13.3.3+nmu1/autoscripts/prerm-systemd
--- debhelper-13.3.3/autoscripts/prerm-systemd  2020-07-17 18:52:19.000000000 
+0200
+++ debhelper-13.3.3+nmu1/autoscripts/prerm-systemd     2021-02-26 
11:26:17.000000000 +0100
@@ -1,3 +1,3 @@
-if [ -d /run/systemd/system ]; then
+if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ]; then
        deb-systemd-invoke stop #UNITFILES# >/dev/null || true
 fi
diff --minimal -Nru debhelper-13.3.3/autoscripts/prerm-systemd-restart 
debhelper-13.3.3+nmu1/autoscripts/prerm-systemd-restart
--- debhelper-13.3.3/autoscripts/prerm-systemd-restart  2020-07-17 
18:52:19.000000000 +0200
+++ debhelper-13.3.3+nmu1/autoscripts/prerm-systemd-restart     2021-02-26 
11:26:33.000000000 +0100
@@ -1,3 +1,3 @@
-if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
+if [ -z "${DPKG_ROOT:-}" ] && [ -d /run/systemd/system ] && [ "$1" = remove ]; 
then
        deb-systemd-invoke stop #UNITFILES# >/dev/null || true
 fi
diff --minimal -Nru debhelper-13.3.3/debian/changelog 
debhelper-13.3.3+nmu1/debian/changelog
--- debhelper-13.3.3/debian/changelog   2021-02-03 20:43:32.000000000 +0100
+++ debhelper-13.3.3+nmu1/debian/changelog      2021-02-26 11:26:34.000000000 
+0100
@@ -1,3 +1,10 @@
+debhelper (13.3.3+nmu1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Support DPKG_ROOT in autoscripts. (Closes: #-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Fri, 26 Feb 2021 11:26:34 +0100
+
 debhelper (13.3.3) unstable; urgency=medium
 
   [ Niels Thykier ]

Reply via email to