Bug#1142015: Please consider adding support for $DPKG_ROOT to support creating bootable Hurd systems on Linux

Johannes Schauer Marin Rodrigues josch at debian.org
Mon Jul 13 21:56:38 BST 2026


Source: orphan-sysvinit-scripts
Version: 0.23
Severity: wishlist
Tags: patch

Hi,

to create a Debian GNU/Hurd chroot from Debian GNU/Linux, so called
"chrootless" or --force-script-chrootless (the dpkg option) has to be
used because Hurd binaries cannot be run on Linux. Since systemd cannot
work on GNU/Hurd, sysvinit is the default init system there. To use
sysvinit effectively, the package orphan-sysvinit-scripts is a desirable
installation candidate.

Installing orphan-sysvinit-scripts with --force-script-chrootless
currently fails because its postinst maintainer script does not respect
the $DPKG_ROOT environment variable. The patch at the end of this email
fixes this. I also opened a MR on salsa for your convenience:
https://salsa.debian.org/matthew/orphan-sysvinit-scripts/-/merge_requests/3/diffs

The changes have been verified to have the desired results in the salsa
CI pipeline of dpkg-root-demo:
https://salsa.debian.org/helmutg/dpkg-root-demo/-/pipelines

Thanks!

cheers, josch

>From 7195e5ee15e77fd720bf176aca2205a2bd97e851 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch at debian.org>
Date: Mon, 29 Jun 2026 02:31:44 +0200
Subject: [PATCH] Add DPKG_ROOT support

---
 debian/postinst      |  2 +-
 lib/update_init_d.sh | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/debian/postinst b/debian/postinst
index 4c11f09..13a306f 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -4,7 +4,7 @@ set -e
 
 case "$1" in
     configure|triggered)
-	/usr/lib/orphan-sysvinit-scripts/update_init_d.sh
+	"$DPKG_ROOT/usr/lib/orphan-sysvinit-scripts/update_init_d.sh"
 
 	;;
 esac
diff --git a/lib/update_init_d.sh b/lib/update_init_d.sh
index b435808..11074e4 100755
--- a/lib/update_init_d.sh
+++ b/lib/update_init_d.sh
@@ -25,7 +25,7 @@ while read -r systemd sysv rcd rest ; do
 	echo "Unable to parse line: $systemd $sysv $rcd $rest"
 	exit 1
     fi
-    if [ -e "/lib/systemd/system/$systemd" ] && [ "$action" = "add" ]; then
+    if [ -e "$DPKG_ROOT/lib/systemd/system/$systemd" ] && [ "$action" = "add" ]; then
 	if dpkg-query -S "/etc/init.d/$sysv" >/dev/null 2>&1 ; then
 	    # This file still belongs to an installed package
 	    # so do nothing for now
@@ -34,19 +34,19 @@ while read -r systemd sysv rcd rest ; do
 	ucf "/usr/share/orphan-sysvinit-scripts/$sysv" "/etc/init.d/$sysv"
 	ucfr orphan-sysvinit-scripts "/etc/init.d/$sysv"
 	update-rc.d "$sysv" "${rcd:-defaults}" >/dev/null
-    elif [ -e "/etc/init.d/$sysv" ] && [ "$action" = "purge" ]; then
+    elif [ -e "$DPKG_ROOT/etc/init.d/$sysv" ] && [ "$action" = "purge" ]; then
 	#Only remove scripts if we are reasonably sure we have previously
 	#registered them with ucf (to minimise user surprise)
 	if which ucfq >/dev/null; then
 	    if ucfq "/etc/init.d/$sysv" | grep -q orphan-sysvinit-scripts ; then
 		for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist; do
-		    rm -f "/etc/init.d/${sysv}.$ext"
+		    rm -f "$DPKG_ROOT/etc/init.d/${sysv}.$ext"
 		done
-		rm -f "/etc/init.d/$sysv"
+		rm -f "$DPKG_ROOT/etc/init.d/$sysv"
 		ucf --purge "/etc/init.d/$sysv"
 		ucfr --purge orphan-sysvinit-scripts "/etc/init.d/$sysv"
 		update-rc.d "$sysv" remove >/dev/null
 	    fi
 	fi
     fi
-done < /usr/lib/orphan-sysvinit-scripts/mapping
+done < "$DPKG_ROOT/usr/lib/orphan-sysvinit-scripts/mapping"
-- 
GitLab



More information about the Debian-init-diversity mailing list