From a922d1805696b6614649a8d3588297d44f4e1192 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 4 Jun 2012 09:02:03 +1000 Subject: makepkg: add function to return download protocol Extract the download protocol from a source entry. Returns "local" for local source files. Signed-off-by: Allan McRae --- scripts/makepkg.sh.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 4cafa945..fe0c0684 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -224,6 +224,17 @@ get_url() { printf "%s\n" "${1#*::}" } +# extract the protocol from a source entry - return "local" for local sources +get_protocol() { + if [[ $1 = *://* ]]; then + # strip leading filename + local proto="${1##*::}" + printf "%s\n" "${proto%%://*}" + else + printf "%s\n" local + fi +} + get_downloadclient() { # $1 = URL with valid protocol prefix local url=$1 -- cgit v1.2.3