From a7a05deb37b3db6aa3606f488467f621c40ce32d Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Thu, 2 May 2013 07:03:12 +0200 Subject: 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. --- makechrootpkg.in | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'makechrootpkg.in') diff --git a/makechrootpkg.in b/makechrootpkg.in index bf4034e..c234b72 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -120,24 +120,12 @@ umask 0022 chroottype=$(stat -f -c %T "$chrootdir") # Lock the chroot we want to use. We'll keep this lock until we exit. -# Note this is the same FD number as in mkarchroot -exec 9>"$copydir.lock" -if ! flock -n 9; then - stat_busy "Locking chroot copy [$copy]" - flock 9 - stat_done -fi +lock 9 "$copydir.lock" "Locking chroot copy [$copy]" if [[ ! -d $copydir ]] || $clean_first; then # Get a read lock on the root chroot to make # sure we don't clone a half-updated chroot - exec 8>"$chrootdir/root.lock" - - if ! flock -sn 8; then - stat_busy "Locking clean chroot" - flock -s 8 - stat_done - fi + slock 8 "$chrootdir/root.lock" "Locking clean chroot" stat_busy "Creating clean working copy [$copy]" if [[ "$chroottype" == btrfs ]]; then -- cgit v1.2.3