1

I am trying to set up a foreign chroot in a docker container. Excerpt from the script:

apt-get -y install debootstrap fakechroot fakeroot qemu-user-static binfmt-support
mkdir -p $CROSS_ROOT
fakechroot fakeroot -s .fakeroot.state debootstrap --variant=fakechroot --include=fakeroot,build-essential,ca-certificates,debian-archive-keyring,git,sudo --arch=${CROSS_ARCH} --foreign ${CROSS_RELEASE} $CROSS_ROOT $CROSS_MIRROR
mkdir -p $CROSS_ROOT/usr/bin
ln /usr/bin/qemu-*-static $CROSS_ROOT/usr/bin/
fakechroot fakeroot -i .fakeroot.state -s .fakeroot.state chroot $CROSS_ROOT /debootstrap/debootstrap --second-stage

For Debian buster/armhf, the last line fails with the following error message:

/lib/ld-linux-armhf.so.3: No such file or directory

However, when I insert ls -la $CROSS_ROOT/lib/ld-linux-* before the last line, the library file is found:

lrwxrwxrwx 1 root root 30 Mar 15  2022 /opt/chroot/armhf/lib/ld-linux-armhf.so.3 -> arm-linux-gnueabihf/ld-2.28.so

The link target also exists:

-rwxr-xr-x 1 root root 105840 Mar 15  2022 /opt/chroot/armhf/lib/arm-linux-gnueabihf/ld-2.28.so

So the library is definitely where it should be. What is wrong here, and what can I do about it?

1 Answer 1

0

Some sources on the net indicate that fakechroot behaves in an inconsistent manner, which might explain the failures. Besides, fakechroot should not be needed, as chroot runs without any issues in a Docker container (GitLab CI runner, which as I understand runs in unprivileged mode).

On the other hand, fakeroot seems to be necessary, as some privileged operations (namely, mounting /sys and /proc) will otherwise fail on an unprivileged Docker container.

This also means we can select a regular --variant (anything other than fakechroot, which will error out if not running in a fakechroot environment).

So, drop fakechroot and use a --variant other than fakechroot (in my case, buildd as I am setting up a build system). The following worked, at least to the point that debootstrap finishes both stages without errors:

apt-get -y install debootstrap fakechroot fakeroot qemu-user-static binfmt-support
mkdir -p $CROSS_ROOT
fakeroot -s .fakeroot.state debootstrap --variant=buildd --include=fakechroot,fakeroot,build-essential,ca-certificates,debian-archive-keyring,git,sudo --arch=${CROSS_ARCH} --foreign ${CROSS_RELEASE} $CROSS_ROOT $CROSS_MIRROR
mkdir -p $CROSS_ROOT/usr/bin
ln /usr/bin/qemu-*-static $CROSS_ROOT/usr/bin/
fakeroot -i .fakeroot.state -s .fakeroot.state chroot $CROSS_ROOT /debootstrap/debootstrap --second-stage --verbose

Some packages were also changed over the previous example; I didn’t investigate if that is really necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .