From 1ac2349ae9e3dbb5c0a7f8a01cacf29428bcd7fe Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 1 Mar 2004 10:48:24 +0000 Subject: do not use $o in crypto.pm, pass {distro_type} to mirrors() and bestMirror() instead --- perl-install/crypto.pm | 16 +++++++++------- perl-install/install_steps_interactive.pm | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'perl-install') diff --git a/perl-install/crypto.pm b/perl-install/crypto.pm index a8fa6f9ec..d5326737b 100644 --- a/perl-install/crypto.pm +++ b/perl-install/crypto.pm @@ -3,7 +3,7 @@ package crypto; # $Id$ use diagnostics; use strict; -use vars qw($o %url2land %land2tzs %static_mirrors %mirrors); +use vars qw(%url2land %land2tzs %static_mirrors %mirrors); use MDK::Common::System; use common; @@ -45,7 +45,9 @@ use ftp; %mirrors = (); sub mirror2text { $mirrors{$_[0]} && $mirrors{$_[0]}[0] . '|' . $_[0] } -sub mirrors() { +sub mirrors { + my ($o_distro_type) = @_; + unless (keys %mirrors) { #- contact the following URL to retrieve list of mirror. #- http://www.linux-mandrake.com/mirrorsfull.list @@ -54,9 +56,9 @@ sub mirrors() { local $SIG{ALRM} = sub { die "timeout" }; alarm 60; - my $type = $o->{distro_type} || 'updates'; + my $distro_type = $o_distro_type || 'updates'; foreach (<$f>) { - my ($arch, $url, $dir) = m|$type([^:]*):ftp://([^/]*)(/\S*)| or next; + my ($arch, $url, $dir) = m|$distro_type([^:]*):ftp://([^/]*)(/\S*)| or next; MDK::Common::System::compat_arch($arch) or log::l("ignoring updates from $url because of incompatible arch: $arch"), next; my $land = N("United States"); @@ -76,12 +78,12 @@ sub mirrors() { } sub bestMirror { - my ($string) = @_; + my ($string, $o_distro_type) = @_; my %mirror2value; - foreach my $url (mirrors()) { + foreach my $url (mirrors($o_distro_type)) { my $value = 0; - my $cvalue = mirrors(); + my $cvalue = mirrors($o_distro_type); $mirror2value{$url} ||= 1 + $cvalue; foreach (@{$land2tzs{$mirrors{$url}[0]} || []}) { diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 0922af7ab..02f032b8f 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -780,9 +780,10 @@ Do you want to install the updates ?")), eval { my @mirrors = do { my $_w = $o->wait_message('', N("Contacting Mandrake Linux web site to get the list of available mirrors...")); - crypto::mirrors() }; + crypto::mirrors($o->{distro_type}); + }; #- if no mirror have been found, use current time zone and propose among available. - $u->{mirror} ||= crypto::bestMirror($o->{timezone}{timezone}); + $u->{mirror} ||= crypto::bestMirror($o->{timezone}{timezone}, $o->{distro_type}); $o->ask_from_({ messages => N("Choose a mirror from which to get the packages"), cancel => N("Cancel"), }, [ { separator => '|', -- cgit v1.2.1