"Fossies" - the Fresh Open Source Software Archive 
Member "install-tl-20231204/tlpkg/installer/install-menu-extl.pl" (20 Feb 2023, 5462 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-2021 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 do_remote_init();
61 print STDOUT "endload\n\n";
62
63 # %vars hash should eventually include each binary, collection and scheme
64 # as individual schalars.
65 # the above sub adds all platforms and collections to %vars
66 # but maybe not schemes so we add these now:
67
68 foreach my $pkg ($tlpdb->schemes) {
69 $vars{$pkg}=($vars{'selected_scheme'} eq $pkg)? 1:0;
70 }
71 $vars{'scheme-custom'} = 0 unless defined $vars{'scheme-custom'};
72
73 # reading back current %vars from the frontend
74 sub read_vars {
75 my $l = <STDIN>;
76 chomp $l;
77 if ($l ne 'vars') {
78 return 0;
79 }
80 while (1) {
81 $l = <STDIN>;
82 chomp $l;
83 if ($l =~ /^([^:]+): (.*)$/) {
84 $vars{$1} = $2;
85 } elsif ($l eq 'endvars') {
86 $vars{'free_size'} = TeXLive::TLUtils::diskfree($vars{'TEXDIR'});
87 return 1;
88 } else {
89 return 0;
90 }
91 }
92 return 0;
93 }
94
95 # for each scheme and collection, print name, category and short description
96 sub print_descs {
97 print "descs\n";
98 foreach my $p ($tlpdb->schemes) {
99 my $pkg = $tlpdb->get_package($p);
100 print $pkg->name, ': ', $pkg->category, ' ', $pkg->shortdesc || "", "\n";
101 }
102 foreach my $p ($tlpdb->collections) {
103 my $pkg = $tlpdb->get_package($p);
104 print $pkg->name, ': ', $pkg->category, ' ', $pkg->shortdesc || "", "\n";
105 }
106 print "enddescs\n";
107 }
108
109 sub print_vars {
110 print "vars\n";
111 foreach my $key (sort keys %vars) {
112 print $key, ': ', $vars{$key}, "\n";
113 }
114 print "endvars\n";
115 }
116
117 # run_menu_extl should be invoked by install-tl
118
119 sub run_menu_extl {
120 # make sure we have a value for total_size:
121 calc_depends();
122 print "menudata\n";
123 print "year: $texlive_release\n";
124 print "svn: $::installerrevision\n";
125 # for windows, add a key indicating elevated permissions
126 if (wndws()) {
127 print "admin: ". TeXLive::TLWinGoo::admin() . "\n";
128 }
129 print_descs();
130
131 print_vars();
132
133 # tell the frontend the preferred order for schemes
134 my @schemes = schemes_ordered_for_presentation();
135 push @schemes, "scheme-custom";
136 print "schemes_order: ", join(' ', @schemes), "\n";
137
138 # binaries
139 print "binaries\n";
140 # binaries aren't packages; list their descriptions here
141 my @binaries = $tlpdb->available_architectures;
142 @binaries=sort TeXLive::TLUtils::sort_archs @binaries;
143 foreach my $b (@binaries) {
144 print $b, ': ', platform_desc($b), "\n";
145 }
146 print "endbinaries\n";
147
148 print "endmenudata\n"; # this triggers the frontend menu
149
150 # read input from frontend / install-tl-gui.tcl.
151 # Four cases to consider:
152 # 'calc': the frontend wants to update its ::vars array
153 # after some menu choices
154 # 'checkdir': check whether $vars{TEXDIR} is creatable
155 # 'startinst': done with choices, tell install-tl to
156 # start installation
157 # 'quit': tell install-tl to clean up and quit
158
159 # read from frontend
160 while (1) {
161 my $l = <STDIN>;
162 chomp($l);
163 if ($l eq 'quit') {
164 return $MENU_QUIT;
165 } elsif ($l eq 'calc') {
166 if (read_vars()) {
167 if ($vars{'selected_scheme'} eq 'scheme-custom') {
168 calc_depends();
169 } else {
170 select_scheme($vars{'selected_scheme'});
171 }
172 $vars{'n_collections_selected'} = 0;
173 foreach my $v (keys %vars) {
174 if (substr($v, 0, 11) eq 'collection-' && $vars{$v}) {
175 $vars{'n_collections_selected'} += 1;
176 }
177 }
178 print_vars();
179 } else {
180 log("Illegal input '$l' from frontend");
181 return $MENU_ABORT;
182 }
183 } elsif ($l eq 'checkdir') {
184 my $td = <STDIN>;
185 chomp $td;
186 if (TeXLive::TLUtils::texdir_check($td)) {
187 print "1\n";
188 } else {
189 print "0\n";
190 }
191 } elsif ($l eq 'startinst') {
192 if (read_vars()) {
193 calc_depends();
194 return $MENU_INSTALL;
195 } else {
196 return $MENU_ABORT;
197 }
198 } else {
199 return $MENU_ABORT;
200 }
201 }
202 } # run_menu_extl
203 $::run_menu = \&run_menu_extl;
204
205
206 1;