diff --git a/build.sh b/build.sh index dc2697c..f051727 100755 --- a/build.sh +++ b/build.sh @@ -123,6 +123,20 @@ run_stage(){ log "End ${STAGE_DIR}" } +term() { + if [ "$?" -ne 0 ]; then + log "Build failed" + else + log "Build finished" + fi + unmount "${STAGE_WORK_DIR}" + if [ "$STAGE" = "export-image" ]; then + for img in "${STAGE_WORK_DIR}/"*.img; do + unmount_image "$img" + done + fi +} + if [ "$(id -u)" != "0" ]; then echo "Please run as root" 1>&2 exit 1 @@ -157,22 +171,6 @@ do esac done -term() { - if [ "$?" -ne 0 ]; then - log "Build failed" - else - log "Build finished" - fi - unmount "${STAGE_WORK_DIR}" - if [ "$STAGE" = "export-image" ]; then - for img in "${STAGE_WORK_DIR}/"*.img; do - unmount_image "$img" - done - fi -} - -trap term EXIT INT TERM - export PI_GEN=${PI_GEN:-pi-gen} export PI_GEN_REPO=${PI_GEN_REPO:-https://github.com/RPi-Distro/pi-gen} export PI_GEN_RELEASE=${PI_GEN_RELEASE:-Raspberry Pi reference} @@ -252,6 +250,9 @@ if [ "$SETFCAP" != "1" ]; then export CAPSH_ARG="--drop=cap_setfcap" fi +mkdir -p "${WORK_DIR}" +trap term EXIT INT TERM + dependencies_check "${BASE_DIR}/depends" echo "Checking native $ARCH executable support..." @@ -259,6 +260,13 @@ 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." + PAGESIZE=$(getconf PAGESIZE) + if [ "$ARCH" == "armhf" ] && [ "$PAGESIZE" != "4096" ]; then + echo + echo "Building an $ARCH image requires a kernel with a 4k page size" + echo "Current pagesize: $PAGESIZE" + echo "On Raspberry Pi OS, you can switch to a suitable kernel by adding kernel=kernel8.img to /boot/firmware/config.txt and rebooting" + fi exit 1 fi fi @@ -295,7 +303,6 @@ if [[ "${PUBKEY_ONLY_SSH}" = "1" && -z "${PUBKEY_SSH_FIRST_USER}" ]]; then exit 1 fi -mkdir -p "${WORK_DIR}" log "Begin ${BASE_DIR}" STAGE_LIST=${STAGE_LIST:-${BASE_DIR}/stage*}