summaryrefslogtreecommitdiff
path: root/Master/tlpkg/installer/install-menu-text.pl
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2011-09-13 01:18:50 +0000
committerNorbert Preining <preining@logic.at>2011-09-13 01:18:50 +0000
commit8403bdd44f7afb2d9b199f310f21f7d757d4d03f (patch)
tree60a656a6bbf1000344058dda3a793e890e9dbb53 /Master/tlpkg/installer/install-menu-text.pl
parent3872da8466c31b1cedc8fbf2c43edc1fb720d63d (diff)
support selecting a mirror in all the installers
git-svn-id: svn://tug.org/texlive/trunk@23929 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/installer/install-menu-text.pl')
-rwxr-xr-xMaster/tlpkg/installer/install-menu-text.pl103
1 files changed, 103 insertions, 0 deletions
diff --git a/Master/tlpkg/installer/install-menu-text.pl b/Master/tlpkg/installer/install-menu-text.pl
index 907e4c8f5e5..5f4c4e07b55 100755
--- a/Master/tlpkg/installer/install-menu-text.pl
+++ b/Master/tlpkg/installer/install-menu-text.pl
@@ -111,6 +111,109 @@ sub prompt {
# reference to another menu or to itself.
sub run_menu_text {
my (@args) = @_;
+ my $default = 0;
+ # select mirror if -select-mirror is given
+ if ($::opt_select_repository) {
+ # network is always available
+ my @mirror_list = TeXLive::TLUtils::create_mirror_list();
+ print "Please select a repository:\n";
+ print "Network repositories:\n" if ($#media_available >= 0);
+ my @sel_to_index;
+ my $selind = 0;
+ # this is for 0 mirror.ctan.org, but it is printed last!
+ push @sel_to_index, 0;
+ $selind++;
+ for my $i (0..$#mirror_list) {
+ if ($mirror_list[$i] !~ m/^ /) {
+ print "$mirror_list[$i]\n";
+ } else {
+ print "[$selind] $mirror_list[$i]\n";
+ push @sel_to_index, $i;
+ $selind++;
+ }
+ }
+ print "---\n";
+ print "[0] default mirror - http://mirror.ctan.org\n";
+ my $local_ind = "a";
+ if ($#media_available >= 0) {
+ print "Locally present repositories:\n";
+ # we have some local media present, propose to use it
+ for my $l (@media_available) {
+ my ($a, $b) = split ('#', $l);
+ if ($a eq 'local_compressed') {
+ print "[$local_ind] compressed archive at $b\n";
+ $default = $local_ind;
+ #$local_ind = chr(ord($local_ind)+1);
+ $local_ind++;
+ } elsif ($a eq 'local_uncompressed') {
+ print "[$local_ind] uncompressed archive at $b\n";
+ $default = $local_ind;
+ $local_ind++;
+ } elsif ($a eq 'NET') {
+ print "[$local_ind] cmd line repository: $b\n";
+ $default = $local_ind;
+ $local_ind++;
+ } else {
+ printf STDERR "Unknown media $l\n";
+ }
+ }
+ }
+ print "[q] quit\n";
+ $selind--;
+ my $selstr = "Your selection ";
+ if ($local_ind ne "a") {
+ # we got at least some local repository
+ if ($local_ind eq "b") {
+ $selstr .= "(a,0-$selind,q)";
+ $local_ind = chr(ord($local_ind)-1);
+ } else {
+ # that does not work!!!
+ #$local_ind--;
+ $local_ind = chr(ord($local_ind)-1);
+ $selstr .= "(a-$local_ind,0-$selind,q)";
+ }
+ }
+ $selstr .= " [$default]: ";
+ my $got_answer = 0;
+ my $ans = undef;
+ while (!defined($ans)) {
+ print $selstr;
+ $ans = readline(*STDIN);
+ if (!defined($ans)) {
+ print "Please select 'q' for quitting the program!\n";
+ } else {
+ chomp($ans);
+ $ans = $default if ($ans eq "");
+ if ($ans =~ m/^[0-9]+$/) {
+ if (0 <= $ans && $ans <= $selind) {
+ my $mfull;
+ if ($ans == 0) {
+ $::init_remote_needed = 'ctan';
+ } else {
+ # only if something else but the predefined mirror is selected
+ # we something here
+ $mfull = TeXLive::TLUtils::extract_mirror_entry($mirror_list[$sel_to_index[$ans]]);
+ print "selected mirror: ", $mfull, "\n";
+ $::init_remote_needed = $mfull;
+ }
+ }
+ } elsif ($ans =~ m/^[a-$local_ind]$/) {
+ my $i = ord($ans) - ord('a');
+ my $t = $media_available[$i];
+ $t =~ s/^[^#]*#//;
+ $::init_remote_needed = $t;
+ } elsif ($ans eq 'q' || $ans eq 'Q') {
+ print "Good bye.\n";
+ exit 0;
+ } else {
+ print "Not a valid answer.\n";
+ $ans = undef;
+ }
+ }
+ }
+ }
+ # run remote init
+ do_remote_init($::init_remote_needed);
# the text mode installer does not take interest in any argument
# but the -old-installation-found
while (@args) {