Subject: pkg/7471 fix proposal: MASTER_SITES per DISTFILE
To: None <tech-pkg@netbsd.org>
From: Thomas Klausner <wiz@danbala.ifoer.tuwien.ac.at>
List: tech-pkg
Date: 11/30/2001 01:47:23
--K8nIJk4ghYZn606h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi!

I'd like to commit the attached patches to resolve pkg/7471 (the
oldest pkg PR right now, after tron solved the xxgdb one last week).

If you apply this, you can set a variable like:
	MASTER_SITES_${DISTNAME}.tar.gz=	http://somewhere/
or
	PATCH_SITES_some-patch.gz=	ftp://else/

Example diffs for ghostscript and kterm (which was the only package
that uses multiple PATCH_SITES which I could find) and a documentation
update for Packages.txt are also attached. For ghostscript (which is
an extreme case) it really speeds up the `make fetch' step.

I tested `make fetch' and `make fetch-list' and both seem to work
fine.

If there are no objections, I'll commit it over the weekend.

Bye,
 Thomas

-- 
Thomas Klausner - wiz@danbala.tuwien.ac.at
Language is not neutral. It is not merely a vehicle which carries ideas. It
is itself a shaper of ideas. -- Dale Spender

--K8nIJk4ghYZn606h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="7471-bsd.pkg.mk"

Index: bsd.pkg.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/bsd.pkg.mk,v
retrieving revision 1.867
diff -u -r1.867 bsd.pkg.mk
--- bsd.pkg.mk	2001/11/29 20:06:03	1.867
+++ bsd.pkg.mk	2001/11/30 00:38:14
@@ -857,7 +857,7 @@
 MASTER_SITES:=	${_MASTER_SITE_OVERRIDE} ${MASTER_SITES}
 PATCH_SITES:=	${_MASTER_SITE_OVERRIDE} ${PATCH_SITES}
 .endif
-  
+
 # Derived names so that they're easily overridable.
 DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
 .if defined(PKGREVISION) && ${PKGREVISION} != ""
@@ -1229,20 +1229,22 @@
 					CKSUM=`${DIGEST} $$alg < ${_DISTDIR}/$$bfile`; \
 					CKSUM2=`${AWK} '$$1 == "'$$alg'" && $$2 == "('$$file')" {print $$4;}' <${DISTINFO_FILE}`; \
 					if [ "$$CKSUM" = "$$CKSUM2" -o "$$CKSUM2" = "IGNORE" ]; then \
-						continue 2;		\
+						break;			\
 					else				\
 						${ECHO_MSG} "=> Checksum failure - trying next site."; \
 					fi;				\
 				elif [ ! -f ${_DISTDIR}/$$bfile ]; then \
 					${ECHO_MSG} "=> FTP didn't fetch expected file, trying next site." ; \
 				else					\
-					continue 2;			\
+					break;				\
 				fi;					\
 			fi						\
 		done;							\
-		${ECHO_MSG} "=> Couldn't fetch $$bfile - please try to retrieve this";\
-		${ECHO_MSG} "=> file manually into ${_DISTDIR} and try again."; \
-		exit 1;							\
+		if [ ! -f ${_DISTDIR}/$$bfile ]; then \
+			${ECHO_MSG} "=> Couldn't fetch $$bfile - please try to retrieve this";\
+			${ECHO_MSG} "=> file manually into ${_DISTDIR} and try again."; \
+			exit 1;						\
+		fi;							\
 	fi
 
 _CHECK_DIST_PATH=							\
@@ -1277,23 +1279,25 @@
 .if !target(do-fetch)
 do-fetch:
 	${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_DISTDIR}
+.for fetchfile in ${_DISTFILES}
 	${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};			\
