Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream updates #10

Open
wants to merge 222 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
930d861
Update release notes
XECDesign Aug 20, 2020
78c9e2c
Raspbian -> Raspberry Pi OS
XECDesign Aug 24, 2020
d6207a6
Update OS.png
XECDesign Aug 24, 2020
c1a7dae
Enable adding SSH pubkey and setting pubkey only (#380)
Sep 8, 2020
d6ee1e5
Update README.md
Sep 16, 2020
be8daaa
Only disable wifi if WPA_COUNTRY is not set (#416)
rnestler Sep 18, 2020
d159645
workaround build failure on AWS M6g instances (#449)
Sep 23, 2020
dd96ca1
Automagically use i386/debian:buster (#415)
aniongithub Oct 6, 2020
6c21cc1
stage4: add printing support
XECDesign Nov 17, 2020
0f59f00
export-image: get apt lists from public repo
XECDesign Nov 17, 2020
cce27bd
Update release notes
XECDesign Nov 27, 2020
94a4e4b
Finalise 2020-12-02
XECDesign Dec 2, 2020
225f698
os.json: Update kernel version automatically
XECDesign Dec 2, 2020
69ee26f
stage5: Remove scratch2
XECDesign Jan 4, 2021
96982d1
Add 1.2 multiplier to nominal root partition size
XECDesign Jan 8, 2021
2109051
Update release notes
XECDesign Jan 4, 2021
bf8c9f5
Add QCOW2 build mechanism (#349)
pandel Feb 10, 2021
4611094
Update release notes
XECDesign Mar 4, 2021
66cd2d1
Install gpiozero in lite images
XECDesign Mar 31, 2021
dcfd74d
Update release notes
XECDesign May 7, 2021
f271ce2
Added PIGEN_DOCKER_OPTS to build-docker.sh (#521)
Claudenw Jun 16, 2021
4ebe549
Update Beginner's Guide download link
XECDesign Jun 17, 2021
54e1bb4
Added simple catch for default case in which PIGEN_DOCKER_OPTS is uns…
DBongiorno-CG Jun 17, 2021
d562f2a
Fix: update dependencies (#526)
fisiel Jun 22, 2021
f9d44ed
Copy debootstrap.log on failure
XECDesign Jun 22, 2021
42bbe02
Fix broken imagetool.sh --mount (#529)
bbinet Jun 24, 2021
ff1e8b1
Remove deprecated elevator key from cmdline (#535)
MichaIng Sep 1, 2021
f6048c7
Update 07-resize-init.diff
XECDesign Sep 1, 2021
029f258
Don't check for binfmt_misc on arm platforms
kormoc Dec 20, 2020
2f12cf9
Remove IMG_DATE from work directories
XECDesign Sep 20, 2021
a8596e0
Use sync mode when running 'kpartx -a'
Josh798 Oct 5, 2021
d9b4a4a
Switch to bullseye
XECDesign Oct 4, 2021
b23d0b1
Use raspi-config to disable predictable network interface names
XECDesign Oct 5, 2021
7c45f4e
stage3: install libcamera-tools and libcamera-apps
XECDesign Oct 5, 2021
456aa2e
bootstrap: do not install the info package
XECDesign Oct 5, 2021
d0eed3b
Update config.txt
XECDesign Oct 5, 2021
ac246e3
Use raspi-config to toggle boot_wait
XECDesign Oct 5, 2021
5a4b7ec
Update release notes
XECDesign Oct 5, 2021
b542f68
stage2: install python-is-python3
XECDesign Oct 7, 2021
93beb9f
stage2: install libcamera-apps-lite
XECDesign Oct 15, 2021
6d36377
Automatically load overlays for detected DSI displays
XECDesign Oct 29, 2021
85bc296
Update release notes
XECDesign Oct 29, 2021
288b21f
Update release notes
XECDesign Oct 29, 2021
68fee34
Do not use qcow2 images by default
XECDesign Nov 8, 2021
1e0c206
Fix imagetool example
marcone Nov 7, 2021
2798307
Update README.md
myxxmikeyxx Nov 10, 2021
9e52285
Remove omxplayer
XECDesign Nov 10, 2021
6117b9b
Add user to render group
XECDesign Nov 12, 2021
69cd279
Update chromium install
XECDesign Dec 2, 2021
3fb5442
Update release notes
XECDesign Dec 6, 2021
351024d
stage2: Install udisks2
XECDesign Dec 6, 2021
f04a414
Install mkvtoolnix for mkvmerge
XECDesign Dec 22, 2021
786af7c
stage3: install gnome-keyring
XECDesign Dec 22, 2021
23f75d6
Update release notes
XECDesign Jan 10, 2022
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)
brevalferrari 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
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ SKIP
SKIP_IMAGES
.pc
*-pc
apt-cacher-ng/
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'
9 changes: 5 additions & 4 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 \
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
247 changes: 171 additions & 76 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:bookworm
;;
*)
BASE_IMAGE=debian:bookworm
;;
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-static and /proc/sys/fs/binfmt_misc are present
if [[ "${binfmt_misc_required}" == "1" ]]; then
if ! qemu_arm=$(which qemu-arm-static) ; then
echo "qemu-arm-static not found (please install qemu-user-static)"
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-static &&
# binfmt_misc is sometimes not mounted with debian bookworm 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