diff options
Diffstat (limited to 'main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch')
-rw-r--r-- | main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch | 69 |
1 files changed, 48 insertions, 21 deletions
diff --git a/main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch b/main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch index b749f30769..336a44092c 100644 --- a/main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch +++ b/main/abuild/0001-abuild-fix-fetch-lock-file-on-nfs.patch @@ -1,4 +1,4 @@ -From 7479ed1efcd4ac1f5cc93aa65352f6a25bcbf218 Mon Sep 17 00:00:00 2001 +From 92186b70ca9c520fc726e0885aac633aadace655 Mon Sep 17 00:00:00 2001 From: Natanael Copa <ncopa@alpinelinux.org> Date: Wed, 26 Aug 2015 08:14:36 +0200 Subject: [PATCH] abuild: fix fetch lock file on nfs @@ -12,9 +12,9 @@ We fix this by creating a small abuild-fetch application that will create a POSIX lock which works with NFS. --- Makefile | 6 +- - abuild-fetch.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - abuild.in | 47 +-------------- - 3 files changed, 190 insertions(+), 47 deletions(-) + abuild-fetch.c | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + abuild.in | 69 +------------------- + 3 files changed, 200 insertions(+), 69 deletions(-) create mode 100644 abuild-fetch.c diff --git a/Makefile b/Makefile @@ -50,10 +50,10 @@ index 81c2851..b7332b2 100644 diff --git a/abuild-fetch.c b/abuild-fetch.c new file mode 100644 -index 0000000..89d914f +index 0000000..51b41eb --- /dev/null +++ b/abuild-fetch.c -@@ -0,0 +1,184 @@ +@@ -0,0 +1,194 @@ +/* MIT license + +Copyright (C) 2015 Natanael Copa <ncopa@alpinelinux.org> @@ -114,7 +114,7 @@ index 0000000..89d914f + int lockfd, status=0; + pid_t childpid; + char outfile[PATH_MAX], partfile[PATH_MAX]; -+ char *name; ++ char *name, *p; + struct flock fl = { + .l_type = F_WRLCK, + .l_whence = SEEK_SET, @@ -129,11 +129,23 @@ index 0000000..89d914f + .argc = 3, + .argv = { "wget", "-O", partfile, NULL } + }; ++ + name = strrchr(url, '/'); + if (name == NULL) + errx(1, "%s: no '/' in url"); ++ p = strstr(url, "::"); ++ if (p != NULL) { ++ name = url; ++ *p = '\0'; ++ url = p + 2; ++ } else if (strstr(url, "saveas-") == url) { ++ *name++ = '\0'; ++ url += 7; /* strlen("saveas-") */ ++ } else { ++ name++; ++ } + -+ snprintf(outfile, sizeof(outfile), "%s%s", destdir, name); ++ snprintf(outfile, sizeof(outfile), "%s/%s", destdir, name); + snprintf(lockfile, sizeof(lockfile), "%s.lock", outfile); + snprintf(partfile, sizeof(partfile), "%s.part", outfile); + @@ -147,10 +159,8 @@ index 0000000..89d914f + err(1, "fcntl(F_SETLKW)"); + } + -+ if (access(outfile, F_OK) == 0) { -+ printf("%s already exist. skipping\n", outfile); ++ if (access(outfile, F_OK) == 0) + goto fetch_done; -+ } + + if (access(partfile, F_OK) == 0) { + printf("Partial download found. Trying to resume.\n"); @@ -239,10 +249,10 @@ index 0000000..89d914f + return r; +} diff --git a/abuild.in b/abuild.in -index b8d8851..6e96187 100644 +index b8d8851..952048b 100644 --- a/abuild.in +++ b/abuild.in -@@ -298,23 +298,6 @@ sourcecheck() { +@@ -298,79 +298,12 @@ sourcecheck() { return 0 } @@ -265,18 +275,31 @@ index b8d8851..6e96187 100644 - uri_fetch() { local uri="$1" - local d="${uri##*/}" # $(basename $uri) -@@ -335,38 +318,10 @@ uri_fetch() { - ;; - esac +- 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" +- +- CLEANUP_FILES="$CLEANUP_FILES $lockfile" - ( - flock -n -x 9 || msg "Waiting for ${lockfile##*/}..." - flock -x 9 @@ -302,10 +325,14 @@ index b8d8851..6e96187 100644 - && mv "$SRCDEST/$d.part" "$SRCDEST/$d" - - ) 9>$lockfile +- +- local rc=$? +- rm -f "$lockfile" +- return $rc + abuild-fetch -d "$SRCDEST" "$uri" + } - local rc=$? - rm -f "$lockfile" + is_remote() { -- 2.5.0 |