summaryrefslogtreecommitdiff
path: root/abuild.in
diff options
context:
space:
mode:
Diffstat (limited to 'abuild.in')
-rw-r--r--abuild.in69
1 files changed, 1 insertions, 68 deletions
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() {