Package: usrmerge
Version: 36
Severity: serious
Tags: patch

Hi,

the recent changes to usr-is-merged.postinst broke DPKG_ROOT support:

Setting up usr-is-merged (36) ...
removed '/lib64'
/tmp/mmdebstrap.P6Rv45i7Hi/var/lib/dpkg/info/usr-is-merged.postinst: 16: rmdir: 
not found
dpkg: error processing package usr-is-merged (--configure):
 installed usr-is-merged package post-installation script subprocess returned 
error exit status 127
Errors were encountered while processing:
 usr-is-merged
E: Sub-process /usr/bin/dpkg returned an error code (1)
E: setup failed: E: command failed: 
/usr/share/mmdebstrap/hooks/merged-usr/essential00.sh
I: main() received signal PIPE: waiting for setup...
I: removing tempdir /tmp/mmdebstrap.P6Rv45i7Hi...
Can't exec "rm": No such file or directory at /usr/bin/mmdebstrap line 6232.
E: rm failed: -1

Since usr-is-merged.postinst fails to respect $DPKG_ROOT it will operate
on the directory hierarchy outside the chroot and remove several rather
important directories.

I'm filing this with severity series because it breaks the mmdebstrap
autopkgtest and should thus be prevented from transitioning to testing until
fixed. The following patch fixes the problem:

diff -Nru usrmerge-36/debian/usr-is-merged.postinst 
usrmerge-36+nmu1/debian/usr-is-merged.postinst
--- usrmerge-36/debian/usr-is-merged.postinst   2023-08-27 13:33:27.000000000 
+0200
+++ usrmerge-36+nmu1/debian/usr-is-merged.postinst      2023-08-29 
01:14:03.000000000 +0200
@@ -9,11 +9,11 @@
   # so clean up the unused (and unowned) ones
   local arch_directories="/lib64 /lib32 /libo32 /libx32"
   for dir in $arch_directories; do
-    [ -e "$dir" ] || continue
+    [ -e "$DPKG_ROOT$dir" ] || continue
     if ! dpkg-query -S $dir >/dev/null 2>&1; then
-      rm -v $dir
-      if [ -e /usr$dir ] && ! dpkg-query -S /usr$dir >/dev/null 2>&1 ; then
-        rmdir --ignore-fail-on-non-empty -v /usr$dir
+      rm -v "$DPKG_ROOT$dir"
+      if [ -e "$DPKG_ROOT/usr$dir" ] && ! dpkg-query -S /usr$dir >/dev/null 
2>&1 ; then
+        rmdir --ignore-fail-on-non-empty -v "$DPKG_ROOT/usr$dir"
       fi
     fi
   done

Reply via email to