delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/01/08/00:20:04

X-Spam-Check-By: sourceware.org
Message-ID: <459F2350.2010302@cwilson.fastmail.fm>
Date: Fri, 05 Jan 2007 23:19:28 -0500
From: Charles Wilson <cygwin AT cwilson DOT fastmail DOT fm>
User-Agent: Thunderbird 1.5.0.9 (Windows/20061207)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: [patch] cygport-0.2.7 mixed-mode SRC_URIs
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------070905040204020400080508
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

...and allow the new PATCH_URI in cygport-0.2.7 to work when main src is 
in CVS|SVN|GIT repo.  (At present, in 0.2.7, PATCH_URI is ignored if 
inherit cvs|svn|git).

Admittedly, that is be an odd situation: an "official" patch that is 
supposed to be applied to a CVS checkout -- if it is "official", why is 
it a patch -- shouldn't it already reflected in the repository's 
contents?  But, that's exactly the situation for libjpeg: the patch is 
actually the third-party lossless jpeg patch, and I recently switched to 
using the libjpeg CVS repository on sourceforge instead of the regular 
jpeg6b tarball; the sourceforge version is identical to the tarball 
except it uses autoconf/automake/libtool to build.

With this patch, SRC_URI can contain multiple entries.  All SRC_URI 
entries *except the first*, and all PATCH_URIs, can only be downloaded 
from the internet via mirror|ftp|http|https protocols.  If the "extra" 
SRC_URIs or any PATCH_URIs contain a "protocol://" prefix other than 
those listed, it is an error.  If any "extra" SRC_URIs or PATCH_URIs do 
not contain a "protocol://" prefix, they are ignored (e.g. no attempt is 
made to fetch them, and no error is reported).

cygport-0.2.7's new PATCH_URI, however, is not sufficient for all 
purposes, even if modifications were made to allow just THAT to work 
when inheriting cvs|svn|git.  Sometimes, the "extra" files you want to 
download are not .patch files -- as in this case: the lossless jpeg 
"patch" is a tarball that CONTAINS a patch, as well as some binary test 
images.  So, we need both: enable PATCH_URI to work when the "main" 
SRC_URI is in a cvs|svn|git repo, but also allow multiple entries in 
SRC_URI where the latter ones are not cvs|svn|git.

Possible objection: what if you want multiple SRC_URIs where more than 
one are taken from cvs, or one is cvs and one is svn...  Sorry, can't 
help you.  (1) That's WAY beyond the scope of this patch (2) I can't 
even imagine a *realistic* scenario where that is necessary, and (3) 
it's already taken more than two months and this patch is languishing as 
it is -- making the patch even more complicated would just ensure its 
ultimate demise|rejection.



NOTE:
If SRC_URI is to contain multiple entries, and a cvs repo (or svn, or 
git) is used for the first one, then in the .cygport file SRC_URI must 
be defined AFTER 'inherit cvs' (or svn, or git) is invoked.


---------------------------------------------------------------
Implementation: is a bit simpler than the one posted in early November:
http://www.cygwin.com/ml/cygwin/2006-11/msg00137.html

This is because (1) cygport-0.2.7's (mirror|http|https|ftp) download 
routine is now more forgiving of non-protocol URIs in all cases. So we 
don't need a special, warn-and-do-not-error version of src_fetch_auto. 
(2) the src_prep_*_hook stuff was refactored into a separate patch, 
posted earlier this evening.
---------------------------------------------------------------

2007-01-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.

--
Chuck

--------------070905040204020400080508
Content-Type: text/plain;
 name="cygport-mixedmode.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="cygport-mixedmode.patch"

Index: bin/cygport.in
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/bin/cygport.in,v
retrieving revision 1.45
diff -u -r1.45 cygport.in
--- bin/cygport.in	4 Jan 2007 02:35:26 -0000	1.45
+++ bin/cygport.in	6 Jan 2007 04:05:25 -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	6 Jan 2007 04:05:25 -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	6 Jan 2007 04:05:25 -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.5
diff -u -r1.5 svn.cygclass
--- lib/svn.cygclass	23 Nov 2006 04:14:59 -0000	1.5
+++ lib/svn.cygclass	6 Jan 2007 04:05:25 -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_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}
 }


--------------070905040204020400080508
Content-Type: text/plain; charset=us-ascii

--
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/
--------------070905040204020400080508--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019