Various fixes

This commit is contained in:
Serge Schneider
2016-05-04 15:51:41 +01:00
parent 612c1a73f1
commit aca321fd70
3 changed files with 46 additions and 11 deletions

View File

@@ -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