summaryrefslogtreecommitdiffstats
path: root/urpm/download.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-04 07:10:25 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-04 07:10:25 +0000
commit074d51f05f535f13ed474e36757dd9b7a93756f8 (patch)
tree016bb89aca628804723253803d14312fdb4fb284 /urpm/download.pm
parent454c2b4eb035bdaee59cbcfca1f8c85f7f454312 (diff)
downloadurpmi-074d51f05f535f13ed474e36757dd9b7a93756f8.tar
urpmi-074d51f05f535f13ed474e36757dd9b7a93756f8.tar.gz
urpmi-074d51f05f535f13ed474e36757dd9b7a93756f8.tar.bz2
urpmi-074d51f05f535f13ed474e36757dd9b7a93756f8.tar.xz
urpmi-074d51f05f535f13ed474e36757dd9b7a93756f8.zip
create _create_one_metalink_line() out of _create_metalink_()
Diffstat (limited to 'urpm/download.pm')
-rw-r--r--urpm/download.pm42
1 files changed, 24 insertions, 18 deletions
diff --git a/urpm/download.pm b/urpm/download.pm
index c626ca6c..d39d52b3 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -897,6 +897,29 @@ sub _take_n_elem {
@l < $n ? @l : @l[0 .. $n-1];
}
+sub _create_one_metalink_line {
+ my ($medium, $mirror, $rel_file, $counter) = @_;
+
+ my $type = $mirror->{url};
+ $type =~ s!://.*!!;
+
+ # If more than 100 mirrors, give all the remaining mirrors a priority of 0
+ my $preference = max(0, 100 - $counter);
+
+ my @options = (qq(type="$type"), qq(preference="$preference"));
+ # Not supported in metalinks
+ #if (@$list[$i]->{bw}) {
+ # push @options, 'bandwidth="' . @$list[$i]->{bw} . '"';
+ # }
+ # Supported in metalinks, but no longer used in mirror list..?
+ if ($mirror->{connections}) {
+ push @options, qq(maxconnections=") . $mirror->{connections} . qq(");
+ }
+ push @options, 'location="' . lc($mirror->{zone}) . '"';
+ my $base = urpm::mirrors::_add__with_dir($mirror->{url}, $medium->{'with-dir'});
+ sprintf(qq(<url %s>%s/%s</url>), join(' ', @options), $base, $rel_file);
+}
+
sub _create_metalink_ {
my ($urpm, $medium, $rel_files, $options) = @_;
# Don't create a metalink when downloading mirror list
@@ -924,24 +947,7 @@ sub _create_metalink_ {
my $i = 0;
foreach my $mirror (@mirrors) {
$i++;
- my $type = $mirror->{url};
- $type =~ s!://.*!!;
- # If more than 100 mirrors, give all the remaining mirrors a priority of 0
- my $preference = max(0, 100 - $i);
-
- my @options = (qq(type="$type"), qq(preference="$preference"));
- # Not supported in metalinks
- #if (@$list[$i]->{bw}) {
- # push @options, 'bandwidth="' . @$list[$i]->{bw} . '"';
- # }
- # Supported in metalinks, but no longer used in mirror list..?
- if ($mirror->{connections}) {
- push @options, qq(maxconnections=") . $mirror->{connections} . qq(");
- }
- push @options, 'location="' . lc($mirror->{zone}) . '"';
- my $base = urpm::mirrors::_add__with_dir($mirror->{url}, $medium->{'with-dir'});
- push @metalink,
- sprintf(qq(\t\t\t<url %s>%s/%s</url>), join(' ', @options), $base, $rel_file);
+ push @metalink, "\t\t\t" . _create_one_metalink_line($medium, $mirror, $rel_file, $i);
}
push @metalink, "\t\t</resources>";
push @metalink, "\t</file>";