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 enhancement


At present, if you use cvs|svn|git cygclass, you can only have one SRC_URI. This patch does three related things

(1) relaxes that restriction slightly. Now, the *first* SRC_URI corresponds to the tarball created from the remote repository checkout via CVS_URI/SVN_URI/GIT_URI. The other entries in SRC_URI may be mirror, http, or ftp URIs -- or local files (see #2, next).

(2) Sometimes, .src.patch and .cygwin.patch just aren't enough. If SRC_URI contains multiple URI's, then only the first one need be cvs|svn|git|mirror|http|ftp. The others are now allowed to be simple files; 'cygport get' will warn, not error, if it fails to recognize the download protocol of the 2nd...Nth URI.

(3) If SRC_URI contains extra patches, then you need some way to apply them -- and src_prep() is protected. Implement overridable (and no-op by default) functions src_prep_init_hook() src_prep_fini_hook(). The former is called just after all SRC_URIs are unpacked; the latter at the end of src_prep (e.g after the .src.patch and .cygwin.patch are applied).

These changes were necessary to support building jpeg (using the autotoolized source package at sourceforge, and the lossless compression patch from simplesystems, and the debian lossless-crop patch[locally modified to apply cleanly after the simplesystems change]):

----------------------%<-------------------
...
CVS_URI=":pserver:anonymous@libjpeg.cvs.sourceforge.net:/cvsroot/libjpeg"
CVS_DATE="2006-03-01"
PD=${CVS_DATE//-}
CVS_MODULE=lib${PN}
inherit cvs

SRC_URI="${PN}-${PV}-${PD}.tar.bz2 \
ftp://ftp.simplesystems.org/pub/ImageMagick/delegates/ljpeg-6b.tar.gz \
jpegv6b-losslesscrop-after-ljpeg.patch"

SRC_DIR="lib${PN}"
...
src_prep_init_hook() {
        cd ${origsrcdir}
        mv testimgl* ${SRC_DIR}/
        cd ${SRC_DIR}
        apply_patch ${origsrcdir}/ljpeg-6b.patch
        apply_patch jpegv6b-losslesscrop-after-ljpeg.patch
}
----------------------%<-------------------

--
Chuck

P.S. Ping on relocatable patch?

2006-11-07 Charles Wilson <...>

	* bin/cygport.in (src_fetch_auto): new function. Autodetects
	protocol of passed-in URI (mirror|http|ftp) and errors if
	no recognized protocol detected
	(src_fetch_auto_warn): new function. Autodetects protocol
	of passed-in URI (mirror|http|ftp) and issues a warning if
	no recognized protocol detected
	(src_fetch): call src_fetch_auto_warn for 2nd..Nth SRC_URI
	regardless of download method (cvs|svn|git|mirror|http|ftp)
	of first SRC_URI.  If !(cvs|svn|git), call src_fetch_auto
	for first SRC_URI -- which will error if first SRC_URI's
	protocol is unrecognized.
	(src_prep_init_hook): new function. no-op.
	(src_prep_fini_hook): new function. no-op.
	(src_prep): call src_prep_init_hook and src_prep_fini_hook.

	* 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.26
diff -u -r1.26 cygport.in
--- bin/cygport.in	18 Oct 2006 04:27:31 -0000	1.26
+++ bin/cygport.in	7 Nov 2006 14:49:16 -0000
@@ -344,31 +344,54 @@
 	error "Could not download ${1##*/}";
 }
 
+# attempts to fetch $1, auto-detecting download method
+# among (mirror, http, ftp)
+src_fetch_auto() {
+	local uri="$1"
+	case ${uri%/*} in
+		mirror:*)      mirror_fetch ${uri} ;;
+		http:*|ftp:*)  fetch ${uri} || error "Download ${uri##*/} failed" ;;
+		${uri}|.)      error "Invalid download URI ${uri}" ;;
+	esac
+}
+src_fetch_auto_warn() {
+	local uri="$1"
+	case ${uri%/*} in
+		mirror:*)      mirror_fetch ${uri} ;;
+		http:*|ftp:*)  fetch ${uri} || error "Download ${uri##*/} failed" ;;
+		${uri}|.)      warning "Invalid download URI ${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 [ -n "${_USE_CVS_FETCH}" ]
 	then
-		cvs_fetch;
+		cvs_fetch; # only fetches the first SRC_URI
 	elif [ -n "${_USE_SVN_FETCH}" ]
 	then
-		svn_fetch;
+		svn_fetch; # only fetches the first SRC_URI
 	elif [ -n "${_USE_GIT_FETCH}" ]
 	then
-		git_fetch;
+		git_fetch; # only fetches the first SRC_URI
 	else
-		for uri in ${SRC_URI}
-		do
-			case ${uri%/*} in
-				mirror:*)      mirror_fetch ${uri} ;;
-				http:*|ftp:*)  fetch ${uri} || error "Download ${uri##*/} failed" ;;
-				${uri}|.)      error "Invalid download URI ${uri}" ;;
-			esac
-		done
+		# only fetch the first SRC_URI and report error on failure
+		src_fetch_auto "${first_src_uri}"
 	fi
+
+	# for the rest, only warn if not value URL (mirror|http|ftp)
+	for uri in ${rest_src_uri}
+	do
+		src_fetch_auto_warn "${uri}"
+	done
 }
 
 # unpacks the original package source archive
@@ -530,6 +553,12 @@
 	fi
 }
 
+src_prep_init_hook() {
+	:
+}
+src_prep_fini_hook() {
+	:
+}
 src_prep() {
 	local sigext;
 	local src_pkg;
@@ -581,6 +610,8 @@
 	fi
 
 	__step "Preparing working source directory";
+	src_prep_init_hook
+	cd ${top}
 
 	cp -fpr ${origsrcdir}/* ${srcdir};
 
@@ -593,6 +624,10 @@
 	then
 		apply_patch ${top}/${cygwin_patchfile} ${top}/${src_patchfile};
 	fi
+
+	cd ${top}
+	src_prep_fini_hook
+	cd ${S}
 }
 
 # protect functions
Index: lib/cvs.cygclass
===================================================================
RCS file: /cvsroot/cygwin-ports/cygport/lib/cvs.cygclass,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 cvs.cygclass
--- lib/cvs.cygclass	14 Jun 2006 01:16:16 -0000	1.1.1.1
+++ lib/cvs.cygclass	7 Nov 2006 14:49:16 -0000
@@ -23,6 +23,7 @@
 cvs_fetch() {
 	local cvs_branch
 	local cvs_date
+	local first_src_uri
 
 	check_prog_req cvs
 
@@ -41,5 +42,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.2
diff -u -r1.2 git.cygclass
--- lib/git.cygclass	18 Aug 2006 01:33:22 -0000	1.2
+++ lib/git.cygclass	7 Nov 2006 14:49:16 -0000
@@ -23,6 +23,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
@@ -36,5 +37,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.1.1.1
diff -u -r1.1.1.1 svn.cygclass
--- lib/svn.cygclass	14 Jun 2006 01:16:17 -0000	1.1.1.1
+++ lib/svn.cygclass	7 Nov 2006 14:49:17 -0000
@@ -23,6 +23,7 @@
 
 svn_fetch() {
 	local svn_rev
+	local first_src_uri
 
 	check_prog_req svn subversion
 
@@ -39,5 +40,7 @@
 	cd ${T}
 	verbose svn checkout ${SVN_URI} ${svn_rev}
 
-	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]