From 92186b70ca9c520fc726e0885aac633aadace655 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 26 Aug 2015 08:14:36 +0200 Subject: abuild: fix fetch lock file on nfs flock(2) on an NFS mount will on the server side convert the lock to a POSIX lock (fcntl(F_SETLK)). This means that abuild running on NFS server and client will create different locks and they will both try download same file at same time. We fix this by creating a small abuild-fetch application that will create a POSIX lock which works with NFS. --- abuild.in | 69 +-------------------------------------------------------------- 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'abuild.in') diff --git a/abuild.in b/abuild.in index b8d8851..952048b 100644 --- a/abuild.in +++ b/abuild.in @@ -298,79 +298,12 @@ sourcecheck() { return 0 } -# convert curl options to wget options and call wget instead of curl -wget_fallback() { - local wget_opts= outfile= opt= - while getopts "C:Lko:s" opt; do - case $opt in - 'L') ;; # --location. wget does this by default - 'f') ;; # --fail. wget does this by default - 'C') wget_opts="$wget_opts -c";; # --continue-at - 's') wget_opts="$wget_opts -q";; # --silent - 'o') wget_opts="$wget_opts -O $OPTARG";; # --output - 'k') wget_opts="$wget_opts --no-check-certificate";; #gnu wget - esac - done - shift $(( $OPTIND - 1 )) - wget $wget_opts "$1" -} - uri_fetch() { local uri="$1" - local d="${uri##*/}" # $(basename $uri) - local opts [ -n "$quiet" ] && opts="-s" - local lockfile="$SRCDEST/$d".lock - - # fix saveas-*://* URIs - case "$uri" in - # remove 'saveas-' from beginning and - # '/filename' from end of URI - saveas-*://*) uri="${uri:7:$(expr ${#uri} - 7 - ${#d} - 1)}";; - - *::*) - d=${uri%%::*} - uri=${uri#$d::} - ;; - esac - - case "$uri" in - https://*) opts="-k";; - esac - mkdir -p "$SRCDEST" - - CLEANUP_FILES="$CLEANUP_FILES $lockfile" - ( - flock -n -x 9 || msg "Waiting for ${lockfile##*/}..." - flock -x 9 - - [ -f "$SRCDEST/$d" ] && exit 0 # use exit since its a subshell - - if [ -f "$SRCDEST/$d.part" ]; then - msg "Partial download found. Trying to resume" - opts="$opts -C -" - fi - msg "Fetching $uri" - - # fallback to wget if curl is missing. useful for bootstrapping - local fetcher= - if ! [ -x "$(which curl)" ]; then - fetcher=wget_fallback - else - fetcher=curl - opts="$opts -L -f -k" - fi - - $fetcher $opts -o "$SRCDEST/$d.part" "$uri" \ - && mv "$SRCDEST/$d.part" "$SRCDEST/$d" - - ) 9>$lockfile - - local rc=$? - rm -f "$lockfile" - return $rc + abuild-fetch -d "$SRCDEST" "$uri" } is_remote() { -- cgit v1.2.3-60-g2f50