From 1f7e8dc267a012c1b2ad49000bea184610ed0599 Mon Sep 17 00:00:00 2001 From: mjl Date: Tue, 13 Jul 1999 18:09:19 +0000 Subject: 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. --- mk/bsd.pkg.mk | 21 ++++++++++++++++++--- mk/mk.conf.example | 19 +++++++++++++++++-- 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'mk') 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}; \ diff --git a/mk/mk.conf.example b/mk/mk.conf.example index 5131c4a17c1..f715d3bce2c 100644 --- a/mk/mk.conf.example +++ b/mk/mk.conf.example @@ -1,4 +1,4 @@ -# $NetBSD: mk.conf.example,v 1.60 1999/07/07 13:47:34 itojun Exp $ +# $NetBSD: mk.conf.example,v 1.61 1999/07/13 18:09:19 mjl Exp $ # # Sample /etc/mk.conf file, which can be used to set specific values @@ -143,7 +143,22 @@ # arguments # Default: ${SU} - root -c - +#MASTER_SORT= .ac.at .at .de .ch .se .fi .no + # Whitespace delimited list of preferred + # download locations. MASTER_SITES will be + # reordered according to the hosts' address + # last components. + # Possible: list of domain name suffixes + # Default: none +#MASTER_SORT_REGEX= ftp://.*/ + # Same as MASTER_SORT, but takes a regular + # expression for more flexibility in matching. + # Regexps defined here have higher priority + # than MASTER_SORT. + # This example would prefer ftp transfers + # over anything else. + # Possible: Regexps as in awk(1) + # Default: none # # Definitions used only in the packages collection -- cgit v1.2.3