This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] cygport-0.2.9 mixed-mode SRC_URIs


Forward port to latest release.

For further history and justifiation of this patch, see http://cygwin.com/ml/cygwin/2007-01/msg00111.html and follow the embedded links and threads.

--
Chuck

2007-02-05 Charles Wilson <...>

	* bin/cygport.in (src_fetch_auto): new function refactored from
	src_fetch(). Autodetects protocol of passed-in URI
	(mirror|http|https|ftp) and errors if a protocol is specified
	but is not recognized.  URIs with no protocol specification
	are silently ignored (e.g. not downloaded).
	(src_fetch): call src_fetch_auto for 2nd..Nth SRC_URI and all
	PATCH_URIs regardless of protocol used for the first SRC_URI
	(cvs|svn|git|mirror|http|https|ftp).  If !(cvs|svn|git), call
	src_fetch_auto for first SRC_URI as well.

	* lib/cvs.cygclass: extract first name from SRC_URI and use that
	to generate tarball name. Ensure that working directory is
	unchanged by a call to cvs_fetch.
	* lib/svn.cygclass: extract first name from SRC_URI and use that
	to generate tarball name. Ensure that working directory is
	unchanged by a call to svn_fetch.
	* lib/git.cygclass: extract first name from SRC_URI and use that
	to generate tarball name. Ensure that working directory is
	unchanged by a call to git_fetch.

Index: bin/cygport.in
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v
retrieving revision 1.53
diff -u -r1.53 cygport.in
--- bin/cygport.in	5 Feb 2007 03:28:43 -0000	1.53
+++ bin/cygport.in	5 Feb 2007 21:40:40 -0000
@@ -376,32 +376,51 @@
 	error "Could not download ${1##*/}";
 }
 
+# attempts to fetch $1, auto-detecting download method
+# among (mirror, http, https, ftp).  If $1 has no 'protocol://'
+# prefix, it is ignored.  If it has an unsupported 'protocol://'
+# prefix, an error is raised.
+src_fetch_auto() {
+	local uri="$1"
+	case ${uri%%://*} in
+		mirror)		mirror_fetch ${uri} ;;
+		http|https|ftp)	fetch ${uri} || error "Download ${uri##*/} failed" ;;
+		${uri})		;;
+		*)		error "Invalid download URI ${uri} (bad protocol: '${uri%%://*}')" ;;
+	esac
+}
+
 # downloads sources from Internet if not present
 src_fetch() {
 	local uri;
+	local first_src_uri;
+	local rest_src_uri;
 
 	cd ${top};
+	first_src_uri="${SRC_URI%% *}"
+	rest_src_uri="${SRC_URI##${first_src_uri}}"
 
 	if defined _USE_CVS_FETCH
 	then
-		cvs_fetch;
+		cvs_fetch; # only fetches the first SRC_URI
 	elif defined _USE_SVN_FETCH
 	then
-		svn_fetch;
+		svn_fetch; # only fetches the first SRC_URI
 	elif defined _USE_GIT_FETCH
 	then
-		git_fetch;
+		git_fetch; # only fetches the first SRC_URI
 	else
-		for uri in ${SRC_URI} ${PATCH_URI}
-		do
-			case ${uri%%://*} in
-				mirror)			mirror_fetch ${uri} ;;
-				http|https|ftp)	fetch ${uri} || error "Download ${uri##*/} failed" ;;
-				${uri})			;;
-				*)				error "Invalid download URI ${uri}" ;;
-			esac
-		done
+		# only fetch the first SRC_URI here...
+		src_fetch_auto "${first_src_uri}"
 	fi
+
+	# ...for the rest (including PATCH_URIs), allow only 
+	# mirror|http|https|ftp remote protocols -- or local files
+	# (e.g. silently ignore URIs which do not specify a protocol)
+	for uri in ${rest_src_uri} ${PATCH_URI}
+	do
+		src_fetch_auto "${uri}"
+	done
 }
 
 # unpacks the original package source archive
Index: lib/cvs.cygclass
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/lib/cvs.cygclass,v
retrieving revision 1.4
diff -u -r1.4 cvs.cygclass
--- lib/cvs.cygclass	23 Nov 2006 04:14:59 -0000	1.4
+++ lib/cvs.cygclass	5 Feb 2007 21:40:40 -0000
@@ -25,6 +25,7 @@
 cvs_fetch() {
 	local cvs_branch
 	local cvs_date
+	local first_src_uri
 
 	check_prog_req cvs
 
@@ -43,5 +44,7 @@
 	cd ${T}
 	verbose cvs -d ${CVS_URI} checkout ${cvs_branch} ${cvs_date} ${CVS_MODULE}
 
-	tar jcf ${top}/${SRC_URI} --exclude=CVS --exclude=.cvsignore ${CVS_MODULE}
+	first_src_uri=${SRC_URI%% *}
+	tar jcf ${top}/${first_src_uri} --exclude=CVS --exclude=.cvsignore ${CVS_MODULE}
+	cd ${top}
 }
Index: lib/git.cygclass
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/lib/git.cygclass,v
retrieving revision 1.5
diff -u -r1.5 git.cygclass
--- lib/git.cygclass	23 Nov 2006 04:14:59 -0000	1.5
+++ lib/git.cygclass	5 Feb 2007 21:40:40 -0000
@@ -25,6 +25,7 @@
 SRC_DIR="${GIT_MODULE}"
 
 git_fetch() {
+	local first_src_uri
 	check_prog_req git
 
 	# T likely doesn't exist at this point, so create it first
@@ -38,5 +39,7 @@
 		cd ${T}
 	fi
 
-	tar jcf ${top}/${SRC_URI} --exclude=.git ${GIT_MODULE}
+	first_src_uri=${SRC_URI%% *}
+	tar jcf ${top}/${first_src_uri} --exclude=.git ${GIT_MODULE}
+	cd ${top}
 }
Index: lib/svn.cygclass
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/lib/svn.cygclass,v
retrieving revision 1.7
diff -u -r1.7 svn.cygclass
--- lib/svn.cygclass	5 Feb 2007 04:19:35 -0000	1.7
+++ lib/svn.cygclass	5 Feb 2007 21:40:40 -0000
@@ -24,6 +24,7 @@
 SRC_DIR="${SVN_MODULE}"
 
 svn_fetch() {
+	local first_src_uri
 	local svn_rev
 
 	check_prog_req svn subversion
@@ -41,5 +42,7 @@
 	cd ${T}
 	verbose svn checkout ${SVN_URI}/${SVN_BRANCH:-trunk} ${svn_rev} ${SVN_MODULE}
 
-	tar jcf ${top}/${SRC_URI} --exclude=.svn ${SVN_MODULE}
+	first_src_uri=${SRC_URI%% *}
+	tar jcf ${top}/${first_src_uri} --exclude=.svn ${SVN_MODULE}
+	cd ${top}
 }

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]