diff options
author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2022-11-20 09:24:37 +0000 |
---|---|---|
committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2022-11-20 09:38:00 +0000 |
commit | 88419fd468b76cea82776ef590aa4e600bacdfeb (patch) | |
tree | 94b66a90118a1d8f80fc62e6304ced43694cada4 | |
parent | 5c59aff6bd4ec774070568a3c23bc4f467643eb7 (diff) | |
download | drakx-88419fd468b76cea82776ef590aa4e600bacdfeb.tar drakx-88419fd468b76cea82776ef590aa4e600bacdfeb.tar.gz drakx-88419fd468b76cea82776ef590aa4e600bacdfeb.tar.bz2 drakx-88419fd468b76cea82776ef590aa4e600bacdfeb.tar.xz drakx-88419fd468b76cea82776ef590aa4e600bacdfeb.zip |
Add a dialogue for choosing options for mirror selection and urpmi downloader.
-rw-r--r-- | perl-install/any.pm | 75 |
1 files changed, 75 insertions, 0 deletions
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<mirror_url>: the currently selected mirror URL ('$MIRRORLIST' for automatic selection) + +=item * B<downloader>: 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; |