From 5c59aff6bd4ec774070568a3c23bc4f467643eb7 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 19 Nov 2022 09:26:09 +0000 Subject: Move ask_mirror() from install::any to any. This makes it available for use by draklive-install. --- perl-install/install/any.pm | 71 +-------------------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) (limited to 'perl-install/install') diff --git a/perl-install/install/any.pm b/perl-install/install/any.pm index a55de478d..78bb16eaf 100644 --- a/perl-install/install/any.pm +++ b/perl-install/install/any.pm @@ -210,80 +210,11 @@ sub prep_net_suppl_media { sleep(3); } -=item ask_url($in, $o_url) - -Asks URL of the mirror - -=cut - -sub ask_url { - my ($in, $o_url) = @_; - - my $url = $o_url; - $in->ask_from_({ messages => N("URL of the mirror?"), focus_first => 1 }, [ - { val => \$url, - validate => sub { - if ($url =~ m!^(http|ftp)://!) { - 1; - } else { - $in->ask_warn('', N("URL must start with ftp:// or http://")); - 0; - } - } } ]) && $url; -} - -=item ask_mirror($o, $type, $o_url) - -Retrieves list of mirrors and offers to pick one - -=cut - -sub ask_mirror { - my ($o, $type, $o_url) = @_; - - require mirror; - - my $mirrors = eval { - my $_w = $o->wait_message('', N("Contacting %s web site to get the list of available mirrors...", N("Mageia"))); - mirror::list($o->{product_id}, $type); - }; - my $err = $@; - if (!$mirrors) { - $o->ask_warn('', N("Failed contacting %s web site to get the list of available mirrors", N("Mageia")) . "\n$err"); - return ask_url($o, $o_url); - } - - my $give_url = { country => '-', host => 'URL' }; - - my $mirror = $o_url ? (find { $_->{url} eq $o_url } @$mirrors) || $give_url - #- use current time zone to select best mirror - : mirror::nearest($o->{timezone}{timezone}, $mirrors); - - $o->ask_from_({ messages => N("Choose a mirror from which to get the packages"), - cancel => N("Cancel"), - }, [ { separator => '|', - format => \&mirror::mirror2text, - list => [ @$mirrors, $give_url ], - val => \$mirror, - }, - ]) or return; - - my $url; - if ($mirror eq $give_url) { - $url = ask_url($o, $o_url) or goto &ask_mirror; - } else { - $url = $mirror->{url}; - } - $url =~ s!/main/?$!!; - log::l("chosen mirror: $url"); - $url; -} - sub ask_suppl_media_url { my ($o, $method, $o_url) = @_; if (member($method, qw(ftp http))) { - install::any::ask_mirror($o, 'distrib', $o_url); + any::ask_mirror($o, 'distrib', $o_url); } elsif ($method eq 'nfs') { my ($host, $dir) = $o_url ? $o_url =~ m!nfs://(.*?)(/.*)! : (); $o->ask_from_( -- cgit v1.2.1