Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Jul 2000 18:17:16 +0900
From:      "Akinori -Aki- MUSHA" <knu@idaemons.org>
To:        asami@FreeBSD.org, freebsd-ports@FreeBSD.org
Subject:   Add MASTER_SORT facility to our ports!
Message-ID:  <86vgyinvtv.wl@localhost.local.idaemons.org>

next in thread | raw e-mail | index | archive | help
Hi,

Here's the patch that adds master sites sorting facility into our
ports system.  I obtained it from NetBSD pkgsrc, to port to our ports
with a trivial fixes.

How to use it?  For instance, you can set "MASTER_SORT=provider.ne.jp
upstream.ad.jp .jp" and you'll have your preferred master sites in the
order specified.  You can also use MASTER_SORT_REGEX, which enables
you to specify your preference in regex, for example, you can set
"MASTER_SORT_REGEX=^ftp://" to show that you prefer ftp to http.

Neat, huh? :)


Index: bsd.port.mk
===================================================================
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.341
diff -u -r1.341 bsd.port.mk
--- bsd.port.mk	2000/07/04 08:47:50	1.341
+++ bsd.port.mk	2000/07/07 08:33:25
@@ -1070,6 +1070,20 @@
 .endif
 .endif
 
+#
+# Sort the master site list according to the patterns in MASTER_SORT
+#
+MASTER_SORT?=
+MASTER_SORT_REGEX?=
+MASTER_SORT_REGEX+= ${MASTER_SORT:S|.|\\.|g:S|^|//[^/]*|:S|$|/|}
+
+MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX}"; }
+.for srt in ${MASTER_SORT_REGEX}
+MASTER_SORT_AWK+= /${srt:S^/^\\/^g}/ { good["${srt}"] = good["${srt}"] " " $$0 ; next; } 
+.endfor
+MASTER_SORT_AWK+= { rest = rest " " $$0; } END { n=split(gl, gla); for(i=1;i<=n;i++) { print good[gla[i]]; } print rest; }
+SORTED_MASTER_SITES_CMD= echo '${MASTER_SITES}' | ${AWK} '${MASTER_SORT_AWK}'
+
 DISTFILES?=		${DISTNAME}${EXTRACT_SUFX}
 ALLFILES?=	${DISTFILES} ${PATCHFILES}
 
@@ -1535,7 +1549,7 @@
 				fi; \
 			fi; \
 			${ECHO_MSG} ">> $$file doesn't seem to exist on this system."; \
-			for site in ${MASTER_SITES}; do \
+			for site in `${SORTED_MASTER_SITES_CMD}`; do \
 			    ${ECHO_MSG} ">> Attempting to fetch from $${site}."; \
 				DIR=${DIST_SUBDIR}; \
 				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
@@ -2134,7 +2148,7 @@
 	@(cd ${_DISTDIR}; \
 	 for file in ${DISTFILES}; do \
 		if [ ! -f $$file -a ! -f `${BASENAME} $$file` ]; then \
-			for site in ${MASTER_SITES}; do \
+			for site in `${SORTED_MASTER_SITES_CMD}`; do \
 				DIR=${DIST_SUBDIR}; \
 				CKSIZE=`${GREP} "^SIZE ($${DIR:+$$DIR/}$$file)" ${MD5_FILE} | ${AWK} '{print $$4}'`; \
 				case $${file} in \



-- 
                           /
                          /__  __       
                         / )  )  ) )  /
Akinori -Aki- MUSHA aka / (_ /  ( (__(  @ idaemons.org / FreeBSD.org

"We're only at home when we're on the run, on the wing, on the fly"


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86vgyinvtv.wl>