Source: dash
Severity: normal
Tags: patch
User: [email protected]
Usertags: dpkg-root-support
Hi,
Hi,
since dpkg 1.18.5, dpkg sets the variable DPKG_ROOT when invoking
maintainer scripts. Usually that variable is empty but when calling dpkg
with --root and --force-script-chrootless, dpkg will set DPKG_ROOT to
the new root directory. In that mode, maintainer scripts are called
without chroot(1) around them, and thus have to be able to possibly
operate on the path from DPKG_ROOT instead of working on /. This is
useful for bootstrapping, creating chroots for foreign architectures
where utilities from inside the chroot cannot be executed, avoiding
dependency loops between postinst scripts, installation without
requiring superuser privileges and for creating installations that do
not even contain dpkg. See
https://wiki.debian.org/Teams/Dpkg/Spec/InstallBootstrap for more
information.
We have set up a weekly salsa job that patches 10 source packages plus
dash and then shows how a chroot created with DPKG_ROOT is bit-by-bit
identical to a chroot created the normal way:
https://salsa.debian.org/helmutg/dpkg-root-demo/-/pipelines
The changes needed for dash are twofold:
1. prefixing paths in dash.postinst with DPKG_ROOT (this bug)
2. replacing add-shell with triggers once debianutils >= 5.1-1 migrates
to testing
Since debianutils is currently blocked from migration, this bug is about
the first item.
Please consider applying the attached patch.
Thanks!
cheers, josch
diff -Nru dash-0.5.11+git20200708+dd9ef66/debian/dash.postinst
dash-0.5.11+git20200708+dd9ef66/debian/dash.postinst
--- dash-0.5.11+git20200708+dd9ef66/debian/dash.postinst 2020-12-10
14:23:19.000000000 +0100
+++ dash-0.5.11+git20200708+dd9ef66/debian/dash.postinst 2021-06-17
19:31:47.000000000 +0200
@@ -3,8 +3,8 @@
# $1: dfile, $2: link target, $3: distrib
replace_with_link() {
- dfile=$1; ltarget=$2; distrib=$3
- temp=$dfile.tmp
+ dfile="$DPKG_ROOT$1"; ltarget=$2; distrib="$DPKG_ROOT$3"
+ temp="$dfile.tmp"
# Safely create a symlink to $ltarget at $dfile, first
# making a backup of $dfile (the file being diverted)
# in $distrib (if specified).
@@ -47,8 +47,8 @@
dpkg-divert --package bash --no-rename --remove $dfile
dpkg-divert --package dash --no-rename --divert $distrib --add $dfile
# remove the old equivalent of $distrib, if it existed.
- if [ -n "$truename" ]; then
- rm -f "$truename"
+ if [ -n "$DPKG_ROOT$truename" ]; then
+ rm -f "$DPKG_ROOT$truename"
fi
replace_with_link $dfile $ltarget $distrib
}
@@ -132,7 +135,7 @@
db_get dash/sh
if [ "$RET" = true ]; then
claim_binsh /bin/sh dash
- if [ -d /usr/share/man/man1/ ]; then
+ if [ -d "$DPKG_ROOT/usr/share/man/man1/" ]; then
claim_binsh /usr/share/man/man1/sh.1.gz dash.1.gz \
/usr/share/man/man1/sh.distrib.1.gz
fi