Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
304 commits
Select commit Hold shift + click to select a range
cc8f695
Add 7z and zip support
XECDesign Jan 12, 2022
231487d
Use trusted.gpg.d instead of apt-key
XECDesign Jan 13, 2022
6d2d36e
Don't try to use qemu-debootstrap
XECDesign Jan 14, 2022
40f67ce
Install ca-certificates during bootstrap
XECDesign Jan 14, 2022
f01430c
Update release notes
XECDesign Jan 20, 2022
0b4874f
Fix docker build with debian bullseye image
simonliedl Jan 19, 2022
c393ef1
Strip trailing spaces
XECDesign Feb 2, 2022
8862e4d
Add check and warning for a space presence in the base path
gromain Feb 2, 2022
7248200
Add gpg dependency
bwisn Feb 1, 2022
b3f6852
Update release notes
XECDesign Feb 3, 2022
c63a3ae
fix dash in README
Feb 16, 2022
b1d54c8
Provide information to build the 64 bit image in the README (#596)
gromain Feb 22, 2022
b2bd87c
Add more binfmt errors and hints to README
Feb 22, 2022
1ad53be
Add flush option to boot partition
XECDesign Feb 23, 2022
c5a906b
Fix whitespace
XECDesign Feb 23, 2022
a120c41
Fix fstab flush option
pelwell Feb 28, 2022
5d044ba
Addition of a `DEPLOY_COMPRESSION` option to the configuration (#592)
gromain Mar 1, 2022
95ac3cf
Remove default password
XECDesign Mar 18, 2022
b0316ae
Enable userconf-pi on first boot
XECDesign Mar 18, 2022
09ebc77
stage4: Install rpi-imager
XECDesign Mar 21, 2022
1b635da
stage4: Install rpi-wayland
XECDesign Mar 21, 2022
f1f6722
Update release notes
XECDesign Mar 28, 2022
f651a43
Update release notes
XECDesign Mar 29, 2022
226b479
stage1: install systemd-timesyncd
XECDesign Apr 4, 2022
3385618
Update release notes
XECDesign Apr 8, 2022
01b2432
Create a `DISABLE_FIRST_BOOT_USER_RENAME` flag to be set in config (#…
gromain Jun 17, 2022
eb82321
Prevent install of OpenJDK 11
XECDesign Apr 20, 2022
d3105c6
Use unbundled BlueJ variant
XECDesign Apr 20, 2022
00da851
Adjust partition formatting and mount options
XECDesign May 4, 2022
288a0a6
Update release notes
XECDesign May 4, 2022
4de913c
Modify 010_pi-nopasswd to match FIRST_USER_NAME
XECDesign Jun 14, 2022
db3cd43
stage2: Install NetworkManager
XECDesign Aug 9, 2022
68ddb44
Use raspi-config to set WPA_COUNTRY
XECDesign Aug 19, 2022
d53c4e5
Default to dhcpcd for now
XECDesign Aug 19, 2022
69cd410
Install picamera2
XECDesign Aug 30, 2022
ec643eb
Update release notes
XECDesign Aug 31, 2022
67491f1
Install 'file'
XECDesign Sep 1, 2022
7206ab1
Switch to sys-mods' firstboot script
XECDesign Sep 1, 2022
6625549
Update release notes
XECDesign Sep 6, 2022
c0cddb7
Update release notes
XECDesign Sep 7, 2022
cb26ff3
nodered is no longer included in full images
XECDesign Sep 14, 2022
59886d8
Update release notes
XECDesign Sep 15, 2022
8a42abc
Update release notes
XECDesign Sep 21, 2022
6a61be9
Disable first run wizard if DISABLE_FIRST_BOOT_USER_RENAME is set
XECDesign Sep 22, 2022
6b8e412
Update release notes
XECDesign Sep 26, 2022
4da0392
Update README.md document WPA_COUNTRY Code format (#636)
kralo Oct 3, 2022
f00b722
apt/retries: specify option from the Acquire group (#638)
kralo Oct 14, 2022
47e34ef
stage2: pre-install kms++-utils
XECDesign Nov 1, 2022
549681f
Updates to avoid common pitfalls when changing the RELEASE variable
XECDesign Nov 8, 2022
c3083ec
Add parameter to keep cap_setfcap
XECDesign Nov 8, 2022
1d13a29
use a single partitioned loop device (#641)
rfc6919 Nov 11, 2022
05081aa
Fix apt gpg key install
XECDesign Feb 8, 2023
5d2c6f3
export-image: change boot partition lable to 'bootfs'
XECDesign Feb 14, 2023
f2d3855
Update release notes
XECDesign Feb 14, 2023
cf40e4b
Check that docker is not set up in rootless mode (#679)
stefanb2 Mar 27, 2023
0db41e3
Ensure that deploy is always owned by user (#680)
stefanb2 Mar 27, 2023
b8437a7
DRY removal for docker run command line (#686)
stefanb2 Mar 28, 2023
4e92753
Use tmpfs for chroot /run and /tmp
XECDesign Mar 29, 2023
6dc45a8
Register binfmt_misc entry for docker build (#685)
moh53n Apr 3, 2023
9249e14
Copy container log to deploy (#688)
stefanb2 Apr 3, 2023
47eee1f
Update release notes
XECDesign Apr 25, 2023
01d24ef
Skip binfmt_misc register when unnecessary (#693)
stefanb2 May 9, 2023
446f3e3
Adds call to mknod if loop dev does not exist after call to `losetup …
bamartin125 Aug 17, 2023
ed68013
fix: support bash v3 by removing array usage (#705)
reubenmiller Sep 25, 2023
6aca615
Switch to Bookworm
XECDesign Sep 7, 2023
9d9d063
Remove/replace obsolete packages
XECDesign Sep 7, 2023
a524fe4
stage3: replace qpdfview with evince
XECDesign Sep 7, 2023
43c49d8
stage3: install eom
XECDesign Sep 7, 2023
9fc1385
stage3: install Firefox
XECDesign Sep 7, 2023
8dd23cb
Remove dhcpcd and associated options
XECDesign Sep 7, 2023
4a4a66e
export-image: auto-remove and purge packages on dist-upgrade
XECDesign Sep 7, 2023
88ac523
Enable Wayland by default
XECDesign Sep 7, 2023
c856800
Switch to new kernel and firmware packages
XECDesign Sep 7, 2023
64b498b
Don't generate NOOBS files
XECDesign Sep 7, 2023
188c155
Migrate to raspberrypi.com
XECDesign Sep 8, 2023
e6dd7ca
stage2: remove rng-tools
XECDesign Sep 12, 2023
574d3e7
stage0: only fetch armhf packages from Raspbian
XECDesign Sep 13, 2023
d7dde0c
stage5: disable greenfoot and bluej as they don't seem to work
XECDesign Sep 7, 2023
6051f1d
stage4: remove pimoroni packages for now
XECDesign Sep 13, 2023
3a6342b
stage0: install kernel headers
XECDesign Sep 14, 2023
7ae1a26
stage4: ignore power key and let raspberrypi-ui-mods handle it
XECDesign Sep 14, 2023
c4f98a8
Move picamera2 to stage3 - PyAV takes up too much space for lite images
XECDesign Aug 23, 2023
5b15e14
stage2: install GPIO libraries
XECDesign Sep 25, 2023
dc6a3c1
stage2: install python3-smbus2
XECDesign Sep 26, 2023
a0b8868
Update release notes
XECDesign Sep 27, 2023
fb56ad5
stage5: match rp-prefapps package list
XECDesign Oct 3, 2023
663401d
README.md: default release is bookworm (#715)
marcone Oct 16, 2023
0ef867e
Fix build-docker.sh CONTINUE=1 mode (#716)
stefanb2 Oct 17, 2023
d966897
README.md: add PI_GEN_RELEASE (#720)
stefanb2 Oct 23, 2023
19acff0
Fix typo (#725)
Nov 22, 2023
95c9fa8
stage2: include gpiod binary tools
XECDesign Nov 27, 2023
5b22a55
Update release notes
XECDesign Nov 27, 2023
193bae2
Remove obsolete packages
XECDesign Nov 28, 2023
399a5c2
stage2: install python3-venv
XECDesign Nov 29, 2023
ae81834
export-image: Add issue.txt symlink
XECDesign Nov 29, 2023
e07ee9b
Update release notes
XECDesign Nov 29, 2023
02b371d
stage4: Update beginner's guide URL, assuming the latest version is a…
XECDesign Nov 29, 2023
1377e90
Ensure loop device partition nodes are created (#741)
acinonyx Jan 4, 2024
c5fdb01
Update release notes
XECDesign Dec 8, 2023
ec04064
stage0: Only disable initramfs updates if update-initramfs.conf exists
XECDesign Dec 18, 2023
a143895
stage0: Check whether foreign architecture is needed
XECDesign Dec 18, 2023
30fa760
stage0: prevent kernel packages from creating useless symlinks
XECDesign Jan 17, 2024
e682f62
stage3: add vulkan support
XECDesign Jan 17, 2024
a125344
Remove cmdline.txt and config.txt symlinks
XECDesign Jan 22, 2024
0425477
stage2: rc.local drop-in no longer required, since Debian ships its o…
XECDesign Jan 23, 2024
c20ce09
export-image: make sure initramfs is created
XECDesign Jan 30, 2024
69037ce
Update README.md (#755)
tdewey-rpi Feb 19, 2024
502e5fa
Remove QCOW2 build mechanism (#648)
mmmspatz Feb 23, 2024
94cbf47
Create .gitlab-ci.yml file
XECDesign Feb 14, 2024
c029146
ensure_loopdev_partitions: let udev settle
XECDesign Feb 15, 2024
82e5642
README.md: Add xxd dependency (#750)
ckuhtz Feb 26, 2024
1ce1f1c
Replace libcamera-apps with rpicam-apps
XECDesign Mar 4, 2024
57c641a
Update release notes
XECDesign Mar 7, 2024
4ce1f1f
stage3: Remove fbturbo
XECDesign Mar 11, 2024
e8d8670
Update release notes
XECDesign Mar 11, 2024
99e1980
stage4: remove disable-pwr-button substage
XECDesign Mar 13, 2024
d92bef1
stage4: add meson
XECDesign Mar 13, 2024
b829737
Update release notes
XECDesign Mar 13, 2024
3b5e214
export-image: format boot partition with appropriate FAT size
XECDesign Mar 13, 2024
af5a88a
stage4: add openocd
XECDesign Mar 13, 2024
1109642
Update release notes
XECDesign Mar 15, 2024
7ce2538
Revert "Added docker-compose.yml for easy apt-cacher-ng startup"
XECDesign Apr 9, 2024
c70f96f
stage5: smartsim has been removed from recommended apps
XECDesign Apr 9, 2024
165e960
Fix keyboard configuration
XECDesign Apr 18, 2024
5780b1f
export stage list
Apr 25, 2024
f1c166a
export-image: run du with -x to avoid crossing filesystem boundaries
XECDesign Apr 29, 2024
e95e00f
Set a default IMG_NAME
XECDesign May 13, 2024
d87f764
build.sh: Warn user of unsupported build environment architecture and…
XECDesign May 13, 2024
9917c86
README.md: Consistent formatting of 'Default' values
XECDesign May 13, 2024
d790fed
Compare mount output using base of dirname (#771)
pevsonic May 15, 2024
fb48183
Expand trap cleanup function (#773)
tdewey-rpi May 15, 2024
75fe47c
Increase default swap size to 200
XECDesign May 27, 2024
07ab464
stage4: Pre-install labwc
XECDesign Jun 10, 2024
9b17be9
Update release notes
XECDesign Jun 10, 2024
ca5eb62
Enable DWC2 host mode support for CM5 by default
XECDesign Jun 24, 2024
0b115f3
stage4: Pre-install rpi-connect
XECDesign Jun 19, 2024
dca93d2
README: add specific stage build for Docker (#777)
beuss Jul 9, 2024
21e8e54
export-image: generate sbom file if syft is available
XECDesign Jul 23, 2024
7fe9ae5
stage3: Switch chromium package and remove unnecessary steps
XECDesign Aug 27, 2024
40a5c1c
stage3: switch to labwc by default
XECDesign Sep 11, 2024
a766e71
stage3: switch from arandr to raindrop
XECDesign Sep 11, 2024
674c30e
Replace python3-rpi.gpio with python3-rpi-lgpio
XECDesign Sep 18, 2024
8f88b83
stage4: install squeekboard
XECDesign Sep 23, 2024
9e65ea7
Update release notes
XECDesign Sep 26, 2024
f165f8a
Update release notes
XECDesign Oct 28, 2024
9dfbb15
Update release notes
XECDesign Oct 28, 2024
b8e497c
Allow export image customisation (#801)
learmj Oct 29, 2024
2aa7133
Create WORK_DIR earlier
XECDesign Oct 29, 2024
df6d0e2
Add kernel page size check
XECDesign Oct 29, 2024
1baee51
Improve PAGESIZE check and recommendation
XECDesign Oct 30, 2024
536dd58
README.md: Clarify early on that armhf and arm64 images should be bui…
XECDesign Oct 30, 2024
9dbd882
README.md: Fix TIMEZONE_DEFAULT description
XECDesign Oct 30, 2024
b91ab52
README.md: Remove obsolete warning
XECDesign Oct 30, 2024
e86b901
Rework wlan blocking
XECDesign Oct 31, 2024
c6d3038
Remove wpa_supplicant tweaks
XECDesign Oct 31, 2024
fba9533
Build initial initramfs with 'most' modules, then change the setting …
XECDesign Oct 31, 2024
d7c4d30
Bump default swap to 512M
XECDesign Nov 1, 2024
8fd4886
Minor spelling and formatting tweaks. (#807)
mml Nov 11, 2024
449d43e
Exclude ifupdown as it slows down boot
XECDesign Nov 11, 2024
c8d0e0b
Remove rc.local
XECDesign Nov 11, 2024
b15527e
Fix bluetooth rfkill unblock - 0 is unblocked
XECDesign Nov 19, 2024
13c185c
Switch default journald storage to volatile
XECDesign Nov 19, 2024
f2d397f
stage2: set publish-workstation to yes in avahi-daemon.conf
XECDesign Nov 21, 2024
8e30e79
stage5: install code-the-classics-2
XECDesign Nov 22, 2024
ca08900
README.md: Fix typo (#813)
marcone Nov 28, 2024
fc28035
Escape the ? expression in sed
XECDesign Jan 2, 2025
fb5180d
Dockerfile: fix ENV warning (#791)
stefanb2 Jan 2, 2025
e071d0d
Switch docker build to Debian Bookworm
stefanb2 Oct 18, 2023
f621f9e
Align partition start boundaries to 8M
P33M Mar 12, 2025
2e5d13e
export-image: generate bmap file if bmaptool is available
roliver-rpi Mar 13, 2025
04880a5
Remove old qemu-arm-static reference
XECDesign Apr 15, 2025
260c17d
stage2: trim down third party firmware package list
XECDesign Mar 13, 2025
ca3d54e
Add TEMP_REPO variable
XECDesign Apr 15, 2025
bcf2bc1
stage4: do not install system-config-printer (replaced with rprinters…
XECDesign Apr 28, 2025
79afc6e
export-image: remove image_ prefix from non-image files
XECDesign Apr 28, 2025
551c588
export-image: Do not compress the bmap file
XECDesign Apr 29, 2025
b9f63ee
Update release notes
XECDesign May 6, 2025
f548f25
Update release notes
XECDesign May 12, 2025
6e8dcbf
Update release notes
XECDesign May 13, 2025
e9c2afb
export-image: Check if bmap file exists before copying
XECDesign May 13, 2025
bf7981f
stage4: remove stage4/03-bookshelf
XECDesign May 28, 2025
26ea1c1
stage4: remove alacarte and alacarte-specific fixes
XECDesign May 28, 2025
52ac775
Add e2fsprogs to dependencies
XECDesign Aug 14, 2025
c2cd4e8
bookworm -> trixie
XECDesign May 13, 2025
ec789c7
Remove obsolete packages
XECDesign Aug 19, 2025
d8ff345
Refresh patches
XECDesign Aug 19, 2025
56d7e30
stage0: modernise apt sources
XECDesign Jun 5, 2025
5dc3f5d
Remove v7l kernel
XECDesign Jul 15, 2025
a62422c
stage4: change do_wayland to W2 (labwc)
XECDesign Aug 19, 2025
c4e9044
Set machine-id to "uninitialized" to signal first boot
XECDesign Jun 2, 2025
23e7af3
Remove firstboot init script in favour of initramfs and systemd services
XECDesign Jun 2, 2025
6811c1d
Remove fake-hwclock
XECDesign Jun 6, 2025
f6a540d
Simplify console-setup configuration
XECDesign Jun 5, 2025
a078afe
stage2: remove resize2fs_once init.d service
XECDesign Jun 5, 2025
9ea6e44
stage2: enable pdiffs
XECDesign Jun 5, 2025
22601c0
stage2: replace dphys-swapfile with rpi-swap
XECDesign Aug 19, 2025
131a375
stage2: remove nfs-common
XECDesign Aug 19, 2025
e324499
stage2: disabling these services doesn't do anything on Trixie
XECDesign Aug 19, 2025
e2893c1
stage2: don't enable regenerate_ssh_host_keys. SSH generates the keys…
XECDesign Aug 19, 2025
59b16f3
stage2: Don't modify journald.conf. This is done via a drop-in config…
XECDesign Aug 19, 2025
99068c0
Replace raspberrypi-ui-mods with new meta-packages
XECDesign Aug 19, 2025
5a978bf
stage4: remove raspberrypi-net-mods, since it's already installed in …
XECDesign Aug 19, 2025
6baaa07
stage4: remove dillo
XECDesign Aug 19, 2025
c4adcfc
Remove rpi-imager (armhf builds no longer provided)
XECDesign Jul 28, 2025
ccb473a
stage2: replace pi-bluetooth with bluez and bluez-firmware
XECDesign Jun 3, 2025
04bc684
stage1: add resize to cmdline.txt
XECDesign Jun 10, 2025
3b4c7e2
stage5: Remove (nu)scratch, since Trixie does not ship SqueakVM
XECDesign Aug 19, 2025
881aa41
stage5: Remove realvnc packages, since they weren't provided for Trixie
XECDesign Aug 19, 2025
556087c
stage5: Remove wolfram-engine, since it wasn't provided for Trixie
XECDesign Aug 19, 2025
d4cd8f9
stage5: Remove scratch3, since it wasn't provided for Trixie
XECDesign Aug 19, 2025
3bcd9d4
Switch stage3 to use meta-packages
XECDesign Aug 4, 2025
349a6a0
Switch stage4 to use meta-packages
XECDesign Aug 4, 2025
bd0a6ab
Move print support, rpd-theme and rpd-preferences to stage3
XECDesign Aug 4, 2025
8887a88
export-image: pre-populate apt-listchanges database
XECDesign Aug 22, 2025
f0f9145
Add missing dependency to README and switch from apt-get to apt
XECDesign Sep 5, 2025
3bfeac6
stage0: Change 'Arch' to 'Architectures' in raspbian.sources
XECDesign Sep 5, 2025
c3848a3
README.md: mention first run wizard in FIRST_USER_NAME documentation
XECDesign Sep 3, 2025
05071a9
build.sh: log skipped non-executable run.sh files
XECDesign Sep 3, 2025
7f6d20c
Whitespace fixes
XECDesign Sep 3, 2025
f9160c0
stage4: Disable wayvnc
XECDesign Sep 4, 2025
734e1a6
Revert "stage5: Remove scratch3, since it wasn't provided for Trixie"
XECDesign Sep 5, 2025
372e563
Add cloud-init support
paulober Aug 28, 2025
0a8f982
stage2: Enable first boot resize and fstrim service
XECDesign Sep 22, 2025
e464053
Partially disable cloud-init
XECDesign Sep 29, 2025
0dfd9a5
stage2: install rpi-keyboard-config and rpi-keyboard-fw-update
XECDesign Sep 30, 2025
7385add
Update release notes
XECDesign Sep 30, 2025
c2096db
Drop powerstate change hook for rpi-usb-gadget
paulober Oct 3, 2025
db9a45c
cloud-init support: Disable emmiting keys to console by default
paulober Oct 6, 2025
ba8b9bc
Disable ssh fingerprint to console
paulober Oct 6, 2025
3b77da7
stage2: preseed console-setup/charmap47
XECDesign Oct 9, 2025
67336fe
Update Raspberry Pi Archive signing key
XECDesign Oct 16, 2025
bbe5f22
stage2: install rpi-usb-gadget
XECDesign Oct 16, 2025
d270801
stage2: install rpi-connect-lite
XECDesign Oct 16, 2025
a46065d
export-image: fix timesync typo
XECDesign Oct 28, 2025
cb05dfc
stage2: Re-add cloud-init files to bootfs (#881)
paulober Nov 24, 2025
a0785ae
Remove wget-log files left behind by debootstrap
XECDesign Nov 5, 2025
2d95547
Update release notes
XECDesign Dec 2, 2025
358f978
Update release notes
XECDesign Dec 4, 2025
7688396
.gitignore: add .vscode/ directories
stefanb2 Feb 27, 2026
164ddbb
Update qemu package binary and package names (#904)
jayofelony Mar 2, 2026
c020178
Add PASSWORDLESS_SUDO option
XECDesign Feb 10, 2026
4b9cd15
Set FIRST_USER_NAME shell to nologin if no password is set
XECDesign Feb 16, 2026
2e8cf25
stage2: Remove modemmanager
XECDesign Feb 26, 2026
21bc9ef
More qemu-user-static->qemu-user-binfmt changes
XECDesign Mar 2, 2026
567a833
Flip do_sudo_pass setting
XECDesign Mar 5, 2026
2ab9dde
stage2: add missing nonint in raspi-config call
XECDesign Mar 17, 2026
219974a
Update release notes
XECDesign Mar 25, 2026
46c6957
export-image: Use 1 sector per cluser for bootfs
XECDesign Mar 27, 2026
e3731e1
Update release notes
XECDesign Apr 16, 2026
d2f70c5
stage2: inreall rpifwcrypto
XECDesign Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ SKIP
SKIP_IMAGES
.pc
*-pc
apt-cacher-ng/
.vscode/
4 changes: 4 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include:
- project: serge/pi-gen
ref: ci
file: 'pi-gen.yml'
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM debian:buster
ARG BASE_IMAGE=debian:bullseye
FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND noninteractive
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get -y update && \
apt-get -y install --no-install-recommends \
git vim parted \
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \
bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
binfmt-support ca-certificates \
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools e2fsprogs\
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc \
binfmt-support ca-certificates fdisk gpg pigz arch-test \
&& rm -rf /var/lib/apt/lists/*

COPY . /pi-gen/
Expand Down
266 changes: 191 additions & 75 deletions README.md

Large diffs are not rendered by default.

119 changes: 93 additions & 26 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/bash -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
#!/usr/bin/env bash
# Note: Avoid usage of arrays as MacOS users have an older version of bash (v3.x) which does not supports arrays
set -eu

DIR="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)"

BUILD_OPTS="$*"

DOCKER="docker"
# Allow user to override docker command
DOCKER=${DOCKER:-docker}

if ! ${DOCKER} ps >/dev/null 2>&1; then
DOCKER="sudo docker"
# Ensure that default docker command is not set up in rootless mode
if \
! ${DOCKER} ps >/dev/null 2>&1 || \
${DOCKER} info 2>/dev/null | grep -q rootless \
; then
DOCKER="sudo ${DOCKER}"
fi
if ! ${DOCKER} ps >/dev/null; then
echo "error connecting to docker:"
Expand Down Expand Up @@ -47,6 +55,7 @@ fi
CONTAINER_NAME=${CONTAINER_NAME:-pigen_work}
CONTINUE=${CONTINUE:-0}
PRESERVE_CONTAINER=${PRESERVE_CONTAINER:-0}
PIGEN_DOCKER_OPTS=${PIGEN_DOCKER_OPTS:-""}

if [ -z "${IMG_NAME}" ]; then
echo "IMG_NAME not set in 'config'" 1>&2
Expand All @@ -73,31 +82,89 @@ fi
# Modify original build-options to allow config file to be mounted in the docker container
BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')"

${DOCKER} build -t pi-gen "${DIR}"
# Check the arch of the machine we're running on. If it's 64-bit, use a 32-bit base image instead
case "$(uname -m)" in
x86_64|aarch64)
BASE_IMAGE=i386/debian:trixie
;;
*)
BASE_IMAGE=debian:trixie
;;
esac
${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}"

if [ "${CONTAINER_EXISTS}" != "" ]; then
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM
time ${DOCKER} run --rm --privileged \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/" &
wait "$!"
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}_cont"
DOCKER_CMDLINE_PRE="--rm"
DOCKER_CMDLINE_POST="--volumes-from=${CONTAINER_NAME}"
else
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}' SIGINT SIGTERM
time ${DOCKER} run --name "${CONTAINER_NAME}" --privileged \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/" &
wait "$!"
DOCKER_CMDLINE_NAME="${CONTAINER_NAME}"
DOCKER_CMDLINE_PRE=""
DOCKER_CMDLINE_POST=""
fi

# Check if binfmt_misc is required
binfmt_misc_required=1
case $(uname -m) in
aarch64)
binfmt_misc_required=0
;;
arm*)
binfmt_misc_required=0
;;
esac

# Check if qemu-arm and /proc/sys/fs/binfmt_misc are present
if [[ "${binfmt_misc_required}" == "1" ]]; then
if ! qemu_arm=$(which qemu-arm) ; then
echo "qemu-arm not found (please install qemu-user-binfmt)"
exit 1
fi
if [ ! -f /proc/sys/fs/binfmt_misc/register ]; then
echo "binfmt_misc required but not mounted, trying to mount it..."
if ! mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc ; then
echo "mounting binfmt_misc failed"
exit 1
fi
echo "binfmt_misc mounted"
fi
if ! grep -q "^interpreter ${qemu_arm}" /proc/sys/fs/binfmt_misc/qemu-arm* ; then
# Register qemu-arm for binfmt_misc
reg="echo ':qemu-arm-rpi:M::"\
"\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:"\
"\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:"\
"${qemu_arm}:F' > /proc/sys/fs/binfmt_misc/register"
echo "Registering qemu-arm for binfmt_misc..."
sudo bash -c "${reg}" 2>/dev/null || true
fi
fi

trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
$DOCKER_CMDLINE_PRE \
--name "${DOCKER_CMDLINE_NAME}" \
--privileged \
${PIGEN_DOCKER_OPTS} \
--volume "${CONFIG_FILE}":/config:ro \
-e "GIT_HASH=${GIT_HASH}" \
$DOCKER_CMDLINE_POST \
pi-gen \
bash -e -o pipefail -c "
dpkg-reconfigure qemu-user-binfmt &&
# binfmt_misc is sometimes not mounted with debian trixie image
(mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true) &&
cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/
" &
wait "$!"

# Ensure that deploy/ is always owned by calling user
echo "copying results from deploy/"
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy .
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy - | tar -xf -

echo "copying log from container ${CONTAINER_NAME} to deploy/"
${DOCKER} logs --timestamps "${CONTAINER_NAME}" &>deploy/build-docker.log

ls -lah deploy

# cleanup
Expand Down
Loading