summaryrefslogtreecommitdiffstats
path: root/urpm
diff options
context:
space:
mode:
Diffstat (limited to 'urpm')
-rw-r--r--urpm/download.pm7
-rw-r--r--urpm/mirrors.pm25
2 files changed, 22 insertions, 10 deletions
diff --git a/urpm/download.pm b/urpm/download.pm
index 47e25a75..53e47467 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -925,7 +925,9 @@ sub _create_metalink_ {
# Don't create a metalink when downloading mirror list
$medium or return;
- my $mirrors = $urpm->{mirrors_cache}{$medium->{mirrorlist}};
+ # only use the 8 best mirrors, then we let aria2 choose
+ require urpm::mirrors;
+ my @mirrors = map { _take_n_elem(8, @$_) } urpm::mirrors::list_urls($urpm, $medium, '');
my $metalinkfile = "$urpm->{cachedir}/$options->{media}.metalink";
# Even if not required by metalink spec, this line is needed at top of
@@ -936,9 +938,6 @@ sub _create_metalink_ {
'<files>',
);
- # only use the 8 best mirrors, then we let aria2 choose
- my @mirrors = _take_n_elem(8, @{$mirrors->{list}});
-
foreach my $rel_file (@$rel_files) {
my $i = 0;
my @lines = map {
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}