Skip to content

Commit d87f764

Browse files
committed
build.sh: Warn user of unsupported build environment architecture and fail early if binfmt_misc isn't working as expected
1 parent e95e00f commit d87f764

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ RUN apt-get -y update && \
77
apt-get -y install --no-install-recommends \
88
git vim parted \
99
quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \
10-
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
11-
binfmt-support ca-certificates fdisk gpg pigz\
10+
libarchive-tools libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc \
11+
binfmt-support ca-certificates fdisk gpg pigz arch-test \
1212
&& rm -rf /var/lib/apt/lists/*
1313

1414
COPY . /pi-gen/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ To install the required dependencies for `pi-gen` you should run:
1919
```bash
2020
apt-get install coreutils quilt parted qemu-user-static debootstrap zerofree zip \
2121
dosfstools libarchive-tools libcap2-bin grep rsync xz-utils file git curl bc \
22-
gpg pigz xxd
22+
gpg pigz xxd arch-test
2323
```
2424

2525
The file `depends` contains a list of tools needed. The format of this

build.sh

+9
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ fi
244244

245245
dependencies_check "${BASE_DIR}/depends"
246246

247+
echo "Checking native $ARCH executable support..."
248+
if ! arch-test -n "$ARCH"; then
249+
echo "WARNING: Only a native build environment is supported. Checking emulated support..."
250+
if ! arch-test "$ARCH"; then
251+
echo "No fallback mechanism found. Ensure your OS has binfmt_misc support enabled and configured."
252+
exit 1
253+
fi
254+
fi
255+
247256
#check username is valid
248257
if [[ ! "$FIRST_USER_NAME" =~ ^[a-z][-a-z0-9_]*$ ]]; then
249258
echo "Invalid FIRST_USER_NAME: $FIRST_USER_NAME"

depends

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ lsmod:kmod
1919
bc
2020
gpg
2121
pigz
22+
arch-test

0 commit comments

Comments
 (0)