From cc5a65723c33f0458562a890692b41436ac7e837 Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Fri, 27 May 2016 11:54:56 +0100 Subject: [PATCH] Add NOOBS export support --- build.sh | 7 +++++-- scripts/common | 17 ++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 9a889f2..fe8214a 100755 --- a/build.sh +++ b/build.sh @@ -163,13 +163,16 @@ for STAGE_DIR in ${BASE_DIR}/stage*; do run_stage done -STAGE_DIR=${BASE_DIR}/export-image - CLEAN=1 for EXPORT_DIR in ${EXPORT_DIRS}; do + STAGE_DIR=${BASE_DIR}/export-image IMG_SUFFIX=$(cat ${EXPORT_DIR}/EXPORT_IMAGE) EXPORT_ROOTFS_DIR=${WORK_DIR}/$(basename ${EXPORT_DIR})/rootfs run_stage + if [ -e ${EXPORT_DIR}/EXPORT_NOOBS ]; then + STAGE_DIR=${BASE_DIR}/export-noobs + run_stage + fi done log "End ${BASE_DIR}" diff --git a/scripts/common b/scripts/common index a9d722d..6db58e2 100644 --- a/scripts/common +++ b/scripts/common @@ -4,14 +4,14 @@ log (){ export -f log bootstrap(){ - ARCH=$(dpkg --print-architecture) + local ARCH=$(dpkg --print-architecture) export http_proxy=${APT_PROXY} if [ "$ARCH" != "armhf" ]; then - BOOTSTRAP_CMD=qemu-debootstrap + local BOOTSTRAP_CMD=qemu-debootstrap else - BOOTSTRAP_CMD=debootstrap + local BOOTSTRAP_CMD=debootstrap fi ${BOOTSTRAP_CMD} --components=main,contrib,non-free \ @@ -39,7 +39,7 @@ unmount(){ fi while mount | grep -q $DIR; do - LOCS=`mount | grep $DIR | cut -f 3 -d ' ' | sort -r` + local LOCS=`mount | grep $DIR | cut -f 3 -d ' ' | sort -r` for loc in $LOCS; do umount $loc done @@ -50,9 +50,12 @@ export -f unmount unmount_image(){ sync sleep 1 - unmount $(dirname ${1}) - LOOP_DEV=$(losetup -j ${1} | cut -f1 -d':') + local LOOP_DEV=$(losetup -j ${1} | cut -f1 -d':') if [ -n "${LOOP_DEV}" ]; then + local MOUNTED_DIR=$(mount | grep $(basename ${LOOP_DEV} | head -n 1 | cut -f 3 -d ' ')) + if [ -n "${MOUNTED_DIR}" ]; then + unmount $(dirname ${MOUNTED_DIR}) + fi sleep 1 kpartx -ds ${LOOP_DEV} losetup -d ${LOOP_DEV} @@ -82,7 +85,7 @@ on_chroot() { export -f on_chroot update_issue() { - GIT_HASH=$(git rev-parse HEAD) + local GIT_HASH=$(git rev-parse HEAD) echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue } export -f update_issue