From a3fc9a056f4382743ad8c3af011f11774e0ed9bd Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 20 Feb 2013 13:38:22 +0000 Subject: [PATCH] abuild: support filename::fileuri in source This is an alternative to saveas-*:// which should be slightly more intuitive. It also is similar to what arch linux does. --- abuild.in | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/abuild.in b/abuild.in index d6951ba..185a9a3 100755 --- a/abuild.in +++ b/abuild.in @@ -193,11 +193,12 @@ default_sanitycheck() { warning "You should not have \$install in source" continue fi - list_has ${i##*/} $md5sums $sha256sums $sha512sums \ - || die "${i##*/} is missing in checksums" case "$i" in + *::*) i=${i%%::*};; https://*) makedepends_has wget && warning "wget no longer need to be in makedepends when source has https://" ;; esac + list_has ${i##*/} $md5sums $sha256sums $sha512sums \ + || die "${i##*/} is missing in checksums" done fi @@ -294,6 +295,9 @@ sourcecheck() { uri=${uri#saveas-} uri=${uri%/*} ;; + *::*) + uri=${uri##*::} + ;; esac wget -q -s "$uri" || return 1 done @@ -330,6 +334,11 @@ uri_fetch() { # 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 @@ -371,22 +380,32 @@ uri_fetch() { } is_remote() { - case "$1" in + case "${1#*::}" in http://*|ftp://*|https://*|saveas-*://*) return 0;; esac return 1 } +filename_from_uri() { + local uri="$1" + local filename="${uri##*/}" # $(basename $uri) + case "$uri" in + *::*) filename=${uri%%::*};; + esac + echo "$filename" +} + # try download from file from mirror first uri_fetch_mirror() { local uri="$1" - local d="${uri##*/}" # $(basename $uri) if [ -n "$DISTFILES_MIRROR" ]; then if is_remote "$DISTFILES_MIRROR"; then - uri_fetch "$DISTFILES_MIRROR"/$d && return 0 + uri_fetch "$DISTFILES_MIRROR"/$(filename_from_uri $uri)\ + && return 0 else - cp "$DISTFILES_MIRROR"/$d "$SRCDEST" && return 0 + cp "$DISTFILES_MIRROR"/$(filename_from_uri $uri) \ + "$SRCDEST" && return 0 fi fi uri_fetch "$uri" @@ -398,7 +417,7 @@ default_fetch() { for s in $source; do if is_remote "$s"; then uri_fetch_mirror "$s" || return 1 - ln -sf "$SRCDEST/${s##*/}" "$srcdir"/ + ln -sf "$SRCDEST/$(filename_from_uri $s)" "$srcdir"/ else ln -sf "$startdir/$s" "$srcdir/" fi @@ -433,7 +452,7 @@ default_unpack() { fi mkdir -p "$srcdir" for u in $source; do - local s="$SRCDEST/${u##*/}" # $(basename $s) + local s="$SRCDEST/$(filename_from_uri $u)" case "$s" in *.tar) msg "Unpacking $s..." @@ -474,8 +493,9 @@ cleancache() { local s for s in $source; do if is_remote "$s"; then - msg "Cleaning downloaded ${s##*/}..." - rm -f "$SRCDEST/${s##*/}" + s=$(filename_from_uri $s) + msg "Cleaning downloaded $s ..." + rm -f "$SRCDEST/$s" fi done } @@ -1286,7 +1306,7 @@ srcpkg() { local prefix="${startdir##*/}" local i files="$prefix/APKBUILD" for i in $source; do - files="$files $prefix/${i##*/}" + files="$files $prefix/$(filename_from uri $i)" done mkdir -p "$PKGDEST" msg "Creating source package $p.src.tar.gz..." @@ -1312,7 +1332,7 @@ apk_up2date() { for i in $source APKBUILD; do local s if is_remote "$i"; then - s="$SRCDEST/${i##*/}" # $(basename $i) + s="$SRCDEST/$(filename_from_uri $i)" else s="$startdir/${i##*/}" fi @@ -1519,7 +1539,7 @@ checksum() { [ -z "$source" ] && return 0 fetch for s in $source; do - files="$files ${s##*/}" + files="$files $(filename_from_uri $s)" done # for compatibility/backporting reasons we still add md5sum @@ -1563,6 +1583,7 @@ source_has() { local i for i in $source; do [ "$1" = "${i##*/}" ] && return 0 + [ "$1" = "${i%%::*}" ] && return 0 done return 1 }