summaryrefslogtreecommitdiff
path: root/scripts/common
diff options
context:
space:
mode:
authorSerge Schneider <serge@raspberrypi.org>2016-05-05 19:39:43 +0100
committerSerge Schneider <serge@raspberrypi.org>2016-05-05 19:39:43 +0100
commit19a1b94d2a34b795e570f25708fa0ae45bcbbf38 (patch)
tree58e3a6a8728e6ee072f45a7cfa9a27138a81a33c /scripts/common
parentace01f2fc7c89cb07b1b642d359a7642f2f44f56 (diff)
parentde878cc21718bade5d7dbd19d8cdfebc0176c155 (diff)
Merge branch 'base' into dev
Diffstat (limited to 'scripts/common')
-rw-r--r--scripts/common24
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/common b/scripts/common
index 814f37f..a9d722d 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 ${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