Skip to content

Conversation

@trupples
Copy link
Collaborator

@trupples trupples commented Sep 23, 2025

Pull Request Description

Building Kuiper images on a Debian bookworm Raspberry Pi 5 host would previously run into the following issues:

  1. 01.bootstrap/run.sh fails at update-binfmts --enable qemu-arm because qemu-arm is not provided on arm hosts ("why emulate arm if already natively on arm?")
  2. 07.extra-tweaks/02.install-rpi-packages fails because chroot detection with debtools ischroot returns incorrect results (2 instead of 0), which breaks the post-install script of the raspi-firmware package.

This PR adds:

  1. A condition to only update-binfmts if emulation is actually needed (host arch != aarch64 && host arch != arm*)
  2. An optional "hack" to temporarily replace ischroot with /usr/bin/true during the image build. This assumes all binaries executed from the built rootfs are ran inside a chroot environment.
  3. An optional "hack" to speed up dpkg by disabling filesystem syncs after each installed package. This helps a lot when the backing storage is slow, such as an SD card.

Open questions:

  1. Is the stage numbering alright? My rationale:
    • The hacks should be deactivated right before exporting the image so they apply to any build steps added in the future.
    • The dpkg unsafe-io hack should be enabled as soon as possible to speed up as many package installs as possible (right after debootstrap would be ideal)
    • The ischroot hack must be enabled before 07.extra-tweaks/02.install-rpi-packages.
  2. Should any of the hacks be enabled by default? Should they be renamed to something else?

PR Type

  • Bug fix (change that fixes an issue)
  • New feature (change that adds new functionality)
  • Breaking change (has dependencies in other repos or will cause CI to fail)

PR Checklist

  • I have performed a self-review of the changes
  • I have commented my code, at least hard-to-understand parts
  • I have built Kuiper Linux image with the changes
  • I have tested new image in hardware, on relevant boards
  • I have signed off all commits from this PR
  • I have updated the documentation (wiki pages, ReadMe etc)

Add an optional "hack" that replaces ischroot with /usr/bin/true for the duration
of the build, because we can safely assume all commands run during the build are
done in chroot. Select with `HACK_ISCHROOT_TRUE=y`.

Debtools provides `ischroot` as an utility to chech if one is running in a chroot
environment. This is used in various package installations to avoid behaviour
that is invalid inside a chroot. The current version doesn't function properly in
our build environment, returning 2 (= chroot detection is not possible), which
breaks some package installs (e.g. raspi-bootloader, but not only).

Signed-off-by: Ioan Dragomir <[email protected]>
Add an if clause to only activate the `qemu-arm` binfmt on non-arm
hosts. On arm hosts, no emulation is needed. Attempting to activate
the arm binfmt on native arm hosts leads to an error because the
`qemu-user-binfmt` package doesn't contain binfmt configs for their
respective host architecture (i.e. the amd64 package doesn't contain
qemu-x86_64, the arm64 package doesn't contain qemu-arm, etc.).

This makes it possible to build Kuiper images on an arm64 host,
allowing for build speedups by removing the emulation layer.

It should also allow building of 32 bit images on armv6/v7/v7l hosts.

Building armhf images on an arm64 host
--------------------------------------

Note that building armhf images requires the host run a kernel with
4k pages, such as `kernel8.img` instead of `kernel2712.img` on the
Raspberry Pi 5. The kernel included in the image can be anything.
On a 16k page kernel, many binaries will fail to load inside the chroot
because of page alignment. The opposite is not an issue: binaries with
16k pages are compatible with a kernel with 4k pages.

See: raspberrypi/bookworm-feedback#107

Signed-off-by: Ioan Dragomir <[email protected]>
@trupples trupples force-pushed the add-rpi5-build-support branch from a0eb091 to 44409d7 Compare October 8, 2025 11:45
@trupples
Copy link
Collaborator Author

trupples commented Oct 8, 2025

Force push rolls back dpkg unsafe-io hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants