diff --git a/README.md b/README.md index 461c10c8..cba647e5 100644 --- a/README.md +++ b/README.md @@ -192,6 +192,11 @@ Conform to the following conventions: If they both use set -e and cp -n then the conflict will be caught and cause the build to fail. +* If your element mounts anything into the image build tree ($TMP\_BUILD\_DIR) + then it will be automatically unmounted when the build tree is unmounted - + and not remounted into the filesystem image - if the mount point is needed + again, your element will need to remount it at that point. + Make as many of the following subdirectories as you need, depending on what part of the process you need to customise: diff --git a/elements/base/finalise.d/02-remove-ccache b/elements/base/finalise.d/02-remove-ccache new file mode 100755 index 00000000..b550f726 --- /dev/null +++ b/elements/base/finalise.d/02-remove-ccache @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +rmdir /tmp/ccache || true diff --git a/lib/img-functions b/lib/img-functions index 40844d64..845e3261 100644 --- a/lib/img-functions +++ b/lib/img-functions @@ -16,16 +16,14 @@ function unmount_image () { # unmount from the chroot # Don't use TMP_MOUNT_PATH here, it might not have been set. - sudo umount -f $TMP_BUILD_DIR/mnt/sys || true - sudo umount -f $TMP_BUILD_DIR/mnt/proc || true - sudo umount -f $TMP_BUILD_DIR/mnt/dev || true - sudo umount -f $TMP_BUILD_DIR/mnt/tmp/in_target.d || true - sudo umount -f $TMP_BUILD_DIR/mnt/tmp/ccache || true + local MOUNTS + MOUNTS=$(grep < /proc/mounts " $TMP_BUILD_DIR/mnt" | awk '{ print $2 }' | sort -r) + for M in $MOUNTS; do + sudo umount -f $M || true + done # give it a second (ok really 5) to umount XXX - why? should instead track # the mount data / lsof etc. sleep 5 - # oh ya don't want to forget to unmount the image - sudo umount -f $TMP_BUILD_DIR/mnt || true # having disk corruption issues; one possibility is qemu-nbd not flushing # dirty pages on disconnect? sync @@ -84,8 +82,6 @@ function run_d_in_target () { check_break after-$1 run_in_target bash sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d sudo rmdir $TMP_MOUNT_PATH/tmp/in_target.d - sudo umount -f $TMP_MOUNT_PATH/tmp/ccache || true - sudo rmdir $TMP_MOUNT_PATH/tmp/ccache fi }