-	 sites=`${SORTED_MASTER_SITES_CMD}`;				\
-	 for file in "" ${_DISTFILES}; do				\
-		if [ "X$$file" = X"" ]; then continue; fi;		\
-		bfile=`${BASENAME} $$file`;				\
-		${_CHECK_DIST_PATH};					\
-		${_FETCH_FILE}						\
-	 done
+	sortedsites=`${SORTED_MASTER_SITES_CMD}`;			\
+	sites="${MASTER_SITES_${fetchfile:T}} $$sortedsites";		\
+	file="${fetchfile}";						\
+	bfile="${fetchfile:T}";						\
+	${_CHECK_DIST_PATH};						\
+	${_FETCH_FILE}
+.endfor
 .  if defined(_PATCHFILES)
+.for fetchfile in ${_PATCHFILES}
 	${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};			\
-	 sites=`${SORTED_PATCH_SITES_CMD}`;				\
-	 for file in "" ${_PATCHFILES}; do				\
-		if [ "X$$file" = X"" ]; then continue; fi;		\
-		bfile=`${BASENAME} $$file`;				\
-		${_CHECK_DIST_PATH};					\
-		${_FETCH_FILE}						\
-	 done
+	sortedsites=`${SORTED_PATCH_SITES_CMD}`;			\
+	sites="${PATCH_SITES_${fetchfile:T}} $$sortedsites";		\
+	file="${fetchfile}";						\
+	bfile="${fetchfile:T}";						\
+	${_CHECK_DIST_PATH};						\
+	${_FETCH_FILE}
+.endfor
 .  endif
 .endif
 
@@ -1982,7 +1986,7 @@
 	${ECHO} "$$sotype";						\
 	${RM} -f a.$$$$.c a.$$$$.out
 .endif
- 
+
 
 ################################################################
 # Skeleton targets start here
@@ -2475,33 +2479,29 @@
 	@${MKDIR} ${_DISTDIR}
 	@[ -z "${_DISTDIR}" ] || ${ECHO} "${MKDIR} ${_DISTDIR}"
 .  if defined(DISTFILES)
+.for fetchfile in ${DISTFILES}
 	@(cd ${_DISTDIR};						\
-	for file in "" ${DISTFILES}; do					\
-		if [ "X$$file" = X"" ]; then continue; fi;		\
-		bfile=`${BASENAME} $$file`;				\
-		if [ ! -f $$file -a ! -f $$bfile ]; then		\
-			${ECHO} -n "cd ${_DISTDIR} && [ -f $$file -o -f $$bfile ] || "; \
-			for site in "" `${SORTED_MASTER_SITES_CMD}`; do	\
-				if [ "X$$site" = X"" ]; then continue; fi; \
-				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} "'"$${site}$${file}"'" "${FETCH_AFTER_ARGS}" '|| '; \
-			done;						\
-			${ECHO} "${ECHO} $${file} not fetched";		\
-		fi							\
-	done)
+	if [ ! -f ${fetchfile} -a ! -f ${fetchfile:T} ]; then		\
+		${ECHO} -n "cd ${_DISTDIR} && [ -f ${fetchfile} -o -f ${fetchfile:T} ] || "; \
+		for site in "" ${MASTER_SITES_${fetchfile:T}} `${SORTED_MASTER_SITES_CMD}`; do	\
+			if [ "X$$site" = X"" ]; then continue; fi; 	\
+			${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} "'"$${site}${fetchfile}"'" "${FETCH_AFTER_ARGS}" '|| '; \
+		done;							\
+		${ECHO} "${ECHO} ${fetchfile} not fetched";		\
+	fi)
+.endfor
 .  endif # DISTFILES
 .  if defined(PATCHFILES)
