diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/common | 17 |
1 files changed, 10 insertions, 7 deletions
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 |