Source: glibc
Version: 2.27-6
Severity: wishlist
Tags: patch
Control: user debian-d...@lists.debian.org
Control: usertag -1 + dpkg-root-support

Hi,

In version 1.18.5, dpkg gained a new way for installing binary packages.
It now supports executing maintainer scripts outside the system it is
operating on. The feature is tracked at
https://wiki.debian.org/Teams/Dpkg/Spec/InstallBootstrap. This is
relevant in two ways:
 * When running debootstrap, ordering postinsts is tricky due to the
   number of dependency loops. By executing them outside the chroot,
   some loops can be broken as utilities of the outer system can be
   used.
 * When creating chroots for foreign architectures, the utilities
   inside such chroots usually cannot be executed at all.

To support this, dpkg now unconditionally exports an environment
variable called DPKG_ROOT. It will point to the installation root with
the trailing slash stripped. That means under normal conditions, it is
empty. Since scripts are normally run under chroot(2) even when passing
--root to dpkg, it is empty in that case as well. Only when explicitly
activating the new mode, the chroot call is skipped and DPKG_ROOT can be
non-empty. It is yet unclear under what conditions this mode should be
enabled, so for the time being the only way to do so is to use
--force-script-chrootless and I stress that this is only meant for
testing.

Currently in Debian sid, there are 57 packages that need to be installed
for the whole Essential:yes set. Most of them Depend (directly or
indirectly) on libc6. Attached patch adds $DPKG_ROOT to a couple of
places of the preinst and postinst of libc6 and that will make 37 of
these 57 install without problems. The patch adds $DPKG_ROOT in more
places than strictly necessary for just installing packages. For example
I didn't test the upgrade scenario. If you like, I can prepare a smaller
patch with only the code paths that I tested.

It would be nice if you could consider applying attached patch because
it is required for the majority of packages in the Essential:yes set to
be successfully installed with the --force-script-chrootless mode.

To test you can run:

dpkg --root "$target" --log "$target/var/log/dpkg.log" 
--force-script-chrootless -i libc6_2.27-6.1_amd64.deb

Thanks!

cheers, josch
diff -Nru glibc-2.27/debian/changelog glibc-2.27/debian/changelog
--- glibc-2.27/debian/changelog 2018-09-04 21:13:02.000000000 +0200
+++ glibc-2.27/debian/changelog 2018-10-09 06:02:02.000000000 +0200
@@ -1,3 +1,10 @@
+glibc (2.27-6.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * support DPKG_ROOT
+
+ -- Johannes 'josch' Schauer <jo...@debian.org>  Tue, 09 Oct 2018 06:02:02 
+0200
+
 glibc (2.27-6) unstable; urgency=medium
 
   [ Samuel Thibault ]
diff -Nru glibc-2.27/debian/debhelper.in/libc.postinst 
glibc-2.27/debian/debhelper.in/libc.postinst
--- glibc-2.27/debian/debhelper.in/libc.postinst        2018-01-06 
01:49:53.000000000 +0100
+++ glibc-2.27/debian/debhelper.in/libc.postinst        2018-10-09 
06:02:02.000000000 +0200
@@ -17,14 +17,14 @@
 if [ "$type" = "configure" ]
 then
     # We don't use a registry anymore, remove the old file
-    rm -f /etc/ld.so.hwcappkgs
+    rm -f "$DPKG_ROOT/etc/ld.so.hwcappkgs"
  
     # /etc/ld.so.nohwcap code:
     __NOHWCAP__
 
     # Load debconf module if available
-    if [ -f /usr/share/debconf/confmodule ] ; then
-       . /usr/share/debconf/confmodule
+    if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
+       . "$DPKG_ROOT/usr/share/debconf/confmodule"
     fi
 
     if [ -n "$preversion" ] && [ -x "$(which ischroot)" ] && ! ischroot; then
@@ -41,7 +41,7 @@
            __NSS_CHECK__
            if [ -n "$services" ]; then
 
-               if [ -f /usr/share/debconf/confmodule ] ; then
+               if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
                    db_version 2.0
                    db_input critical libraries/restart-without-asking || true
                    db_go || true
@@ -116,7 +116,7 @@
                    done
                    echo
                    if [ -n "$failed" ]; then
-                       if [ -f /usr/share/debconf/confmodule ] ; then
+                       if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; 
then
                            db_fset glibc/restart-failed seen false
                            db_subst glibc/restart-failed services "$failed"
                            db_input critical glibc/restart-failed || true
@@ -140,7 +140,7 @@
                fi
                 # Shut down the frontend, to make sure none of the
                # restarted services keep a connection open to it
-               if [ -f /usr/share/debconf/confmodule ] ; then
+               if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
                    db_stop
                fi
            else
@@ -156,7 +156,7 @@
     if ischroot 2>/dev/null; then
         # Don't bother trying to re-exec init from a chroot:
         TELINIT=no
-    elif [ -d /run/systemd/system ]; then
+    elif [ -d "$DPKG_ROOT/run/systemd/system" ]; then
         # Skip if systemd is the active PID 1, since systemd doesn't
         # need a reexec for a clean shutdown
         TELINIT=no
@@ -165,7 +165,7 @@
         if dpkg --compare-versions "$UPSTART" lt-nl 1.6.1; then
             # This is an old upstart that can't re-exec statefully:
             TELINIT=no
-            touch /var/run/init.upgraded
+            touch "$DPKG_ROOT/var/run/init.upgraded"
         fi
     fi
     if [ "$TELINIT" = "yes" ]; then
diff -Nru glibc-2.27/debian/debhelper.in/libc.preinst 
glibc-2.27/debian/debhelper.in/libc.preinst
--- glibc-2.27/debian/debhelper.in/libc.preinst 2018-01-06 01:49:53.000000000 
+0100
+++ glibc-2.27/debian/debhelper.in/libc.preinst 2018-10-09 06:02:02.000000000 
+0200
@@ -93,8 +93,8 @@
 if [ "$type" != abort-upgrade ]
 then
     # Load debconf module if available
-    if [ -f /usr/share/debconf/confmodule ] ; then
-        . /usr/share/debconf/confmodule
+    if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
+        . "$DPKG_ROOT/usr/share/debconf/confmodule"
     fi
 
     # See if LD_LIBRARY_PATH contains the traditional /lib, but not the
@@ -153,7 +153,7 @@
 
         if linux_compare_versions "$kernel_ver" lt $kernel_ver_min
         then
-            if [ -f /usr/share/debconf/confmodule ]
+            if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ]
             then
                 db_version 2.0
                 db_fset glibc/kernel-too-old seen false