+.for fetchfile in ${PATCHFILE}
 	@(cd ${_DISTDIR};						\
-	for file in "" ${PATCHFILES}; do				\
-		if [ "X$$file" = X"" ]; then continue; fi;		\
-		bfile=`${BASENAME} $$file`;				\
-		if [ ! -f $$file -a ! -f $$bfile ]; then		\
-			${ECHO} -n "cd ${_DISTDIR} && [ -f $$file -o -f $$bfile ] || "; \
-			for site in `${SORTED_PATCH_SITES_CMD}`; do	\
-				${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${file} "${FETCH_AFTER_ARGS}" '|| '; \
-			done;						\
-			${ECHO} "${ECHO} $${file} not fetched";		\
-		fi							\
-	done)
+	if [ ! -f ${fetchfile} -a ! -f ${fetchfile:T} ]; then		\
+		${ECHO} -n "cd ${_DISTDIR} && [ -f ${fetchfile} -o -f ${fetchfile:T} ] || "; \
+		for site in ${PATCH_SITES_${fetchfile:T}} `${SORTED_PATCH_SITES_CMD}`; do		\
+			${ECHO} -n ${FETCH_CMD} ${FETCH_BEFORE_ARGS} $${site}$${fetchfile} "${FETCH_AFTER_ARGS}" '|| '; \
+		done;							\
+		${ECHO} "${ECHO} $${fetchfile} not fetched";		\
+	fi)
+.endfor
 .  endif # defined(PATCHFILES)
 .endif # !target(fetch-list-one-pkg)
 

--K8nIJk4ghYZn606h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=7471-kterm

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/x11/kterm/Makefile,v
retrieving revision 1.15
diff -u -r1.15 Makefile
--- Makefile	2001/08/23 04:26:55	1.15
+++ Makefile	2001/11/30 00:38:26
@@ -5,7 +5,7 @@
 MASTER_SITES=	${MASTER_SITE_XCONTRIB:=applications/}
 
 # the following patch includes NFS xauth patch, and kamo's wd0.2 patch.
-PATCH_SITES+=	ftp://ftp.kame.net/pub/kame/misc/
+PATCH_SITES=	ftp://ftp.kame.net/pub/kame/misc/
 PATCHFILES+=	kterm-620-0213-20010706.diff.gz
 PATCH_DIST_STRIP= -p1
 
@@ -20,13 +20,13 @@
 
 .if defined(KTERM_USE_WALLPAPER)
 .if ${KTERM_USE_WALLPAPER} == "imlib"
-PATCH_SITES+=	http://delegate.uec.ac.jp:8081/club/mma/%7Etakkun/fun/handling/
+PATCH_SITES_KTerm-BGP-Imlib-1.0.patch.gz=	http://delegate.uec.ac.jp:8081/club/mma/%7Etakkun/fun/handling/
 PATCHFILES+=	KTerm-BGP-Imlib-1.0.patch.gz
 BUILDLINK_DEPENDS.imlib?=	imlib>=1.9.4
 USE_CONFIG_WRAPPER=		YES
 .include "../../graphics/imlib/buildlink.mk"
 .elif ${KTERM_USE_WALLPAPER} == "YES"
-PATCH_SITES+=	http://delegate.uec.ac.jp:8081/club/mma/%7Etakkun/fun/handling/
+PATCH_SITES_KTerm-BGP-1.0.patch.gz=	http://delegate.uec.ac.jp:8081/club/mma/%7Etakkun/fun/handling/
 PATCHFILES+=	KTerm-BGP-1.0.patch.gz
 .include "../../graphics/xpm/buildlink.mk"
 .endif

--K8nIJk4ghYZn606h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=7471-ghostscript-nox11

Index: Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/print/ghostscript-nox11/Makefile.common,v
retrieving revision 1.21
diff -u -r1.21 Makefile.common
--- Makefile.common	2001/11/01 09:41:13	1.21
+++ Makefile.common	2001/11/30 00:38:42
@@ -30,18 +30,18 @@
 PATCH_DIST_STRIP=	-p1
 
 # PostScript source to decode encrypted PDF files
-MASTER_SITES+=		http://www.ozemail.com.au/~geoffk/pdfencrypt/
+MASTER_SITES_pdf_sec.ps=	http://www.ozemail.com.au/~geoffk/pdfencrypt/
 PDF_SEC=		pdf_sec.ps
 DISTFILES+=		${PDF_SEC}
 
 # Additional driver for several HP deskjets
