diff options
| author | Serge Schneider <serge@raspberrypi.org> | 2016-05-27 11:55:26 +0100 |
|---|---|---|
| committer | Serge Schneider <serge@raspberrypi.org> | 2016-05-27 11:55:26 +0100 |
| commit | 062af361c8cdf598fd198aa27e35a35d64bdf9a4 (patch) | |
| tree | 92ee2c85b2a51e2bb2cd5fdcfcc801abbd24bc64 /scripts | |
| parent | 96bb138c83d16578f2f7511b80908cf0110c53ec (diff) | |
| parent | cc5a65723c33f0458562a890692b41436ac7e837 (diff) | |
Merge branch 'base' into dev
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 |
