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.
This commit is contained in:
Natanael Copa 2013-02-20 13:38:22 +00:00
parent e23f733ad9
commit a3fc9a056f

View File

@ -193,11 +193,12 @@ default_sanitycheck() {
warning "You should not have \$install in source" warning "You should not have \$install in source"
continue continue
fi fi
list_has ${i##*/} $md5sums $sha256sums $sha512sums \
|| die "${i##*/} is missing in checksums"
case "$i" in case "$i" in
*::*) i=${i%%::*};;
https://*) makedepends_has wget && warning "wget no longer need to be in makedepends when source has https://" ;; https://*) makedepends_has wget && warning "wget no longer need to be in makedepends when source has https://" ;;
esac esac
list_has ${i##*/} $md5sums $sha256sums $sha512sums \
|| die "${i##*/} is missing in checksums"
done done
fi fi
@ -294,6 +295,9 @@ sourcecheck() {
uri=${uri#saveas-} uri=${uri#saveas-}
uri=${uri%/*} uri=${uri%/*}
;; ;;
*::*)
uri=${uri##*::}
;;
esac esac
wget -q -s "$uri" || return 1 wget -q -s "$uri" || return 1
done done
@ -330,6 +334,11 @@ uri_fetch() {
# remove 'saveas-' from beginning and # remove 'saveas-' from beginning and
# '/filename' from end of URI # '/filename' from end of URI
saveas-*://*) uri="${uri:7:$(expr ${#uri} - 7 - ${#d} - 1)}";; saveas-*://*) uri="${uri:7:$(expr ${#uri} - 7 - ${#d} - 1)}";;
*::*)
d=${uri%%::*}
uri=${uri#$d::}
;;
esac esac
case "$uri" in case "$uri" in
@ -371,22 +380,32 @@ uri_fetch() {
} }
is_remote() { is_remote() {
case "$1" in case "${1#*::}" in
http://*|ftp://*|https://*|saveas-*://*) http://*|ftp://*|https://*|saveas-*://*)
return 0;; return 0;;
esac esac
return 1 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 # try download from file from mirror first
uri_fetch_mirror() { uri_fetch_mirror() {
local uri="$1" local uri="$1"
local d="${uri##*/}" # $(basename $uri)
if [ -n "$DISTFILES_MIRROR" ]; then if [ -n "$DISTFILES_MIRROR" ]; then
if is_remote "$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 else
cp "$DISTFILES_MIRROR"/$d "$SRCDEST" && return 0 cp "$DISTFILES_MIRROR"/$(filename_from_uri $uri) \
"$SRCDEST" && return 0
fi fi
fi fi
uri_fetch "$uri" uri_fetch "$uri"
@ -398,7 +417,7 @@ default_fetch() {
for s in $source; do for s in $source; do
if is_remote "$s"; then if is_remote "$s"; then
uri_fetch_mirror "$s" || return 1 uri_fetch_mirror "$s" || return 1
ln -sf "$SRCDEST/${s##*/}" "$srcdir"/ ln -sf "$SRCDEST/$(filename_from_uri $s)" "$srcdir"/
else else
ln -sf "$startdir/$s" "$srcdir/" ln -sf "$startdir/$s" "$srcdir/"
fi fi
@ -433,7 +452,7 @@ default_unpack() {
fi fi
mkdir -p "$srcdir" mkdir -p "$srcdir"
for u in $source; do for u in $source; do
local s="$SRCDEST/${u##*/}" # $(basename $s) local s="$SRCDEST/$(filename_from_uri $u)"
case "$s" in case "$s" in
*.tar) *.tar)
msg "Unpacking $s..." msg "Unpacking $s..."
@ -474,8 +493,9 @@ cleancache() {
local s local s
for s in $source; do for s in $source; do
if is_remote "$s"; then if is_remote "$s"; then
msg "Cleaning downloaded ${s##*/}..." s=$(filename_from_uri $s)
rm -f "$SRCDEST/${s##*/}" msg "Cleaning downloaded $s ..."
rm -f "$SRCDEST/$s"
fi fi
done done
} }
@ -1286,7 +1306,7 @@ srcpkg() {
local prefix="${startdir##*/}" local prefix="${startdir##*/}"
local i files="$prefix/APKBUILD" local i files="$prefix/APKBUILD"
for i in $source; do for i in $source; do
files="$files $prefix/${i##*/}" files="$files $prefix/$(filename_from uri $i)"
done done
mkdir -p "$PKGDEST" mkdir -p "$PKGDEST"
msg "Creating source package $p.src.tar.gz..." msg "Creating source package $p.src.tar.gz..."
@ -1312,7 +1332,7 @@ apk_up2date() {
for i in $source APKBUILD; do for i in $source APKBUILD; do
local s local s
if is_remote "$i"; then if is_remote "$i"; then
s="$SRCDEST/${i##*/}" # $(basename $i) s="$SRCDEST/$(filename_from_uri $i)"
else else
s="$startdir/${i##*/}" s="$startdir/${i##*/}"
fi fi
@ -1519,7 +1539,7 @@ checksum() {
[ -z "$source" ] && return 0 [ -z "$source" ] && return 0
fetch fetch
for s in $source; do for s in $source; do
files="$files ${s##*/}" files="$files $(filename_from_uri $s)"
done done
# for compatibility/backporting reasons we still add md5sum # for compatibility/backporting reasons we still add md5sum
@ -1563,6 +1583,7 @@ source_has() {
local i local i
for i in $source; do for i in $source; do
[ "$1" = "${i##*/}" ] && return 0 [ "$1" = "${i##*/}" ] && return 0
[ "$1" = "${i%%::*}" ] && return 0
done done
return 1 return 1
} }