Package: fakechroot
Version: 2.19-3
Severity: normal
Tags: patch

Dear Maintainer,

debootstrap may fail in a fakechroot environment if systemd is not installed or 
if
the architectures inside and outside of the (fake)chroot don't match.
This doesn't occur if the patch below is applied.

The cause is systemctl version 232-15 finding a library through a DT_RUNPATH 
tag 
(ie outside of the (fake)chroot)).
systemctl is invoked in the maintainer scripts of systemd.
$ readelf -d mychroot-amd64/bin/systemctl
[ ... ]
 0x0000000000000001 (NEEDED)             Shared library: 
[libsystemd-shared-232.so]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
[ ... ]
 0x000000000000001d (RUNPATH)            Library runpath: [/lib/systemd]


Here are the symptoms :

$ dpkg -l systemd
+++-==========-=============-==========-===============================
un  systemd       <none>      <none>     (no description available)

$ fakechroot fakeroot -s .fakeroot.state debootstrap --variant=fakechroot sid 
mychroot-amd64
[ ... ]
I: Unpacking the base system...
W: Failure trying to run: chroot /home/me/mychroot-amd64 dpkg --force-overwrite 
--force-confold --skip-same-version \
  --install /var/cache/apt/archives/adduser_3.115_all.deb 
/var/cache/apt/archives/libapparmor1_2.11.0-2_amd64.deb \
  /var/cache/apt/archives/libcryptsetup4_2%3a1.7.3-3_amd64.deb 
/var/cache/apt/archives/libip4tc0_1.6.0+snapshot20161117-5_amd64.deb \
  /var/cache/apt/archives/libkmod2_23-2_amd64.deb 
/var/cache/apt/archives/libcap2_1%3a2.25-1_amd64.deb \
  /var/cache/apt/archives/libidn11_1.33-1_amd64.deb 
/var/cache/apt/archives/libseccomp2_2.3.1-2.1_amd64.deb \
  /var/cache/apt/archives/dmsetup_2%3a1.02.137-1_amd64.deb 
/var/cache/apt/archives/libdevmapper1.02.1_2%3a1.02.137-1_amd64.deb \
  /var/cache/apt/archives/systemd_232-15_amd64.deb
W: See /home/me/mychroot-amd64/debootstrap/debootstrap.log for details 
(possibly the package systemd is at fault)
$ echo $?
1

$ cat mychroot-amd64/debootstrap/debootstrap.log
[ ... ]
Setting up systemd (232-15) ...
systemctl: error while loading shared libraries: libsystemd-shared-232.so: 
cannot open shared object file: No such file or directory
systemctl: error while loading shared libraries: libsystemd-shared-232.so: 
cannot open shared object file: No such file or directory
systemctl: error while loading shared libraries: libsystemd-shared-232.so: 
cannot open shared object file: No such file or directory
systemd-machine-id-setup: error while loading shared libraries: 
libsystemd-shared-232.so: cannot open shared object file: No such file or 
directory
dpkg: error processing package systemd (--install):
 subprocess installed post-installation script returned error exit status 127
Processing triggers for libc-bin (2.24-9) ...
Errors were encountered while processing:
 systemd

debootstrap succeeds if systemd is installed :

# apt-get --no-install-recommends install systemd

$ fakechroot fakeroot -s .fakeroot.state debootstrap --variant=fakechroot sid 
mychroot-amd64
[ ... ]
I: Base system installed successfully.
$ echo $?
0

However, it fails on different architectures :

$ dpkg --print-architecture
amd64
$ LD_LIBRARY_PATH=/usr/lib/i386-linux-gnu/libfakeroot fakechroot fakeroot -s 
.fakeroot.state debootstrap \
--arch=i386 --variant=fakechroot sid mychroot-i386
[ ... ]
I: Unpacking the base system...
W: Failure trying to run: chroot /home/me/mychroot-i386 dpkg --force-overwrite 
--force-confold --skip-same-version \
  --install /var/cache/apt/archives/adduser_3.115_all.deb 
/var/cache/apt/archives/libapparmor1_2.11.0-2_i386.deb \
 /var/cache/apt/archives/libcryptsetup4_2%3a1.7.3-3_i386.deb 
/var/cache/apt/archives/libip4tc0_1.6.0+snapshot20161117-5_i386.deb \
 /var/cache/apt/archives/libkmod2_23-2_i386.deb 
/var/cache/apt/archives/libcap2_1%3a2.25-1_i386.deb 
/var/cache/apt/archives/libidn11_1.33-1_i386.deb \
 /var/cache/apt/archives/libseccomp2_2.3.1-2.1_i386.deb 
/var/cache/apt/archives/dmsetup_2%3a1.02.137-1_i386.deb \
 /var/cache/apt/archives/libdevmapper1.02.1_2%3a1.02.137-1_i386.deb 
/var/cache/apt/archives/systemd_232-15_i386.deb
W: See /home/me/mychroot-i386/debootstrap/debootstrap.log for details (possibly 
the package systemd is at fault)
$ echo $?
1

$ 
LD_LIBRARY_PATH="/usr/lib/i386-linux-gnu/libfakeroot:/home/me/mychroot-i386/lib/systemd"
 fakechroot fakeroot \
-s .fakeroot.state debootstrap --arch=i386  --variant=fakechroot sid 
mychroot-i386
[ ... ]
I: Base system installed successfully.
$ echo $?
0

Thank you for all your work to improve fakechroot !

Regards,
JH Chatenet

--- /usr/sbin/chroot.fakechroot
+++ /usr/sbin/chroot.fakechroot
@@ -89,6 +89,9 @@
 
     
fakechroot_chroot_paths="$fakechroot_chroot_paths${fakechroot_chroot_paths_ldsoconf:+:$fakechroot_chroot_paths_ldsoconf}${FAKECHROOT_LDLIBPATH:+:$FAKECHROOT_LDLIBPATH}"
     fakechroot_chroot_paths="${fakechroot_chroot_paths#:}"
+    # Append /lib/systemd under newroot, so that systemctl works. debootstrap 
needs this on hosts without systemd or with another architecture.
+    
fakechroot_chroot_paths="${fakechroot_chroot_paths}:${fakechroot_chroot_newroot}/lib/systemd"
+    fakechroot_chroot_paths="${fakechroot_chroot_paths#:}"
 fi
 
 # call real chroot


-- System Information:
Debian Release: 9.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: unable to detect

Versions of packages fakechroot depends on:
ii  libfakechroot  2.19-3

fakechroot recommends no packages.

fakechroot suggests no packages.

-- no debconf information

Reply via email to