-MASTER_SITES+=		ftp://ftp.sbs.de/pub/graphics/ghostscript/pcl3/
+MASTER_SITES_hpdj-2.6.tar.gz=	ftp://ftp.sbs.de/pub/graphics/ghostscript/pcl3/
 HPDJ_DRV=		hpdj-2.6
 DISTFILES+=		${HPDJ_DRV}.tar.gz
 EXTRACT_LIST+=		${HPDJ_DRV}.tar.gz
 
 # I don't know the primary destribution sites of these drivers....
-MASTER_SITES+=		ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/
+MASTER_SITES_dmprt-2.01.tar.gz=	ftp://ftp.freebsd.org/pub/FreeBSD/distfiles/
 DMPRT_DRV=		dmprt-2.01
 DISTFILES+=		${DMPRT_DRV}.tar.gz
 EXTRACT_LIST+=		${DMPRT_DRV}.tar.gz
@@ -61,25 +61,25 @@
 EXTRACT_LIST+=		${MD5000_DRV}.tar.gz
 
 # Alps MD-2000/2010/4000/1300/1500/5000
-MASTER_SITES+=		http://plaza26.mbn.or.jp/~higamasa/gdevmd2k/
+MASTER_SITES_gdevmd2k-0.2a.tar.gz=	http://plaza26.mbn.or.jp/~higamasa/gdevmd2k/
 MD2000_DRV=		gdevmd2k-0.2a
 DISTFILES+=		${MD2000_DRV}.tar.gz
 EXTRACT_LIST+=		${MD2000_DRV}.tar.gz
 
 # Canon LIPS II+, III, IV; EPSON ESC/Page; NEC NPDL drivers
-MASTER_SITES+=		http://www.bukka.p.chiba-u.ac.jp/~ohmori/gs/
+MASTER_SITES_gdevlips-2.3.6.tar.gz=	http://www.bukka.p.chiba-u.ac.jp/~ohmori/gs/
 LIPS_DRV=		gdevlips-2.3.6
 DISTFILES+=		${LIPS_DRV}.tar.gz
 EXTRACT_LIST+=		${LIPS_DRV}.tar.gz
 
 # Ricoh RPDL
-MASTER_SITES+=		http://home.jp.FreeBSD.org/~mita/LOCAL_PORTS/
+MASTER_SITES_gdevrpdl.tar.gz=		http://home.jp.FreeBSD.org/~mita/LOCAL_PORTS/
 RPDL_DRV=		gdevrpdl
 DISTFILES+=		${RPDL_DRV}.tar.gz
 EXTRACT_LIST+=		${RPDL_DRV}.tar.gz
 
 # Kyocera Prescribe
-MASTER_SITES+=		${MASTER_SITE_LOCAL}
+MASTER_SITES_gdevprsc-0.3.tar.gz=		${MASTER_SITE_LOCAL}
 PRESCR_DRV=		gdevprsc-0.3
 DISTFILES+=		${PRESCR_DRV}.tar.gz
 EXTRACT_LIST+=		${PRESCR_DRV}.tar.gz

--K8nIJk4ghYZn606h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="7471-Packages.txt"

Index: Packages.txt
===================================================================
RCS file: /cvsroot/pkgsrc/Packages.txt,v
retrieving revision 1.215
diff -u -r1.215 Packages.txt
--- Packages.txt	2001/11/27 03:03:11	1.215
+++ Packages.txt	2001/11/30 00:42:02
@@ -595,6 +595,10 @@
 (Note the trailing slash after the subdirectory name.) Use of the deprecated
 MASTER_SITE_SUBDIR will not work.
 
+If the package has multiple DISTFILES from different MASTER_SITES, set
+	MASTER_SITE_name_of_file-0.1.2.tar.gz=	ftp://some.url/path/
+to speed up fetching the files, for all except the first distribution file.
+
 Currently the following values are available for CATEGORIES. If more than
 one is used, they need to be separated by spaces:
 

--K8nIJk4ghYZn606h--