summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--pod/urpmi.addmedia.8.pod6
-rw-r--r--urpm/mirrors.pm48
-rwxr-xr-xurpmq2
4 files changed, 48 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index e490b4a8..fad0d53a 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+- urpmi.addmedia, urpmi.update:
+ o urpmi.addmedia --mirrorlist handles a list of mirrors/mirrorlist:
+ you can specify a mirror to use inside a local network, but it will
+ default to standard mirrors when the local mirror is not available.
+
Version 5.14 - 17 March 2008, by Pascal "Pixel" Rigaux
- urpmi:
diff --git a/pod/urpmi.addmedia.8.pod b/pod/urpmi.addmedia.8.pod
index fd95fbb5..7edfcf39 100644
--- a/pod/urpmi.addmedia.8.pod
+++ b/pod/urpmi.addmedia.8.pod
@@ -145,6 +145,12 @@ Use rpm files (instead of synthesis).
Use the given url as a mirror list. It is quite special, please see examples
at the beginning of this page.
+You can also give a space seperated list of urls. Each url can be either a
+mirrorlist or a mirror url. This is useful if you have a mirror to use inside
+a local network, but still use standard mirrors when the local mirror is not
+available.
+
+
nb: $MIRRORLIST is a special variable which gives the default URL for the
current distribution/arch
diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm
index 3bde1837..cfcc932b 100644
--- a/urpm/mirrors.pm
+++ b/urpm/mirrors.pm
@@ -41,13 +41,18 @@ sub pick_one {
#- side-effects: $urpm->{mirrors_cache}
sub _pick_one {
- my ($urpm, $mirrorlist, $must_succeed, $allow_cache_update) = @_;
+ my ($urpm, $mirrorlists, $must_succeed, $allow_cache_update) = @_;
my $url;
- if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update)) {
- $url = $cache->{chosen};
+ my @l = split(' ', $mirrorlists);
+ foreach my $mirrorlist (@l) {
+ if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update)) {
+ $mirrorlist ne $l[-1] and $cache->{network_mtime} = _network_mtime();
+ $url = $cache->{chosen};
+ last;
+ }
}
- !$url && $must_succeed and $urpm->{fatal}(10, N("Could not find a mirror from mirrorlist %s", $mirrorlist));
+ !$url && $must_succeed and $urpm->{fatal}(10, N("Could not find a mirror from mirrorlist %s", $mirrorlists));
$url;
}
@@ -59,7 +64,11 @@ sub _pick_one_ {
if (!$cache->{chosen}) {
if (!$cache->{list}) {
- $cache->{list} = [ _list($urpm, $mirrorlist) ];
+ if (_is_only_one_mirror($mirrorlist)) {
+ $cache->{list} = [ { url => $mirrorlist } ];
+ } else {
+ $cache->{list} = [ _list($urpm, $mirrorlist) ];
+ }
$cache->{time} = time();
}
@@ -76,11 +85,15 @@ sub _pick_one_ {
}
#- side-effects: $urpm->{mirrors_cache}
sub black_list {
- my ($urpm, $mirrorlist, $url) = @_;
- my $cache = _cache($urpm, $mirrorlist);
+ my ($urpm, $mirrorlists, $url) = @_;
+ foreach my $mirrorlist (split ' ', $mirrorlists) {
+ my $cache = _cache($urpm, $mirrorlist);
- @{$cache->{list}} = grep { $_->{url} ne $url } @{$cache->{list}};
- delete $cache->{chosen};
+ if ($cache->{list}) {
+ @{$cache->{list}} = grep { $_->{url} ne $url } @{$cache->{list}};
+ }
+ delete $cache->{chosen};
+ }
}
#- side-effects:
@@ -91,8 +104,11 @@ sub _cache__may_clean_if_outdated {
my $cache = _cache($urpm, $mirrorlist);
if ($allow_cache_update) {
- if ($cache->{time} &&
- time() > $cache->{time} + 24*60*60 * $urpm->{options}{'days-between-mirrorlist-update'}) {
+ if ($cache->{network_mtime} && _network_mtime() > $cache->{network_mtime}) {
+ $urpm->{log}("not using cached mirror list $mirrorlist since network configuration changed");
+ %$cache = ();
+ } elsif ($cache->{time} &&
+ time() > $cache->{time} + 24*60*60 * $urpm->{options}{'days-between-mirrorlist-update'}) {
$urpm->{log}("not using outdated cached mirror list $mirrorlist");
%$cache = ();
}
@@ -208,7 +224,7 @@ sub _mirrors_raw {
my ($urpm, $url) = @_;
$urpm->{log}(N("getting mirror list from %s", $url));
- my @l = urpm::download::get_content($urpm, $url) or die "mirror list not found";
+ my @l = urpm::download::get_content($urpm, $url) or $urpm->{error}("mirror list not found");
@l;
}
@@ -235,6 +251,14 @@ sub _mandriva_mirrorlist {
"http://api.mandriva.com/mirrors/$product_type.$product_id->{version}.$arch.list";
}
+#- heuristic to detect wether it is really a mirrorlist or a simple mirror url:
+sub _is_only_one_mirror {
+ my ($mirrorlist) = @_;
+ _expand($mirrorlist) !~ /\.list$/;
+}
+
+sub _network_mtime() { (stat('/etc/resolv.conf'))[9] }
+
sub parse_LDAP_namespace_structure {
my ($s) = @_;
my %h = map { /(.*?)=(.*)/ ? ($1 => $2) : () } split(',', $s);
diff --git a/urpmq b/urpmq
index d4998bd6..d1bc5f34 100755
--- a/urpmq
+++ b/urpmq
@@ -198,7 +198,7 @@ if ($options{list_aliases}) {
foreach (@{$urpm->{media}}) {
$_->{update} and print "--update ";
$_->{virtual} and print "--virtual ";
- $_->{mirrorlist} and print "--mirrorlist $_->{mirrorlist} ";
+ $_->{mirrorlist} and print "--mirrorlist '$_->{mirrorlist}' ";
print escape_shell($_->{name}), " ";
print escape_shell($_->{mirrorlist} ? $_->{'with-dir'} : $_->{url}), " " if !$_->{mirrorlist} || $_->{'with-dir'};
$_->{with_synthesis} and print "with " . escape_shell($_->{with_synthesis});