summaryrefslogtreecommitdiff
path: root/mkarchroot.in
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-06-15 11:20:37 -0600
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-06-15 11:20:37 -0600
commita8c95177c7f9bab8cb7e697c6e925b2fb1c5d342 (patch)
treeed43f04c4e2aaab033aba23fae4ead687555ca9b /mkarchroot.in
parenta7ee45d6259e84628599f721abc297f935504fee (diff)
parenta7a05deb37b3db6aa3606f488467f621c40ce32d (diff)
Merge commit 'a7a0': merge our and their lock functions
Arch's have shorter names, and properly escape the filename. Ours create the directories, and check if the locks are already open. The best of both worlds. When merging the usages of them, I used arch's messages. Ours are too long, even if they are more informative.
Diffstat (limited to 'mkarchroot.in')
-rw-r--r--mkarchroot.in18
1 files changed, 1 insertions, 17 deletions
diff --git a/mkarchroot.in b/mkarchroot.in
index 68db64c..970bbb9 100644
--- a/mkarchroot.in
+++ b/mkarchroot.in
@@ -49,29 +49,13 @@ else
cache_dirs=(${cache_dir})
fi
-# {{{ functions
-chroot_lock () {
- # Only reopen the FD if it wasn't handed to us
- if [[ $(readlink -f /dev/fd/9) != "${working_dir}.lock" ]]; then
- exec 9>"${working_dir}.lock"
- fi
-
- # Lock the chroot. Take note of the FD number.
- if ! flock -n 9; then
- stat_busy "Locking chroot"
- flock 9
- stat_done
- fi
-}
-# }}}
-
umask 0022
[[ -e $working_dir ]] && die "Working directory '$working_dir' already exists"
mkdir -p "$working_dir"
-chroot_lock
+lock 9 "${working_dir}.lock" "Locking chroot"
if [[ $(stat -f -c %T "$working_dir") == btrfs ]]; then
rmdir "$working_dir"