Skip to content

Commit baaa155

Browse files
committed
Add support to build with BASE_ARCH set as armhf
1 parent c5b7ab8 commit baaa155

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/custompios

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ function execute_chroot_script() {
1515

1616
# In docker, these extra commands are required to enable this black-magic
1717
if [ -f /.dockerenv ] && [ "$(uname -m)" != "armv7l" ] && [ "$(uname -m)" != "aarch64" ] ; then
18-
if [ "$BASE_ARCH" == "armv7l" ]; then
18+
if [ "$BASE_ARCH" == "armv7l" ] || [ "$BASE_ARCH" == "armhf" ]; then
1919
update-binfmts --enable qemu-arm
2020
elif [ "$BASE_ARCH" == "aarch64" ] || [ "$BASE_ARCH" == "arm64" ]; then
2121
update-binfmts --enable qemu-aarch64
2222
fi
23-
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true
23+
if ! mount | grep -q "/proc/sys/fs/binfmt_misc"; then
24+
mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc || true
25+
fi
2426
fi
2527
#move filesystem files
2628
if [ -d "$1/filesystem" ]; then
@@ -30,7 +32,7 @@ function execute_chroot_script() {
3032
#black magic of qemu-arm-static
3133
# cp `which qemu-arm-static` usr/bin
3234
if [ "$(uname -m)" != "armv7l" ] || [ "$(uname -m)" != "aarch64" ] ; then
33-
if [ "$BASE_ARCH" == "armv7l" ]; then
35+
if [ "$BASE_ARCH" == "armv7l" ] || [ "$BASE_ARCH" == "armhf" ]; then
3436
if (grep -q gentoo /etc/os-release);then
3537
ROOT="`realpath .`" emerge --usepkgonly --oneshot --nodeps qemu
3638
else
@@ -51,11 +53,14 @@ function execute_chroot_script() {
5153
chmod 755 common.sh
5254

5355
if [ "$(uname -m)" != "armv7l" ] && [ "$(uname -m)" != "aarch64" ] && [ "$(uname -m)" != "arm64" ] ; then
54-
if [ "$BASE_ARCH" == "armv7l" ]; then
56+
echo "Detected we are on a non-arm device"
57+
if [ "$BASE_ARCH" == "armv7l" ] || [ "$BASE_ARCH" == "armhf" ]; then
5558
echo "Building on non-ARM device a armv7l system, using qemu-arm-static"
5659
if (grep -q gentoo /etc/os-release);then
60+
echo "Building on gentoo non-ARM device a aarch64/arm64 system, using qemu-aarch64-static"
5761
chroot . usr/bin/qemu-arm /bin/bash /chroot_script
5862
else
63+
echo "Using normal non-arm qemu for armv7l"
5964
chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script
6065
fi
6166
elif [ "$BASE_ARCH" == "aarch64" ] || [ "$BASE_ARCH" == "arm64" ]; then
@@ -65,8 +70,11 @@ function execute_chroot_script() {
6570
else
6671
chroot . usr/bin/qemu-aarch64-static /bin/bash /chroot_script
6772
fi
73+
else
74+
echo "Unknown arch, building on: $(uname -m) image: $BASE_ARCH"
75+
exit 1
6876
fi
69-
elif [ "$BASE_ARCH" == "armv7l" ] && [ "$(uname -m)" != "armv7l" ]; then
77+
elif { [ "$BASE_ARCH" == "armv7l" ] || [ "$BASE_ARCH" == "armhf" ]; } && [ "$(uname -m)" != "armv7l" ]; then
7078
echo "Building on aarch64/arm64 device a armv7l system, using qemu-arm-static"
7179
chroot . usr/bin/qemu-arm-static /bin/bash /chroot_script
7280
else

0 commit comments

Comments
 (0)