[pacman-dev] [PATCH 03/11] makepkg: add function to return download protocol

Allan McRae allan at archlinux.org
Tue Jun 26 18:58:09 EDT 2012


Extract the download protocol from a source entry.  Returns "local"
for local source files.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 scripts/makepkg.sh.in | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 4299816..0d87cba 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -222,6 +222,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
-- 
1.7.11.1



More information about the pacman-dev mailing list