The instructions do state that pi-gen only run on Debian-based operating system, but, having moved from ubuntu to fedora on my computers, I have found the steps required to make pi-gen work on Fedora. This solution should also work on other distros with dynamically linked qemu-user-binfmt binaries (check cat /proc/sys/fs/binfmt_misc/qemu-aarch64, if Flags is empty/not set to F it is probably a dynamically linked binary, see below)
I initially installed all requirements, then tried running build.sh and docker-build.sh, both of which failed due to debootstrap giving:
arm64: not supported on this machine/kernel
I found the cause of the problem to be that the fedora qemu-user-binfmt package provides dynamically linked binaries lacking the F-flag, as opposed to debian/ubuntus package that is statically linked with F-flag set.
The F-flag causes the kernel to cache the interpreter (ie qemu-aarch64) on first run and reuse it, while without it the kernel loads the interpreter again for every call. The problem here is that the moment debootstrap chroots into an empty root, before downloading and installing the required system - including qemu-user-binfmt - there is initially no /usr/bin/qemu-aarch64 in the chroot to load and therefore debootstrap fails. I am not sure why this would also cause docker-build.sh to fail, but that is indeed the behaviour, see attached error:
build docker sh-error.txt
The solution is to instead install qemu-user-static, this provides statically linked versions of the binaries which also sets the F-flag, however these are, for compatibility with qemu-user-binfmt (dynamically linked version), suffixed with -static, i.e. /usr/bin/qemu-arm-static instead of /usr/bin/qemu-arm. These are loaded in reverse alphabetical order from the conf files in /usr/lib/binfmt.d/, so if both qemu-user-binfmt (adding qemu-aarch64-dynamic.conf to binfmt.d/) and qemu-user-static (adding qemu-aarch64-static.conf) are installed the static version takes precedence, BUT... build.sh and docker-build.sh still fails despite /proc/sys/fs/binfmt_misc/qemu-aarch64 listing the static binary as the active one!
So the only solution is to uninstall qemu-user-binfmt and install qemu-user-static, but that leaves the problem of the latter package suffixing with -static leading to build.sh and docker-build.sh failing as they check for /usr/bin/qemu-aarch64 and not /usr/bin/qemu-aarch64-static. So it is necessary to create symlinks to the static binaries
sudo ln -sf /usr/bin/qemu-arm-static /usr/bin/qemu-arm && sudo ln -sf /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64
Having done this I could successfully run both build.sh and docker-build.sh to build my pi-gen image on Fedora 44.
You might want to add these instructions in the README.md
Instructions to run on Fedora
To run pi-gen on Fedora the package qemu-user-binfmt must be uninstalled (see LINK TO THIS ISSUE for details) as it is not compatible with chroot, instead the package qemu-user-static must be installed and symlinks made for /usr/bin/qemu-arm-static --> qemu-arm, and qemu-aarch64-static --> qemu-aarch64. In order to run pi-gen under Fedora:
sudo dnf remove qemu-user-binfmt
sudo dnf install quilt qemu-user-static debootstrap zerofree bsdtar xxd pigz arch-test
sudo ln -sf /usr/bin/qemu-arm-static /usr/bin/qemu-arm && sudo ln -sf /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64
The instructions do state that pi-gen only run on Debian-based operating system, but, having moved from ubuntu to fedora on my computers, I have found the steps required to make pi-gen work on Fedora. This solution should also work on other distros with dynamically linked qemu-user-binfmt binaries (check cat /proc/sys/fs/binfmt_misc/qemu-aarch64, if Flags is empty/not set to F it is probably a dynamically linked binary, see below)
I initially installed all requirements, then tried running build.sh and docker-build.sh, both of which failed due to debootstrap giving:
I found the cause of the problem to be that the fedora qemu-user-binfmt package provides dynamically linked binaries lacking the F-flag, as opposed to debian/ubuntus package that is statically linked with F-flag set.
The F-flag causes the kernel to cache the interpreter (ie qemu-aarch64) on first run and reuse it, while without it the kernel loads the interpreter again for every call. The problem here is that the moment debootstrap chroots into an empty root, before downloading and installing the required system - including qemu-user-binfmt - there is initially no /usr/bin/qemu-aarch64 in the chroot to load and therefore debootstrap fails. I am not sure why this would also cause docker-build.sh to fail, but that is indeed the behaviour, see attached error:
build docker sh-error.txt
The solution is to instead install qemu-user-static, this provides statically linked versions of the binaries which also sets the F-flag, however these are, for compatibility with qemu-user-binfmt (dynamically linked version), suffixed with -static, i.e. /usr/bin/qemu-arm-static instead of /usr/bin/qemu-arm. These are loaded in reverse alphabetical order from the conf files in /usr/lib/binfmt.d/, so if both qemu-user-binfmt (adding qemu-aarch64-dynamic.conf to binfmt.d/) and qemu-user-static (adding qemu-aarch64-static.conf) are installed the static version takes precedence, BUT... build.sh and docker-build.sh still fails despite /proc/sys/fs/binfmt_misc/qemu-aarch64 listing the static binary as the active one!
So the only solution is to uninstall qemu-user-binfmt and install qemu-user-static, but that leaves the problem of the latter package suffixing with -static leading to build.sh and docker-build.sh failing as they check for /usr/bin/qemu-aarch64 and not /usr/bin/qemu-aarch64-static. So it is necessary to create symlinks to the static binaries
Having done this I could successfully run both build.sh and docker-build.sh to build my pi-gen image on Fedora 44.
You might want to add these instructions in the README.md
Instructions to run on Fedora
To run pi-gen on Fedora the package qemu-user-binfmt must be uninstalled (see LINK TO THIS ISSUE for details) as it is not compatible with chroot, instead the package qemu-user-static must be installed and symlinks made for /usr/bin/qemu-arm-static --> qemu-arm, and qemu-aarch64-static --> qemu-aarch64. In order to run pi-gen under Fedora: