summaryrefslogtreecommitdiff
path: root/mk/bsd.pkg.mk
diff options
context:
space:
mode:
authormjl <mjl>1999-07-13 18:09:19 +0000
committermjl <mjl>1999-07-13 18:09:19 +0000
commit7bde44d27b59141ee1bf21dc07b2284f22091a37 (patch)
tree8e2bf0726f4243c2a2c7e87a4cd6f35abb9b08af /mk/bsd.pkg.mk
parent489bd1ddaf4ba470e8c3fbddf85789c23fbacf86 (diff)
downloadpkgsrc-7bde44d27b59141ee1bf21dc07b2284f22091a37.tar.gz
Add possibility to sort the master download site list according to
local preferences (domain suffixes or full regular expressions) by defining MASTER_SORT or MASTER_SORT_REGEX appropriately.
Diffstat (limited to 'mk/bsd.pkg.mk')
-rw-r--r--mk/bsd.pkg.mk21
1 files changed, 18 insertions, 3 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index f208ef8f86b..ddbb6672c80 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.296 1999/07/13 01:02:42 hubertf Exp $
+# $NetBSD: bsd.pkg.mk,v 1.297 1999/07/13 18:09:19 mjl Exp $
#
# This file is in the public domain.
#
@@ -876,14 +876,29 @@ _FETCH_FILE= \
exit 1; \
fi
+#
+# Sort the master site list according to the patterns in MASTER_SORT
+#
+
+MASTER_SORT?=
+MASTER_SORT_REGEX?=
+MASTER_SORT_REGEX+= ${MASTER_SORT:S/./\\./g:C/.*/:\/\/[^\/]*&\//}
+
+MASTER_SORT_AWK= BEGIN { RS = " "; ORS = " "; IGNORECASE = 1 ; gl = "${MASTER_SORT_REGEX}"; }
+.for srt in ${MASTER_SORT_REGEX}
+MASTER_SORT_AWK+= /${srt:C/\//\\\//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!= echo '${MASTER_SITES}' | awk '${MASTER_SORT_AWK}'
+
.if !target(do-fetch)
do-fetch:
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_DISTDIR}
${_PKG_SILENT}(${_PKG_DEBUG}cd ${_DISTDIR}; \
- sites="${MASTER_SITES}"; \
+ sites="${SORTED_MASTER_SITES}"; \
for file in "" ${_DISTFILES}; do \
if [ "X$$file" = X"" ]; then continue; fi; \
- ${_FETCH_FILE} \
+ ${_FETCH_FILE} \
done)
.if defined(_PATCHFILES)
${_PKG_SILENT}(${_PKG_DEBUG}cd ${_DISTDIR}; \