Cleanup mount points automatically.
Manually listing the mount points that need cleanup is not maintainable and makes it hard to write elements that use bind mounting to inject resources into the build environment. Change-Id: I7c9ade444f4ebe42552f8e321f257a7ec0a674ef
This commit is contained in:
parent
a5806cd482
commit
c7d80ddeed
@ -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
|
If they both use set -e and cp -n then the conflict will be caught and cause
|
||||||
the build to fail.
|
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
|
Make as many of the following subdirectories as you need, depending on what
|
||||||
part of the process you need to customise:
|
part of the process you need to customise:
|
||||||
|
|
||||||
|
4
elements/base/finalise.d/02-remove-ccache
Executable file
4
elements/base/finalise.d/02-remove-ccache
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
rmdir /tmp/ccache || true
|
@ -16,16 +16,14 @@
|
|||||||
function unmount_image () {
|
function unmount_image () {
|
||||||
# unmount from the chroot
|
# unmount from the chroot
|
||||||
# Don't use TMP_MOUNT_PATH here, it might not have been set.
|
# Don't use TMP_MOUNT_PATH here, it might not have been set.
|
||||||
sudo umount -f $TMP_BUILD_DIR/mnt/sys || true
|
local MOUNTS
|
||||||
sudo umount -f $TMP_BUILD_DIR/mnt/proc || true
|
MOUNTS=$(grep < /proc/mounts " $TMP_BUILD_DIR/mnt" | awk '{ print $2 }' | sort -r)
|
||||||
sudo umount -f $TMP_BUILD_DIR/mnt/dev || true
|
for M in $MOUNTS; do
|
||||||
sudo umount -f $TMP_BUILD_DIR/mnt/tmp/in_target.d || true
|
sudo umount -f $M || true
|
||||||
sudo umount -f $TMP_BUILD_DIR/mnt/tmp/ccache || true
|
done
|
||||||
# give it a second (ok really 5) to umount XXX - why? should instead track
|
# give it a second (ok really 5) to umount XXX - why? should instead track
|
||||||
# the mount data / lsof etc.
|
# the mount data / lsof etc.
|
||||||
sleep 5
|
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
|
# having disk corruption issues; one possibility is qemu-nbd not flushing
|
||||||
# dirty pages on disconnect?
|
# dirty pages on disconnect?
|
||||||
sync
|
sync
|
||||||
@ -84,8 +82,6 @@ function run_d_in_target () {
|
|||||||
check_break after-$1 run_in_target bash
|
check_break after-$1 run_in_target bash
|
||||||
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
|
sudo umount -f $TMP_MOUNT_PATH/tmp/in_target.d
|
||||||
sudo rmdir $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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user