[pacman-dev] [PATCH] makepkg patch for scp

William J. Bowman wjb at williamjbowman.com
Sat Jun 2 19:12:04 EDT 2012


Hello all,

I recently tried to specify a source URL in a PKGBUILD of the form
"scp://host:file". This caused all kinds of problem because, despite a
DLAGENT for scp existing in the default makepkg.conf, that is an invalid
URL for scp.

After a bit of discussion in #archlinux, the correct solution seemed to
be patching makepkg to seperate the protocol from the URL. So here's a
patch.

William Bowman


From 4d0b60a4108bb71835553d0aafa70ba327bac036 Mon Sep 17 00:00:00 2001
From: "William J. Bowman" <wjb at williamjbowman.com>
Date: Sat, 2 Jun 2012 17:17:18 -0400
Subject: [PATCH] Modified makepkg so DLAGENT can work with scp.
 Require %p to be specified in the DLAGENT agent string for the protocol
 to be included in the agent string, and changed the makepkg.conf to use
 it as part of the URL for all except scp.

This change is because "scp://host:file" is not a valid URL for scp.
Instead, scp expects only "host:file" (or user at host:file), without the
protocol.

Signed-off-by: William J. Bowman <wjb at williamjbowman.com>
---
 etc/makepkg.conf.in   |    8 ++++----
 scripts/makepkg.sh.in |   12 +++++++++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in
index 51df493..433fd5d 100644
--- a/etc/makepkg.conf.in
+++ b/etc/makepkg.conf.in
@@ -8,10 +8,10 @@
 #
 #-- The download utilities that makepkg should use to acquire sources
 #  Format: 'protocol::agent'
-DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
-          'http::/usr/bin/curl -b "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
-          'https::/usr/bin/curl -b "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
-          'rsync::/usr/bin/rsync --no-motd -z %u %o'
+DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %p://%u'
+          'http::/usr/bin/curl -b "" -fLC - --retry 3 --retry-delay 3 -o %o %p://%u'
+          'https::/usr/bin/curl -b "" -fLC - --retry 3 --retry-delay 3 -o %o %p://%u'
+          'rsync::/usr/bin/rsync --no-motd -z %p://%u %o'
           'scp::/usr/bin/scp -C %u %o')
 
 # Other common tools:
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 718b4e9..dccad87 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -433,6 +433,12 @@ download_file() {
 	local url=$2
 	# destination file
 	local file=$3
+
+	# To use scp, we can't have the protocol as part of the URL, so we
+	# seperate them and let the DLAGENT decide what to do with them.
+	local proto="${url%%://*}"
+	url="${url##*://}"
+
 	# temporary download file, default to last component of the URL
 	local dlfile="${url##*/}"
 
@@ -441,11 +447,15 @@ download_file() {
 		dlcmd=${dlcmd//\%o/\"$file.part\"}
 		dlfile="$file.part"
 	fi
+	# add the protocol, or don't
+	if [[ $dlcmd = *%p* ]]; then
+		dlcmd=${dlcmd//\%p/\"$proto\"}
+	fi
 	# add the URL, either in place of %u or at the end
 	if [[ $dlcmd = *%u* ]]; then
 		dlcmd=${dlcmd//\%u/\"$url\"}
 	else
-		dlcmd="$dlcmd \"$url\""
+		dlcmd="$dlcmd \"$proto://$url\""
 	fi
 
 	local ret=0
-- 
1.7.10.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp-signature.txt
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital Signature
URL: <http://mailman.archlinux.org/pipermail/pacman-dev/attachments/20120602/8a8618f9/attachment.asc>


More information about the pacman-dev mailing list