pi-gen: Buster builds broken on non-arm hosts
Opening this as a heads to anyone relying on pi-gen.
https://bugs.launchpad.net/qemu/+bug/1805913
Unless this bug is fixed by the time buster goes live, images built through qemu-arm-static are going to be broken in slightly subtle ways. Luckily, qemu devs are pretty good and the issue is likely to be resolved before then.
pixbuf relies on the mime database, which silently fails to update and returns success. The result is that desktop is rendered without any icons.
Something similar happens with SSL certificates, breaking rpi-update and anything else that wants to use https.
Those are the known ways images break, but any binary that uses readdir() is not going to work.
Internally, we’ve moved our builds to an arm build server to avoid going through qemu for now.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 19
- Comments: 47 (25 by maintainers)
Links to this issue
Commits related to this issue
- builder - allow manually setting which dists to build for with __dist= * currently defaults to "stretch buster" — committed to RetroPie/RetroPie-Setup by joolswills 5 years ago
- Force use of 32 bit docker images to workaround a bug See https://github.com/RPi-Distro/pi-gen/issues/271 — committed to Waifus4Lifu/pi-gen-badges by aceat64 5 years ago
- leave stage5 - because of issue on 64 bit - https://github.com/RPi-Distro/pi-gen/issues/271 — committed to JFox-sk/raspbian-ssh by JFox-sk 5 years ago
- BUG: setting architecture for qemu-user-static:i386 to workaround piGen issue #271 — committed to canada4663/pi-gen-greengrass by canada4663 5 years ago
- Fix for non arm host https://github.com/RPi-Distro/pi-gen/issues/271 — committed to Phlogi/pi-gen by Phlogi 5 years ago
- Work around 64-bit qemu bug https://github.com/RPi-Distro/pi-gen/issues/271#issuecomment-556812205 — committed to LinuxCNC/pi-gen by jepler 4 years ago
- Update Dockerfile using 32bit version of the Docker image to overcome issue #271 with SSL Certs — committed to Mmodarre/AzureIotEdgeRPI by Mmodarre 4 years ago
So as per @Chaser’s comment, one way to produce a working image from a 64-bit host is to use
./build-docker.shwith this modification to theDockerfile:@Chaser @rkubes thanks for your input, really appreciated! I now tested it myself too and can also confirm that indeed is just Qemu that needs to be 32 bits, not the kernel of the host system.
I used the included
Dockerfilefrompi-genand used thei386/debian:busterbase image instead to bring 32 bits binaries (including Qemu) as @Chaser suggested. Worked fine on actual RPI.It is not clear at the moment how to test 100% reliably, however the SSL certificates test is a very good indicator as far as I can tell because it provides a tangible control case.
I will send a PR to update the included
Dockerfile. @Chaser thanks a lot again for your input, I didn’t know there werei386images for Docker out there, I would have tested that for sure otherwise.EDIT: @ryanteck might be interested. You don’t need to setup a VM nor a 32-bits kernel for your host build system, just make sure you are installing the
i386version of Qemu in multiarch.@hhromic - Clean execution of todays pi-gen mainline https://github.com/RPi-Distro/pi-gen/commit/114353035142d43798a564a552d1c21fa3e91935
As is pulls down qemu-user-static amd64
Changing to
FROM i386/debian:busterThe build completed successfully. Hopefully this helps.
Hi all, we were able to overcome the issue of SSL certs only by rehashing the ssl certs with c_rehash
Specifically
Credit to Keith Tate as well 😃
As indicated below by @hhromic its not a complete solution.
Maybe my solution is useful for some people: I have decided to take the approach of using Vagrant with Virtualbox because of the fact I can contain everything in a quite portable vm with all dependencies inside (including proxy-cache for the packages). Just create a file
Vagrantfilein the root ofpi-genrepo like this:and run
vagrant up. It will start downloading the Virtualbox base image (based on Debian Buster i386) and after done, it will run thebuild.shscript of the repo. Once done, it will put the images in thedeployfolder. If the process fails, you can run again withvagrant provision.vagrant destroywill delete the vm and its contents. The source is here: https://github.com/jriguera/packer-rpibuilder-vagrant so you can customize it and create your own Raspbian builder vm.@hhromic I usually run my builds in a VM running Ubuntu 18.04. I don’t use docker. I can confirm using the 64-bit 18.04 I will get the SSL error message. I then changed nothing else other than installing the 32-bit
qemu-user-staticpackage and rebuilt the image. Once deployed, I was able to get HTML content without any SSL error messages. All that to say, I also think having the 32-bit qemu is all that’s needed. Not sure if there’s any other tests that we can do to prove there are no other issues.@Chaser that is a workaround for the
ca-certificatespackage only, not a solution to the actual problem described in this issue. I wouldn’t advice advertising it as a solution.The problem affects any program using the
readdir()syscall, not justca-certificatesand the effects are of varying nature. The SSL certificates issue is just one manifestation. Another (as the original post indicated) are icons not being correctly rendered in the Desktop.It is unknown/unverified what other packages might be affected. Therefore the safest solution for now is to build using a 32-bits host (be ARM or non-ARM) as indicated before.
Hi @XECDesign , so I can confirm now that this issue is specifically for hosts with 64 bits kernels no matter if arm or not. I made a testing VM with vanilla Debian
i386(32 bits kernel) and the generated image works fine on real hardware (tested with RPI 3B).To verify this I built a control “broken” Buster image with a 64 bits Debian host using Docker and I did get SSL problems with
curl(with GitHub and other websites too), for example:Then I built another Buster image using a 32 bits Debian host and the
curlcommand above worked fine on the same hardware and same network almost at the same time.Aside, I also noticed a minor issue with the Qemu version shipped with Debian Stretch, where the
man-dbpackage being installed for Buster in the image triggers many of these errors:This is a manifestation of the following bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891109
Fortunately this is resolved in the current Qemu version shipped with Debian Buster, therefore building with a Debian Buster host will not show any errors. I will send a PR to update the
Dockerfilefor this.In summary, I wanted to let you know that this bug is not affecting 32 bits build hosts, no matter if they are arm or not (at least for me). For now you can use a 32 bits build host and
pi-genwill generate a working image.Hope this is useful for future readers!
Depending on the version of qemu and whether you’re using docker, server images might not exhibit issues, but I still wouldn’t recommend it until qemu is fixed.
There has been some good progress upstream. One of the issues has been fixed and another has a fix in the pipeline (https://gitlab.com/qemu-project/qemu/-/issues/633). Not sure how long it will be before there’s an official release with both fixes.
EDIT: I should mention that the fixes only make it work with i686 qemu. amd64 still won’t work, but that seems to be a glibc and/or kernel issue that might not be fixable. I’m not sure what the current state of that is.
Just an update for someone getting here:
I confirm that I just built an arm64 bullseye lite (stage2) image using
build.shon thearm64branch of this repo. My machine is an amd64 debian bullseye. After dumping the image on a real RPi4 and runningcurl -sSL https://github.comI got proper html code (so I guess it is indeed fixed)Just hit this issue while doing something else and the previous workaround didn’t work. It looks like at least on some distributions it’s no longer necessary to copy the qemu binary into the chroot. In my case, it was using the system’s qemu binary rather than the 32bit one I was copying into the chroot.
The workaround I’m using right now is to override the qemu path binfmt uses with a local 32bit copy (edit as appropriate in your case):
Then to remove that override:
Edit: It looks like this is the relevant change that causes the different behaviour: https://bugs.launchpad.net/ubuntu/+source/qemu/+bug/1815100
So, maybe that override with the F flag is a good approach for pi-gen to use in general, to avoid even having to copy the binary in the first place. Pi-gen would just need to check that multiarch support is enabled and that the dependencies are installed, then fetch the binary from somewhere else - debian or ubuntu repos.
@hhromic - was using Codebuild docker image - https://github.com/aws/aws-codebuild-docker-images/blob/master/ubuntu/standard/2.0/Dockerfile
uname -aoutput:@hhromic - understood,
curlworks as expected. HTML content received.Thanks @hhromic updated my comment to be clear its not a solution.
Are there tests that should be done to confirm issues? I have just built an image on a EC2 ARM (64bit) instance (a1.2xlarge) running ubuntu 18.04 LTS. I would like to do some sanity checks on it.
Thanks for looking into it. Much appreciated.