Apologies, there were some similar patches floating around a while ago.
This introduces a small wedge to reorder distsites before fetching.
Index: bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
retrieving revision 1.999
diff -u -p -r1.999 bsd.port.mk
--- bsd.port.mk 28 May 2010 12:34:22 -0000 1.999
+++ bsd.port.mk 5 Jun 2010 06:51:39 -0000
@@ -995,6 +1001,7 @@ _SITE_SELECTOR += *:${_I}) echo >&2 "Err
.endfor
_SITE_SELECTOR += *) sites="${MASTER_SITES}";; esac
+REORDER_SITES ?= :
# OpenBSD code to handle ports distfiles on a CDROM.
#
@@ -2452,6 +2459,7 @@ ${_F}:
f=${_F:s...@^${fulldistdir}/@@}; \
${_CDROM_OVERRIDE}; \
${_SITE_SELECTOR}; \
+ ${REORDER_SITES}; \
for site in $$sites; do \
${ECHO_MSG} ">> Fetch $${site}$$f"; \
if ${FETCH_CMD} $${site}$$f; then \
You can then define in /etc/mk.conf:
REORDER_SITES=sites=`perl ${PORTSDIR}/infrastructure/fetch/reorder_sites -v
$$sites`
With the following script:
--------------------------------------
#! /usr/bin/perl
# ex:ts=8 sw=4:
# $OpenBSD$
#
# Copyright (c) 2010 Marc Espie <[email protected]>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
use strict;
use warnings;
sub write_list
{
my ($fh, $l, $join) = @_;
$join //= ' ';
print $fh join($join, @$l), "\n";
}
my $order;
do "/etc/order_sites.conf";
my $scores = {};
my $verbose = 0;
if ($ARGV[0] eq '-v') {
shift;
$verbose = 1;
}
write_list(\*STDERR, \...@argv) if $verbose;
for my $i (@ARGV) {
$scores->{$i} = 0;
while (my ($s, $score) = (each %$order)) {
if ($i =~ m/$s/) {
$scores->{$i} += $score;
}
}
}
my @result =
sort {$scores->{$b} <=> $scores->{$a}}
grep {$scores->{$_} >= 0}
(keys %$scores);
write_list(\*STDERR, \...@result) if $verbose;
write_list(\*STDOUT, \...@result, "\n");
exit 0;
---------------------
This does expect a small config file /etc/order_sites.conf (actually a bit
of perl) with the following format:
$order = {
regexp => score,
...
};
for instance:
$order = {
'\bfr\b' => 50,
'^http:' => 150,
};
this one will select http: urls in preference to ftp, and give a smaller
greater score to fr.
It does sum up all regexps that match for a given site, and discards
everything with a strictly negative score. The -v means it will show
sites before/after for debugging purposes.
Comments welcome.