Merge branch 'master' into arm64

This commit is contained in:
Serge Schneider 2024-05-15 15:52:53 +01:00
commit 0755b07f06
3 changed files with 27 additions and 11 deletions

View File

@ -158,7 +158,17 @@ do
done done
term() { term() {
true; #TODO: Cleanup if [ "$?" -ne 0 ]; then
log "Build failed"
else
log "Build finished"
fi
unmount "${STAGE_WORK_DIR}"
if [ "$STAGE" = "export-image" ]; then
for img in "${STAGE_WORK_DIR}/"*.img; do
unmount_image "$img"
done
fi
} }
trap term EXIT INT TERM trap term EXIT INT TERM

View File

@ -83,7 +83,7 @@ cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
dpkg -l --root "$ROOTFS_DIR" dpkg -l --root "$ROOTFS_DIR"
} >> "$INFO_FILE" } >> "$INFO_FILE"
ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')" ROOT_DEV="$(awk "\$2 == \"${ROOTFS_DIR}\" {print \$1}" /etc/mtab)"
unmount "${ROOTFS_DIR}" unmount "${ROOTFS_DIR}"
zerofree "${ROOT_DEV}" zerofree "${ROOT_DEV}"

View File

@ -45,20 +45,26 @@ unmount(){
DIR=$1 DIR=$1
fi fi
while mount | grep -q "$DIR"; do for i in {1..6}; do
local LOCS if awk "\$2 ~ /^${DIR//\//\\/}/ {print \$2}" /etc/mtab | sort -r | xargs -r umount; then
LOCS=$(mount | grep "$DIR" | cut -f 3 -d ' ' | sort -r) break
for loc in $LOCS; do elif [ "$i" -eq 6 ]; then
umount "$loc" log "Failed to unmount ${DIR}. Do not try to delete this directory while it contains mountpoints!"
done return 1
fi
log "Retrying ($i/5)..."
sleep 1
done done
} }
export -f unmount export -f unmount
unmount_image(){ unmount_image(){
sync if command -v udevadm >/dev/null 2>&1; then
sleep 1 udevadm settle 10
LOOP_DEVICE=$(losetup --list | grep "$1" | cut -f1 -d' ') else
sleep 1
fi
LOOP_DEVICE=$(losetup -n -O NAME -j "$1")
if [ -n "$LOOP_DEVICE" ]; then if [ -n "$LOOP_DEVICE" ]; then
for part in "$LOOP_DEVICE"p*; do for part in "$LOOP_DEVICE"p*; do
if DIR=$(findmnt -n -o target -S "$part"); then if DIR=$(findmnt -n -o target -S "$part"); then