"Fossies" - the Fresh Open Source Software Archive

Member "install-tl-20200916/tlpkg/installer/install-menu-extl.pl" (16 Jan 2020, 5628 Bytes) of package /linux/misc/install-tl-unx.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env perl
    2 # install-menu-extl.pl
    3 
    4 # Copyright 2018, 2019 Siep Kroonenberg
    5 
    6 # This file is licensed under the GNU General Public License version 2
    7 # or any later version.
    8 
    9 # tell the frontend about all configurable options and terminate
   10 # this output with an agreed-upon termination string.  the frontend
   11 # will get the required package database information from the back
   12 # end.  From this, it can deduce collections, schemes and platforms,
   13 # but not the names of platforms.
   14 
   15 # needed info:
   16 
   17 # binaries + descriptions
   18 # schemes
   19 # collections, probably per scheme
   20 # maybe directories to be configured
   21 
   22 # current options:
   23 
   24 # paper size a4 | letter
   25 # allow restricted toggle
   26 # generate formats
   27 # install docs
   28 # install sources
   29 # create symlinks | 2 aspects of desktop integration
   30 # switch to online CTAN
   31 
   32 # then read the selected options back from the frontend
   33 
   34 # when run_menu_extl reads 'startinst' from the frontend,
   35 # run_menu_extl returns to install-tl.
   36 # by then, the frontend has switched to non-blocking i/o
   37 # and will capture the output of the actual installation
   38 # on the fly inside a log window
   39 
   40 our %vars; # only contains simple scalars
   41 
   42 # from install-tl:
   43 # The global variable %vars is an associative list which contains all
   44 # variables and their values which can be changed by the user.
   45 # needs to be our since TeXLive::TLUtils uses it
   46 
   47 our $opt_in_place;
   48 our $tlpdb;
   49 our $media;
   50 our $previoustlpdb;
   51 our @collections_std;
   52 our $texlive_release;
   53 
   54 our $MENU_INSTALL = 0;
   55 our $MENU_ABORT   = 1; # no cleanup afterwards
   56 our $MENU_QUIT    = 2;
   57 
   58 my $RETURN = $MENU_INSTALL;
   59 
   60 # @fileassocdesc also defined in install-tl
   61 $::fileassocdesc[0] = "None";
   62 $::fileassocdesc[1] = "Only new";
   63 $::fileassocdesc[2] = "All";
   64 
   65 $::deskintdesc[0] = "None";
   66 $::deskintdesc[1] = "Menu shortcuts";
   67 $::deskintdesc[2] = "Launcher";
   68 
   69 do_remote_init();
   70 print STDOUT "endload\n\n";
   71 
   72 # %vars hash should eventually include each binary, collection and scheme
   73 # as individual schalars.
   74 # the above sub adds all platforms and collections to %vars
   75 # but maybe not schemes so we add these now:
   76 
   77 foreach my $pkg ($tlpdb->schemes) {
   78   $vars{$pkg}=($vars{'selected_scheme'} eq $pkg)? 1:0;
   79 }
   80 $vars{'scheme-custom'} = 0 unless defined $vars{'scheme-custom'};
   81 
   82 # reading back current %vars from the frontend
   83 sub read_vars {
   84   my $l = <STDIN>;
   85   chomp $l;
   86   if ($l ne 'vars') {
   87     return 0;
   88   }
   89   while (1) {
   90     $l = <STDIN>;
   91     chomp $l;
   92     if ($l =~ /^([^:]+): (.*)$/) {
   93       $vars{$1} = $2;
   94     } elsif ($l eq 'endvars') {
   95       return 1;
   96     } else {
   97       return 0;
   98     }
   99   }
  100   return 0;
  101 }
  102 
  103 # for each scheme and collection, print name, category and short description
  104 sub print_descs {
  105   print "descs\n";
  106   foreach my $p ($tlpdb->schemes) {
  107     my $pkg = $tlpdb->get_package($p);
  108     print $pkg->name, ': ', $pkg->category, ' ', $pkg->shortdesc || "", "\n";
  109   }
  110   foreach my $p ($tlpdb->collections) {
  111     my $pkg = $tlpdb->get_package($p);
  112     print $pkg->name, ': ', $pkg->category, ' ', $pkg->shortdesc || "", "\n";
  113   }
  114   print "enddescs\n";
  115 }
  116 
  117 sub print_vars {
  118   print "vars\n";
  119   foreach my $key (sort keys %vars) {
  120     print $key, ': ', $vars{$key}, "\n";
  121   }
  122   print "endvars\n";
  123 }
  124 
  125 # run_menu_extl should be invoked by install-tl
  126 
  127 sub run_menu_extl {
  128   # make sure we have a value for total_size:
  129   calc_depends();
  130   print "menudata\n";
  131   print "year: $texlive_release\n";
  132   print "svn: $::installerrevision\n";
  133   # for windows, add a key indicating elevated permissions
  134   if (win32()) {
  135     print "admin: ". TeXLive::TLWinGoo::admin() . "\n";
  136   }
  137   print_descs();
  138 
  139   print_vars();
  140 
  141   # tell the frontend the preferred order for schemes
  142   my @schemes = schemes_ordered_for_presentation();
  143   push @schemes, "scheme-custom";
  144   print "schemes_order: ", join(' ', @schemes), "\n";
  145 
  146   # binaries
  147   print "binaries\n";
  148   # binaries aren't packages; list their descriptions here
  149   my @binaries = $tlpdb->available_architectures;
  150   @binaries=sort TeXLive::TLUtils::sort_archs @binaries;
  151   foreach my $b (@binaries) {
  152     print $b, ': ', platform_desc($b), "\n";
  153   }
  154   print "endbinaries\n";
  155 
  156   print "endmenudata\n"; # this triggers the frontend menu
  157 
  158   # read input from frontend / install-tl-gui.tcl.
  159   # Four cases to consider:
  160   # 'calc': the frontend wants to update its ::vars array
  161   #   after some menu choices
  162   # 'checkdir': check whether $vars{TEXDIR} is creatable
  163   # 'startinst': done with choices, tell install-tl to
  164   #   start installation
  165   # 'quit': tell install-tl to clean up and quit
  166 
  167   # read from frontend
  168   while (1) {
  169     my $l = <STDIN>;
  170     chomp($l);
  171     if ($l eq 'quit') {
  172       return $MENU_QUIT;
  173     } elsif ($l eq 'calc') {
  174       if (read_vars()) {
  175         if ($vars{'selected_scheme'} eq 'scheme-custom') {
  176           calc_depends();
  177         } else {
  178           select_scheme($vars{'selected_scheme'});
  179         }
  180         $vars{'n_collections_selected'} = 0;
  181         foreach my $v (keys %vars) {
  182           if (substr($v, 0, 11) eq 'collection-' && $vars{$v}) {
  183             $vars{'n_collections_selected'} += 1;
  184           }
  185         }
  186         print_vars();
  187       } else {
  188         log("Illegal input '$l' from frontend");
  189         return $MENU_ABORT;
  190       }
  191     } elsif ($l eq 'checkdir') {
  192       my $td = <STDIN>;
  193       chomp $td;
  194       if (TeXLive::TLUtils::texdir_check($td)) {
  195         print "1\n";
  196       } else {
  197         print "0\n";
  198       }
  199     } elsif ($l eq 'startinst') {
  200       if (read_vars()) {
  201         calc_depends();
  202         return $MENU_INSTALL;
  203       } else {
  204         return $MENU_ABORT;
  205       }
  206     } else {
  207       return $MENU_ABORT;
  208     }
  209   }
  210 } # run_menu_extl
  211 
  212 $::run_menu = \&run_menu_extl;
  213 
  214 1;