@@ -173,7 +173,7 @@
 
         if linux_compare_versions "$kernel_ver" lt $kernel_ver_rec
         then
-            if [ -f /usr/share/debconf/confmodule ]
+            if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ]
             then
                 db_version 2.0
                 db_fset glibc/kernel-not-supported seen false
@@ -196,7 +196,7 @@
         kernel_ver_min=8.3
         if kfreebsd_compare_versions "$kernel_ver" lt $kernel_ver_min
         then
-            if [ -f /usr/share/debconf/confmodule ]
+            if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ]
             then
                 db_version 2.0
                 db_version 2.0
@@ -234,7 +234,7 @@
 
     dirs="SLIBDIR /lib /lib/tls /lib32 /lib64 /usr/local/lib /usr/local/lib32 
/usr/local/lib64"
     for dir in $dirs ; do
-        check_dir "in an unexpected directory" $dir
+        check_dir "in an unexpected directory" "$DPKG_ROOT/$dir"
     done
 
     if test -n "$LD_LIBRARY_PATH"; then
@@ -244,16 +244,16 @@
         done
     fi
 
-    if test -e /etc/ld.so.conf; then
-        dirs=$(echo $(cat /etc/ld.so.conf))
+    if test -e "$DPKG_ROOT/etc/ld.so.conf"; then
+        dirs=$(echo $(cat "$DPKG_ROOT/etc/ld.so.conf"))
         if test -n "$dirs" ; then
             for dir in $dirs ; do
-                check_dir "via /etc/ld.so.conf" $dir
+                check_dir "via /etc/ld.so.conf" "$DPKG_ROOT/$dir"
             done
         fi
     fi
 
-    if [ -e /lib/tls/i686/cmov/libc.so.6 ] || [ -e /lib/i686/cmov/libc.so.6 ] 
; then
+    if [ -e "$DPKG_ROOT/lib/tls/i686/cmov/libc.so.6" ] || [ -e 
"$DPKG_ROOT/lib/i686/cmov/libc.so.6" ] ; then
         status_i686=$(dpkg -s libc6-i686 2>/dev/null | grep ^Status: | sed -e 
's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
         status_xen=$(dpkg -s libc6-xen 2>/dev/null | grep ^Status: | sed -e 
's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
         if ([ -z "$status_i686" ] || [ "$status_i686" = "not-installed" ] || [ 
"$status_i686" = "config-files" ]) && \
@@ -271,7 +271,7 @@
        # NSS authentication trouble guard
        if dpkg --compare-versions "$preversion" lt GLIBC_VERSION; then
            if pidof xscreensaver xlockmore >/dev/null; then
-               if [ -f /usr/share/debconf/confmodule ] ; then
+               if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
                    db_version 2.0
                    db_reset glibc/disable-screensaver
                    db_input critical glibc/disable-screensaver || true
@@ -301,7 +301,7 @@
            # NSS services check:
            __NSS_CHECK__
            if [ -n "$services" ]; then 
-               if [ -f /usr/share/debconf/confmodule ] ; then
+               if [ -f "$DPKG_ROOT/usr/share/debconf/confmodule" ] ; then
                    db_version 2.0
                    db_reset glibc/upgrade
                    db_subst glibc/upgrade services $services
@@ -353,7 +353,7 @@
 
     # This will keep us from using hwcap libs (optimized) during an
     # upgrade.
-    touch /etc/ld.so.nohwcap
+    touch "$DPKG_ROOT/etc/ld.so.nohwcap"
 fi
 
 #DEBHELPER#
@@ -363,8 +363,8 @@
        # unconditionally wipe ld.so.cache on major version upgrades; this
        # makes those upgrades a bit slower, but is less error-prone than
        # hoping we notice every time the cache format is changed upstream
-       rm -f /etc/ld.so.cache
-       rm -f /var/cache/ldconfig/aux-cache
+       rm -f "$DPKG_ROOT/etc/ld.so.cache"
+       rm -f "$DPKG_ROOT/var/cache/ldconfig/aux-cache"
     fi
 fi
 

Reply via email to