diff options
author | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2008-07-09 22:55:39 +0000 |
---|---|---|
committer | Per Øyvind Karlsen <peroyvind@mandriva.org> | 2008-07-09 22:55:39 +0000 |
commit | b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a (patch) | |
tree | a4527c4b694df2ab427fe690d963c75e9acfc049 | |
parent | fe66c0ff9b63a02eb65dabeafe2156f1509dcdae (diff) | |
download | urpmi-b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a.tar urpmi-b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a.tar.gz urpmi-b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a.tar.bz2 urpmi-b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a.tar.xz urpmi-b6cdf9b6b4f43b7a0b12f8d11485809cdf1a2c7a.zip |
clean up with help from pixel's suggestions
-rw-r--r-- | urpm/download.pm | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/urpm/download.pm b/urpm/download.pm index 885b9a26..d7e62e24 100644 --- a/urpm/download.pm +++ b/urpm/download.pm @@ -872,52 +872,49 @@ sub _create_metalink_ { if(! $options->{media}){ return; } - my $mirror; + my $mirrors; foreach my $medium (@{$urpm->{media} || []}){ if($medium->{name} eq $options->{media}){ my $mirrorlist = $medium->{mirrorlist}; - $mirror = $urpm->{mirrors_cache}->{$mirrorlist}; + $mirrors = $urpm->{mirrors_cache}->{$mirrorlist}; } } my $metalinkfile = "$urpm->{cachedir}/$options->{media}.metalink"; - my $metalink = '<?xml version="1.0" encoding="utf-8"?>'."\n"; - $metalink = $metalink.'<metalink version="3.0" generator="URPMI"'."\n"; - $metalink = $metalink.'xmlns="http://www.metalinker.org/">'."\n"; - $metalink = $metalink.'<files>'."\n"; - - for(my $i = 0; $i < @$files; $i++){ - my $append = @$files[$i]; - $append =~ s/$mirror->{chosen}//; - $metalink = $metalink."\t<file name=\"".basename($append)."\">\n"; - $metalink = $metalink."\t\t<resources>\n"; - - for(my $i = 0; $i < @{$mirror->{list}}; $i++){ - my $type = $mirror->{list}[$i]->{url}; + my $metalink = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; + $metalink .= "<metalink version=\"3.0\" generator=\"URPMI\"\n"; + $metalink .= "xmlns=\"http://www.metalinker.org/\">\n"; + $metalink .= "<files>\n"; + + foreach my $append (@$files) { + $append =~ s/$mirrors->{chosen}//; + $metalink .= "\t<file name=\"".basename($append)."\">\n"; + $metalink .= "\t\t<resources>\n"; + + my $i = 0; foreach my $mirror (@{$mirrors->{list}}) { $i++; + my $type = $mirror->{url}; $type =~ s/:\/\/.*//; my $preference = 100-$i; # If more than 100 mirrors, give all the remaining mirrors a priority of 0 - if($preference < 0){ - $preference = 0; - } - $metalink = $metalink."\t\t\t<url type=\"$type\" preference=\"$preference\""; + my $preference = max(0, 100 - $i); + $metalink .= "\t\t\t<url type=\"$type\" preference=\"$preference\""; # Not supported in metalinks #if(@$list[$i]->{bw}){ - # $metalink = $metalink." bandwidth=\"".@$list[$i]->{bw}."\" "; + # $metalink .= " bandwidth=\"".@$list[$i]->{bw}."\" "; # } # Supported in metalinks, but no longer used in mirror list..? - if($mirror->{list}[$i]->{connections}){ - $metalink = $metalink." maxconnections=\"".$mirror->{list}[$i]->{connections}."\""; + if($mirror->{connections}){ + $metalink .= " maxconnections=\"".$mirror->{connections}."\""; } - $metalink = $metalink." location=\"".lc($mirror->{list}[$i]->{zone})."\">".$mirror->{list}[$i]->{url}.$append."</url>\n"; + $metalink .= " location=\"".lc($mirror->{zone})."\">".$mirror->{url}.$append."</url>\n"; } - $metalink = $metalink."\t\t</resources>\n"; - $metalink = $metalink."\t</file>\n"; - @$files[$i] = "$metalinkfile:$append"; + $metalink .= "\t\t</resources>\n"; + $metalink .= "\t</file>\n"; + $append = "$metalinkfile:$append"; } - $metalink = $metalink."</files>\n</metalink>\n"; + $metalink .= "</files>\n</metalink>\n"; - output_safe("$metalinkfile", $metalink); + output_safe($metalinkfile, $metalink); } 1; |