diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-09-04 07:56:16 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-09-04 07:56:16 +0000 |
commit | 6ae3df8b164d3e77e30fd2b7dfc4edafab616380 (patch) | |
tree | d6f5eeadb502148b384fd1a96c8b3494bff940f9 | |
parent | b39c0519989af0611ae217b01c026e8e158b101a (diff) | |
download | urpmi-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"
-rw-r--r-- | urpm/download.pm | 7 | ||||
-rw-r--r-- | urpm/mirrors.pm | 25 |
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} |