summaryrefslogtreecommitdiffstats
path: root/perl-install/any.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/any.pm')
-rw-r--r--perl-install/any.pm75
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;