From 174ff59dba8c24f544e354cd43f3b68aea91d265 Mon Sep 17 00:00:00 2001 From: Jan Steffens Date: Sun, 13 Mar 2011 19:06:27 +0100 Subject: Add flock-based locking to chroots This prevents accidents when chroots are shared between multiple users. --- archbuild | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'archbuild') diff --git a/archbuild b/archbuild index 7e8c456..9dd4888 100755 --- a/archbuild +++ b/archbuild @@ -36,6 +36,19 @@ fi if ${clean_first} || [ ! -d "${chroots}/${repo}-${arch}" ]; then echo "Creating chroot for [${repo}] (${arch})..." + + for copy in ${chroots}/${repo}-${arch}/*; do + [[ -d $copy ]] || continue + echo "Deleting chroot copy '$(basename "${copy}")'..." + + # Lock the copy + exec 9>${copy}.lock + flock 9 + + rm -rf ${copy} + done + exec 9>&- + rm -rf ${chroots}/${repo}-${arch} mkdir -p ${chroots}/${repo}-${arch} setarch ${arch} mkarchroot \ -- cgit v1.2.3-70-g09d2