Skip to content

Commit

Permalink
build.sh: Warn user of unsupported build environment architecture and…
Browse files Browse the repository at this point in the history
… fail early if binfmt_misc isn't working as expected
  • Loading branch information
XECDesign committed May 13, 2024
1 parent e95e00f commit d87f764
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ RUN apt-get -y update && \
apt-get -y install --no-install-recommends \
git vim parted \
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
binfmt-support ca-certificates fdisk gpg pigz\
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To install the required dependencies for `pi-gen` you should run:
```bash
apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
dosfstools libarchive-tools libcap2-bin grep rsync xz-utils file git curl bc \
gpg pigz xxd
gpg pigz xxd arch-test
```

The file `depends` contains a list of tools needed. The format of this
Expand Down
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ fi

dependencies_check "${BASE_DIR}/depends"

echo "Checking native $ARCH executable support..."
if ! arch-test -n "$ARCH"; then
echo "WARNING: Only a native build environment is supported. Checking emulated support..."
if ! arch-test "$ARCH"; then
echo "No fallback mechanism found. Ensure your OS has binfmt_misc support enabled and configured."
exit 1
fi
fi

#check username is valid
if [[ ! "$FIRST_USER_NAME" =~ ^[a-z][-a-z0-9_]*$ ]]; then
echo "Invalid FIRST_USER_NAME: $FIRST_USER_NAME"
Expand Down
1 change: 1 addition & 0 deletions depends
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ lsmod:kmod
bc
gpg
pigz
arch-test

0 comments on commit d87f764

Please sign in to comment.