I'm trying to build an extremely minimal chroot environment and / or docker base image with strictly only the packages installed to support the one binary I want to run inside. I'm not interested in tools like deboostrap as these seem to force me to build a complete "system" and that's not what I want. I only want the packages I determine to be necessary.
I can download the .deb files I want manually ensuring I download everything to meet declared depnencies and PreDepends.
The problem comes when I try to install with dpkg --root=<target>
and particularly libc6
. It's like the pre/post install scripts are not be placed in the correct location, but I can't figure out what I'm missing:
# dpkg --install --root /target /files/archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.37-0ubuntu2_amd64.deb
(Reading database ... 0 files and directories currently installed.)
Preparing to unpack .../libc6_2.37-0ubuntu2_amd64.deb ...
dpkg (subprocess): unable to execute new libc6:amd64 package pre-installation script (//var/lib/dpkg/tmp.ci/preinst): No such file or directory
dpkg: error processing archive /files/archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.37-0ubuntu2_amd64.deb (--install):
new libc6:amd64 package pre-installation script subprocess returned error exit status 2
dpkg (subprocess): unable to execute new libc6:amd64 package post-removal script (//var/lib/dpkg/tmp.ci/postrm): No such file or directory
dpkg: error while cleaning up:
new libc6:amd64 package post-removal script subprocess returned error exit status 2
Errors were encountered while processing:
/files/archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6_2.37-0ubuntu2_amd64.deb
debootstrap
still appears to assume that there is a "system" being built in the target chroot dir. I would have expected this to succeedmmdebstrap --variant=custom --include=busybox-static unstable ./target/ /etc/apt/sources.list
. but it errors complaining that dpkg isn't available. If I read the error right. It's counterpartdpkg --install --root ./target busybox-static...deb
works just fine. – Philip Couling Aug 10 '23 at 16:00mmdebstrap
man page: if you don’t wantdpkg
in your chroot, you need to either use the “extract” variant (and take care of running the maintainer scripts yourself in the appropriate context), or use chrootless mode (which isn’t widely supported).busybox-static
is a very simple package to install and shouldn’t be considered representative, but it can be a useful first step in bootstrapping a chroot... – Stephen Kitt Aug 10 '23 at 20:42dash
” guess correct? – Stephen Kitt Aug 10 '23 at 20:45dash
was the immediate problem, I'd figuredbusybox-static
might give me a leg up. But I still run into other problems - needing debconf, pulling in perl and others which is deviating from my goal. After reading Teams/Dpkg/Spec/InstallBootstrap I now realise that what I'm trying to achieve is known to be impossible due to the way packages expect the "essential" system packages to be there without declaring it. I wonder if I can use the LFS trick and bind-mount a functional system onto/usr/local/
for the build duration. – Philip Couling Aug 11 '23 at 01:55