CRUX for DevTerm A06, dev notes

I should have probably guessed this, but doing this on an x86-64 host does not do what you might hope it does:

sudo qemu-aarch64 /tmp/a06root/bin/busybox chroot /tmp/a06root

It executes the chroot(2) syscall by emulating a 64-bit ARM CPU, and then tries to execute a shell in that chroot, but cannot do so because it is looking for an x86-64 executable. So I tried the binfmt script that comes with qemu:

$ sudo mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
$ sudo /usr/local/bin/qemu-binfmt-conf.sh --qemu-path /usr/bin --persistent yes --credential
### [...lotsa output, succeeded...]
$ sudo /tmp/a06root/bin/busybox ls
### Works!
$ sudo /tmp/a06root/bin/busybox chroot /tmp/a06root /bin/busybox
### Fails because it can't find the libraries for qemu!

This would probably work better with qemu statically compiled and it is probably a bad idea to copy the x86-64 libraries into the chroot and then run ldconfig but that is what I did and I have no regrets:

$ sudo cp /lib/libz.so.1 /lib/librt.so.1 /usr/lib/libglib-2.0.so.0 /usr/lib/libgnutls.so.30 /usr/lib/libgmodule-2.0.so.0 /usr/lib/libstdc++.so.6 /lib/libm.so.6 /lib/libpthread.so.0 /usr/lib/libgcc_s.so.1 /lib/libc.so.6 /lib/libpcre.so.1 /usr/lib/../lib/libp11-kit.so.0 /usr/lib/../lib/libtasn1.so.6 /usr/lib/../lib/libnettle.so.8 /usr/lib/../lib/libhogweed.so.6 /usr/lib/../lib/libgmp.so.10 /lib/libdl.so.2 /usr/lib/../lib/libffi.so.7 /tmp/a06root/lib64
$ sudo cp /lib/ld-linux-x86-64.so.2 /tmp/a06root/lib
### I was worried this part wouldn't work:
$ sudo ldconfig -r /tmp/a06root
### ...but it did!  And then, after that, this worked:
$ sudo /tmp/a06root/bin/busybox chroot /tmp/a06root /bin/bash
# uname -m
aarch64

Before attempting that, note that I copied all of them into $chroot/lib64 rather than $chroot/lib. /lib64 is a symlink to /lib, so I just removed the symlink and then added the lbiraries there (the list of which libraries to copy having been generated by doing ldd $(which qemu-aarch64)). /lib/ld-linux is special, that’s the dynamic loader, it’s got to be in /lib.

Anyway, now that that’s working (I wish I had done it sooner; it would have made this build go smoother and likewise with the R01 Slackware build), I can start using that for distcc at least, maybe build more packages in it.