Commit 9c817b65 authored by Eli Schwartz's avatar Eli Schwartz Committed by Allan McRae
Browse files

libmakepkg: implement extendable source protocols



Lookup the existence of matching functions for each protocol, and
fallback on the generic file handler. New source protocols can then be
added via thirdparty libmakepkg drop-ins without requiring modifications
to source.sh

Fixes FS#49076

Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
parent ac0e21a6
......@@ -59,26 +59,11 @@ download_sources() {
pushd "$SRCDEST" &>/dev/null
local proto=$(get_protocol "$netfile")
case "$proto" in
local)
download_local "$netfile"
;;
bzr)
(( get_vcs )) && download_bzr "$netfile"
;;
git)
(( get_vcs )) && download_git "$netfile"
;;
hg)
(( get_vcs )) && download_hg "$netfile"
;;
svn)
(( get_vcs )) && download_svn "$netfile"
;;
*)
download_file "$netfile"
;;
esac
if declare -f download_$proto > /dev/null; then
download_$proto "$netfile"
else
download_file "$netfile"
fi
popd &>/dev/null
done
......@@ -92,22 +77,10 @@ extract_sources() {
for netfile in "${all_sources[@]}"; do
local file=$(get_filename "$netfile")
local proto=$(get_protocol "$netfile")
case "$proto" in
bzr)
extract_bzr "$netfile"
;;
git)
extract_git "$netfile"
;;
hg)
extract_hg "$netfile"
;;
svn)
extract_svn "$netfile"
;;
*)
extract_file "$file"
;;
esac
if declare -f extract_$proto > /dev/null; then
extract_$proto "$netfile"
else
extract_file "$file"
fi
done
}
......@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_bzr() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local url=$(get_url "$netfile")
......
......@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_git() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")
......
......@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_hg() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local dir=$(get_filepath "$netfile")
......
......@@ -29,6 +29,11 @@ source "$LIBRARY/util/pkgbuild.sh"
download_svn() {
# abort early if parent says not to fetch
if declare -p get_vcs > /dev/null 2>&1; then
(( get_vcs )) || return
fi
local netfile=$1
local fragment=${netfile#*#}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment