From 88419fd468b76cea82776ef590aa4e600bacdfeb Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 20 Nov 2022 09:24:37 +0000 Subject: Add a dialogue for choosing options for mirror selection and urpmi downloader. --- perl-install/any.pm | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'perl-install/any.pm') diff --git a/perl-install/any.pm b/perl-install/any.pm index 16102a5ee..698593f44 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -1912,4 +1912,79 @@ sub ask_mirror { $url; } +=item ask_mirror_and_downloader($in, $options, $o_downloader_only) + +Asks whether to automatically select the mirror (using $MIRRORLIST) or use +one specified by the user. Also asks whether to use the default downloader +or to use one specified by the user. + +Default values are supplied and user-entered values are returned in $options +which should be a reference to a hash containing the following fields: + +=over 4 + +=item * B: the currently selected mirror URL ('$MIRRORLIST' for automatic selection) + +=item * B: the currently selected downloader (undefined when using the default downloader) + +=back + +If $o_downloader_only is true, the mirror selection choice is not displayed. + +=cut + +sub ask_mirror_and_downloader { + my ($in, $options, $o_downloader_only) = @_; + + my $mirror_url = $options->{mirror_url} || ''; + my $downloader = $options->{downloader} || 'default'; + + my $mirror_choice = $mirror_url eq '$MIRRORLIST' ? 'automatic' : 'specific'; + + $in->ask_from_( + { + }, + [ + if_(!$o_downloader_only, + { label => N("Mirror choice"), val => \$mirror_choice, + type => 'combo', list => [ 'automatic', 'specific' ], + format => sub { + my ($choice) = @_; + +{ + 'automatic' => N("Automatic"), + 'specific' => N("Specific"), + }->{$choice}; + }, + }, + ), + { label => N("Downloader"), val => \$downloader, + type => 'combo', list => [ 'default', 'aria2', 'curl', 'wget' ], + format => sub { + my ($choice) = @_; + +{ + 'default' => N("Default"), + 'aria2' => 'aria2', + 'curl' => 'curl', + 'wget' => 'wget', + }->{$choice}; + }, + }, + ] + ) or return; + + if ($mirror_choice eq 'automatic') { + $mirror_url = '$MIRRORLIST'; + } elsif ($mirror_url eq '$MIRRORLIST') { + $mirror_url = undef; + } + if ($downloader eq 'default') { + $downloader = undef; + } + + $options->{mirror_url} = $mirror_url; + $options->{downloader} = $downloader; + + 1; +} + 1; -- cgit v1.2.1