diff options
| author | Serge Schneider <serge@raspberrypi.com> | 2023-04-25 15:44:25 +0100 |
|---|---|---|
| committer | Serge Schneider <serge@raspberrypi.com> | 2023-04-25 15:44:25 +0100 |
| commit | c16e6b7deef3ffec23ff0c6e69932c4ea83bc6fa (patch) | |
| tree | d68df8c27378cd7703723141642c8f7c467ff8a4 /build-docker.sh | |
| parent | 0defafedd4ab1b5dd3a97125b6d461eef581a7c6 (diff) | |
| parent | 47eee1f0ddcf8811559d51eea1c1bb48335e3e88 (diff) | |
Merge branch 'master' into arm64
Diffstat (limited to 'build-docker.sh')
| -rwxr-xr-x | build-docker.sh | 38 |
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 |
