summaryrefslogtreecommitdiff
path: root/archbuild.in
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-11-25 20:05:09 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-11-25 20:28:14 -0500
commite9836b6b2afa70f22d305509593b375543b20ba6 (patch)
tree9695c79202bb58c4014033f98a0021790f49817e /archbuild.in
parent2343d5c3c034c2597a034f5a5de9373d7e076e60 (diff)
downloaddevtools-e9836b6b2afa70f22d305509593b375543b20ba6.tar.xz
Use common functions to handle file locking
* lib/common.sh: implement - lock_open_write() - lock_open_read() - lock_close() * archbuild.in, makechrootpkg.in, mkarchroot.in: use said functions This has two benefits: 1. All programs using these methods gain the ability to inherit locks, something that only mkarchroot could do before. This allows the commands to be more compos-able. 2. It is more readable. File locking isn't obvious.
Diffstat (limited to 'archbuild.in')
-rw-r--r--archbuild.in9
1 files changed, 2 insertions, 7 deletions
diff --git a/archbuild.in b/archbuild.in
index 7220391..9476415 100644
--- a/archbuild.in
+++ b/archbuild.in
@@ -43,17 +43,12 @@ if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
[[ -d $copy ]] || continue
msg2 "Deleting chroot copy '$(basename "${copy}")'..."
- exec 9>"$copy.lock"
- if ! flock -n 9; then
- stat_busy "Locking chroot copy '$copy'"
- flock 9
- stat_done
- fi
+ lock_open_write 9 "$copy.lock" "Locking chroot copy '$copy'"
{ type -P btrfs && btrfs subvolume delete "${copy}"; } &>/dev/null
rm -rf --one-file-system "${copy}"
done
- exec 9>&-
+ lock_close 9
rm -rf --one-file-system "${chroots}/${repo}-${arch}"
mkdir -p "${chroots}/${repo}-${arch}"