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

Dave Reisner d at falconindy.com
Tue Jun 26 19:51:56 EDT 2012


On Wed, Jun 27, 2012 at 08:58:09AM +1000, Allan McRae wrote:
> 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%%://*}"

While we're here, should we catch file:// protos and return 'local' as
well? It would save the end user from having to define file:// as a
DLAGENT.

> +	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