diff options
author | Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> | 2013-05-02 07:03:12 +0200 |
---|---|---|
committer | Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> | 2013-05-03 04:34:29 +0200 |
commit | a7a05deb37b3db6aa3606f488467f621c40ce32d (patch) | |
tree | 3091e3cdfc4abb0c73c9199d5c54b6fdfbe5f1d4 /mkarchroot.in | |
parent | 0e98bd8c485b2c55c3971823f99a13c41b1ed696 (diff) | |
download | devtools-a7a05deb37b3db6aa3606f488467f621c40ce32d.tar.gz devtools-a7a05deb37b3db6aa3606f488467f621c40ce32d.tar.xz |
lib/common.sh: Introduce locking helper functions
Reduces code duplication.
With makechrootpkg not calling mkarchroot anymore,
the lock handover protocol is unneeded.
arch-nspawn does not do any locking, so add protection to archbuild.
Diffstat (limited to 'mkarchroot.in')
-rw-r--r-- | mkarchroot.in | 18 |
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" |