summaryrefslogtreecommitdiff
path: root/build-docker.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build-docker.sh')
-rwxr-xr-xbuild-docker.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/build-docker.sh b/build-docker.sh
index 0258920..d28b687 100755
--- a/build-docker.sh
+++ b/build-docker.sh
@@ -98,6 +98,40 @@ else
)
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
+ # Register qemu-arm for binfmt_misc (binfmt_misc won't care duplicate entries unless they have common names)
+ 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
+
trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${DOCKER_CMDLINE_NAME}' SIGINT SIGTERM
time ${DOCKER} run \
"${DOCKER_CMDLINE_PRE[@]}" \
@@ -123,6 +157,10 @@ time ${DOCKER} run \
# Ensure that deploy/ is always owned by calling user
echo "copying results from deploy/"
${DOCKER} cp "${CONTAINER_NAME}":/pi-gen/deploy - | tar -xf -
+
+echo "copying log from container ${CONTAINER_NAME} to depoy/"
+${DOCKER} logs --timestamps "${CONTAINER_NAME}" &>deploy/build-docker.log
+
ls -lah deploy
# cleanup