summaryrefslogtreecommitdiffstats
path: root/urpm/mirrors.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-04 07:56:16 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-04 07:56:16 +0000
commit6ae3df8b164d3e77e30fd2b7dfc4edafab616380 (patch)
treed6f5eeadb502148b384fd1a96c8b3494bff940f9 /urpm/mirrors.pm
parentb39c0519989af0611ae217b01c026e8e158b101a (diff)
downloadurpmi-6ae3df8b164d3e77e30fd2b7dfc4edafab616380.tar
urpmi-6ae3df8b164d3e77e30fd2b7dfc4edafab616380.tar.gz
urpmi-6ae3df8b164d3e77e30fd2b7dfc4edafab616380.tar.bz2
urpmi-6ae3df8b164d3e77e30fd2b7dfc4edafab616380.tar.xz
urpmi-6ae3df8b164d3e77e30fd2b7dfc4edafab616380.zip
create urpm::mirrors::list_urls() and use it
this fixes things like "mirrorlist: http://localmirror/dis/cooker/i586 $MIRRORLIST"
Diffstat (limited to 'urpm/mirrors.pm')
-rw-r--r--urpm/mirrors.pm25
1 files changed, 19 insertions, 6 deletions
diff --git a/urpm/mirrors.pm b/urpm/mirrors.pm
index 90be27b3..4aba409b 100644
--- a/urpm/mirrors.pm
+++ b/urpm/mirrors.pm
@@ -39,6 +39,18 @@ sub pick_one {
$medium->{url} = _add__with_dir($url, $medium->{'with-dir'});
}
+#- side-effects:
+#- + those of _pick_one_ ($urpm->{mirrors_cache})
+sub list_urls {
+ my ($urpm, $medium, $allow_cache_update) = @_;
+
+ my @l = split(' ', $medium->{mirrorlist});
+ map {
+ my $cache = _pick_one_($urpm, $_, $allow_cache_update, $_ ne $l[-1]);
+ $cache ? $cache->{list} : [];
+ } @l;
+}
+
#- side-effects: $urpm->{mirrors_cache}
sub _pick_one {
my ($urpm, $mirrorlists, $must_succeed, $allow_cache_update) = @_;
@@ -46,6 +58,13 @@ sub _pick_one {
my @l = split(' ', $mirrorlists);
foreach my $mirrorlist (@l) {
if (my $cache = _pick_one_($urpm, $mirrorlist, $allow_cache_update, $mirrorlist ne $l[-1])) {
+
+ if ($cache->{nb_uses}++) {
+ $urpm->{debug} and $urpm->{debug}("using mirror $cache->{chosen}");
+ } else {
+ $urpm->{log}("using mirror $cache->{chosen}");
+ }
+
return $cache->{chosen};
}
}
@@ -75,12 +94,6 @@ sub _pick_one_ {
$cache->{chosen} = $cache->{list}[0]{url} or return;
_save_cache($urpm);
}
- if ($cache->{nb_uses}++) {
- $urpm->{debug} and $urpm->{debug}("using mirror $cache->{chosen}");
- } else {
- $urpm->{log}("using mirror $cache->{chosen}");
- }
-
$cache;
}
#- side-effects: $urpm->{mirrors_cache}