From 911218913fc33bc8155782a2c26cb92bbd9dae2a Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Mon, 13 Sep 2004 05:39:52 +0000 Subject: Ability to choose from the mirror list when assing an ftp supplementary media. Fix download of hdlists file for ftp supplementary media. --- perl-install/install_any.pm | 12 ++++++++++-- perl-install/install_steps.pm | 1 + perl-install/install_steps_interactive.pm | 32 ++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-) (limited to 'perl-install') diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index ca65b0c7b..5d4feaf65 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -199,7 +199,7 @@ sub getFile { crypto::getFile($f); } elsif ($current_method eq "ftp") { require ftp; - ftp::getFile($rel, @{ $::o->{packages}{mediums}{$asked_medium}{ftp_prefix} || [] }); + ftp::getFile($rel, @{ $::o->{packages}{mediums}{$asked_medium}{ftp_prefix} || our $global_ftp_prefix || [] }); } elsif ($current_method eq "http") { require http; http::getFile(($ENV{URLPREFIX} || $o_altroot) . "/$rel"); @@ -475,7 +475,15 @@ sub selectSupplMedia { } } } else { - my $url = $o->ask_from_entry('', N("URL of the mirror?")) or return ''; + my $url; + local our $global_ftp_prefix; + if ($suppl_method eq 'ftp') { #- mirrors are ftp only (currently) + $url = $o->askSupplMirror(N("URL of the mirror?")) or return ''; + $url =~ m!^ftp://(?:(.*?)(?::(.*?))?@)?([^/]+)/(.*)! + and $global_ftp_prefix = [ $3, $4, $1, $2 ]; #- for getFile + } else { + my $url = $o->ask_from_entry('', N("URL of the mirror?")) or return ''; + } useMedium($medium_name); require "$suppl_method.pm"; #- require http or ftp #- first, try to find an hdlists file diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 6f4f49070..1258fbb2d 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -299,6 +299,7 @@ sub deselectFoundMedia { } sub selectSupplMedia { '' } +sub askSupplMirror { '' } sub choosePackages { my ($o, $packages, $_compssUsers, $first_time) = @_; diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 036ac87fe..838750637 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -1,7 +1,6 @@ package install_steps_interactive; # $Id$ -use diagnostics; use strict; use vars qw(@ISA $new_bootstrap); @@ -396,6 +395,37 @@ sub deselectFoundMedia { my ($o, $p) = @_; install_any::deselectFoundMedia($o, $p); } + +sub mirror2text { $crypto::mirrors{$_[0]} ? $crypto::mirrors{$_[0]}[0] . '|' . $_[0] : "-|URL" } +sub askSupplMirror { + my ($o, $message) = @_; + my $u = $o->{updates} ||= {}; + require crypto; + my @mirrors = do { + my $_w = $o->wait_message('', N("Contacting Mandrakelinux web site to get the list of available mirrors...")); + crypto::mirrors($o->{distro_type}); + }; + push @mirrors, '-'; + $o->ask_from_( + { + messages => N("Choose a mirror from which to get the packages"), + cancel => N("Cancel"), + }, + [ { separator => '|', + format => \&mirror2text, + list => \@mirrors, + val => \$u->{mirror}, + }, ], + ) or $u->{mirror} = ''; + if ($u->{mirror} eq '-') { + return $o->ask_from_entry('', $message) || ''; + } + my $url = "ftp://$u->{mirror}$crypto::mirrors{$u->{mirror}}[1]"; + $url =~ s/\bmedia\/?$//; + log::l("mirror chosen [$url]"); + return $url; +} + sub selectSupplMedia { my ($o, $suppl_method) = @_; install_any::selectSupplMedia($o, $suppl_method); -- cgit v1.2.1