From aca321fd700deaa0ef36b03ead65661bd654f61c Mon Sep 17 00:00:00 2001 From: Serge Schneider Date: Wed, 4 May 2016 15:51:41 +0100 Subject: Various fixes --- scripts/common | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/common b/scripts/common index 814f37f..e2969ad 100644 --- a/scripts/common +++ b/scripts/common @@ -1,6 +1,7 @@ log (){ date +"[%T] $@" | tee -a ${LOG_FILE} } +export -f log bootstrap(){ ARCH=$(dpkg --print-architecture) @@ -18,6 +19,7 @@ bootstrap(){ --no-check-gpg \ $1 $2 $3 } +export -f bootstrap copy_previous(){ if [ ! -d ${PREV_ROOTFS_DIR} ]; then @@ -27,6 +29,7 @@ copy_previous(){ mkdir -p ${ROOTFS_DIR} rsync -aHAX ${PREV_ROOTFS_DIR}/ ${ROOTFS_DIR}/ } +export -f copy_previous unmount(){ if [ -z "$1" ]; then @@ -38,10 +41,24 @@ unmount(){ while mount | grep -q $DIR; do LOCS=`mount | grep $DIR | cut -f 3 -d ' ' | sort -r` for loc in $LOCS; do - sudo umount $loc + umount $loc done done } +export -f unmount + +unmount_image(){ + sync + sleep 1 + unmount $(dirname ${1}) + LOOP_DEV=$(losetup -j ${1} | cut -f1 -d':') + if [ -n "${LOOP_DEV}" ]; then + sleep 1 + kpartx -ds ${LOOP_DEV} + losetup -d ${LOOP_DEV} + fi +} +export -f unmount_image on_chroot() { if ! mount | grep -q `realpath ${ROOTFS_DIR}/proc`; then @@ -62,7 +79,10 @@ on_chroot() { chroot ${ROOTFS_DIR}/ "$@" } +export -f on_chroot update_issue() { - echo -e "Raspberry Pi reference ${DATE}\nGenerated using Pi-gen, https://github.com/RPi-Distro/Pi-gen, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue + GIT_HASH=$(git rev-parse HEAD) + echo -e "Raspberry Pi reference ${DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > ${ROOTFS_DIR}/etc/rpi-issue } +export -f update_issue -- cgit v1.2.3