diff options
author | Serge Schneider <[email protected]> | 2016-05-04 15:51:41 +0100 |
---|---|---|
committer | Serge Schneider <[email protected]> | 2016-05-04 19:52:13 +0100 |
commit | aca321fd700deaa0ef36b03ead65661bd654f61c (patch) | |
tree | 465413e2d1d05fede66a9dc9fdd9b1e7a90633e9 /scripts | |
parent | 612c1a73f1cb2184639163d0e37e303b70f5f7bc (diff) |
Various fixes
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/common | 24 |
1 files changed, 22 insertions, 2 deletions
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 |