summaryrefslogtreecommitdiff
path: root/archbuild
diff options
context:
space:
mode:
authorJan Steffens <jan.steffens@gmail.com>2011-03-13 19:06:27 +0100
committerJan Steffens <jan.steffens@gmail.com>2011-03-22 19:47:32 +0100
commit174ff59dba8c24f544e354cd43f3b68aea91d265 (patch)
tree08eec872ad89cdb98850082347566a975067f377 /archbuild
parent5434d3991cd51873f987bde49d55948341c09f3e (diff)
downloaddevtools32-174ff59dba8c24f544e354cd43f3b68aea91d265.tar.xz
Add flock-based locking to chroots
This prevents accidents when chroots are shared between multiple users.
Diffstat (limited to 'archbuild')
-rwxr-xr-xarchbuild13
1 files changed, 13 insertions, 0 deletions
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 \