[buildd-tools-devel] [PATCH 06/12] [union] Cleanup union handling in scripts
Jan-Marek Glogowski
glogow at fbihome.de
Fri Jul 31 14:21:43 UTC 2009
The underlay directory should be empty after umounts, so it
should be sufficient to remove it. This won't purge content
if umount failed.
Additionally just cleanup underlay in union mode.
---
etc/setup.d/05union | 2 +-
etc/setup.d/10mount | 27 +++++++++++++++------------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/etc/setup.d/05union b/etc/setup.d/05union
index 8cc6882..4413e1b 100644
--- a/etc/setup.d/05union
+++ b/etc/setup.d/05union
@@ -60,7 +60,7 @@ if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then
# For safety, use rmdir rather than rm -rf in case
# umount failed.
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
- echo "Purging $CHROOT_UNION_UNDERLAY_DIRECTORY"
+ echo "Removing $CHROOT_UNION_UNDERLAY_DIRECTORY"
fi
if [ -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then
rmdir "${CHROOT_UNION_UNDERLAY_DIRECTORY}"
diff --git a/etc/setup.d/10mount b/etc/setup.d/10mount
index 190dd58..b0f3cd8 100755
--- a/etc/setup.d/10mount
+++ b/etc/setup.d/10mount
@@ -67,7 +67,7 @@ do_umount_all()
}
# Mount a filesystem union
-# $1: read-only branch
+# $1: the mount location
do_mount_fs_union()
{
# Prepare mount options (branch config) for union type
@@ -87,7 +87,7 @@ do_mount_fs_union()
fi
# Try mounting fs
- mount -t $CHROOT_UNION_TYPE -o "$CHROOT_UNION_MOUNT_OPTIONS" ${CHROOT_NAME} ${CHROOT_MOUNT_LOCATION}
+ mount -t $CHROOT_UNION_TYPE -o "$CHROOT_UNION_MOUNT_OPTIONS" ${CHROOT_NAME} "${1}"
}
if [ "$AUTH_VERBOSITY" = "verbose" ]; then
@@ -139,20 +139,23 @@ if [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT
# If recovering, we want to remount all filesystems to ensure
# a sane state.
- if [ $1 = "setup-recover" ]; then
- do_umount_all "$CHROOT_MOUNT_LOCATION"
+ if [ "${CREATE_UNION}" = "yes" ]; then
+ CHROOT_UNION_MOUNT_LOCATION="${CHROOT_MOUNT_LOCATION}"
+ CHROOT_MOUNT_LOCATION="${CHROOT_UNION_UNDERLAY_DIRECTORY}"
+ if [ $1 = "setup-recover" ]; then
+ do_umount_all "$CHROOT_UNION_MOUNT_LOCATION"
+ fi
fi
- if [ "$CREATE_UNION" = "yes" ]; then
- MOUNT_LOCATION="$CHROOT_UNDERLAY_DIR"
- else
- MOUNT_LOCATION="$CHROOT_MOUNT_LOCATION"
+ # If recovering, we want to remount all filesystems to ensure
+ # a sane state.
+ if [ $1 = "setup-recover" ]; then
+ do_umount_all "$CHROOT_MOUNT_LOCATION"
fi
- do_mount "$CHROOT_MOUNT_OPTIONS" "$CHROOT_MOUNT_DEVICE" "$MOUNT_LOCATION"
-
+ do_mount "$CHROOT_MOUNT_OPTIONS" "$CHROOT_MOUNT_DEVICE" "$CHROOT_MOUNT_LOCATION"
if [ "$CREATE_UNION" = "yes" ]; then
- do_mount_fs_union
+ do_mount_fs_union "$CHROOT_UNION_MOUNT_LOCATION"
fi
if [ -n "$FSTAB" ]; then
@@ -168,7 +171,7 @@ if [ "$CHROOT_TYPE" = "directory" ] || [ "$CHROOT_TYPE" = "file" ] || [ "$CHROOT
elif [ $1 = "setup-stop" ]; then
do_umount_all "$CHROOT_MOUNT_LOCATION"
- if [ "${CHROOT_UNION_TYPE:-none}" != "none" ]; then
+ if [ "${CREATE_UNION}" = "yes" ]; then
do_umount_all "$CHROOT_UNION_UNDERLAY_DIRECTORY"
fi
--
1.6.3.2
More information about the Buildd-tools-devel
mailing list