1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
|
#!/usr/bin/env perl
#
# $Id$
#
# Copyright 2008 Norbert Preining
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
# This file WILL implements the text based menu system for the TeX Live installer.
#
#
# MISSING SUPPORT FOR:
# - update systems from net
# - TEXMFHOME ???
our %vars;
our $tlpdb;
our @collections_std;
our @collections_lang;
our @collections_lang_doc;
our $texlive_release;
our $trynet;
our $max_bins_on_CD;
our $MENU_INSTALL = 0;
our $MENU_ABORT = 1;
our $MENU_QUIT = 2;
my $return = $MENU_INSTALL;
require Tk;
my $mw;
my $bintextbutton;
my $schemebutton;
my $collectionstext;
my $texmflocaltext;
my $texmfsysvartext;
my $texdirtext;
my $symlinktext;
sub run_menu {
calc_depends;
$mw = MainWindow->new;
$mw->Label(-text => 'TeX Live 2008 Installation')->pack;
$bintextbutton = $mw->Button(
-command => sub { menu_select_binsystems(); }
);
$bintextbutton->pack;
$schemebutton = $mw->Button(
-command => sub { menu_select_scheme(); }
);
$schemebutton->pack;
$mw->Label(-text => 'Customizing installation scheme')->pack;
$mw->Button(
-text => "Standard Collections",
-command => sub { menu_select_standard_collections(); }
)->pack;
$mw->Button(
-text => "Language Collections",
-command => sub { menu_select_lang_collections(); }
)->pack;
$collectionstext = $mw->Label();
$collectionstext->pack;
#$mw->Button(
# -text => "Directories' setup",
# -command => sub { notimpl(); }
#)->pack;
$mw->Label(-text => "Directories' setup")->pack;
$texdirtext = $mw->Button(
-command => sub { menu_edit_vars_value("TEXDIR"); } );
$texmflocaltext = $mw->Button(
-command => sub { menu_edit_vars_value("TEXMFLOCAL"); } );
$texmfsysvartext = $mw->Button(
-command => sub { menu_edit_vars_value("TEXMFSYSVAR"); } );
$texdirtext->pack;
$texmflocaltext->pack;
$texmfsysvartext->pack;
$mw->Checkbutton(-variable => \$vars{'option_letter'}, -text => "use letter size instead of A4 by default")->pack;
$mw->Checkbutton(-variable => \$vars{'option_fmt'}, -text => "create all format files")->pack;
$mw->Checkbutton(-variable => \$vars{'option_doc'}, -text => "install font/macro doc tree")->pack;
$mw->Checkbutton(-variable => \$vars{'option_src'}, -text => "install font/macro source tree")->pack;
if (unix()) {
$symlinktext = $mw->Button(-command => sub { menu_select_symlink(); })->pack;
}
my $f3 = $mw->Frame;
$f3->Button(
-text => 'Go!',
-command => sub { $return = $MENU_INSTALL; $mw->destroy },
)->pack(-side => 'left');
$f3->Button(
-text => 'Cancel',
-command => sub { $return = $MENU_ABORT; $mw->destroy }
)->pack(-side => 'right');
$f3->pack(-expand => 'x');
menu_update_texts();
Tk::MainLoop();
return($return);
}
sub notimpl {
my $errorwin = $mw->Toplevel;
$errorwin->Button(-text => "Not implemented yet!",
-command => [ $errorwin => 'destroy' ])->pack;
}
sub menu_edit_vars_value {
my $key = shift;
my $sw = $mw->Toplevel;
my $val = $vars{$key};
$sw->Label(-text => "Enter path for $key:")->pack;
my $entry = $sw->Entry(-textvariable => $val, -width => 0);
$entry->pack;
$sw->Button(-text => "Ok",
-command => sub { $val = $entry->get; callback_edit_directories($key,$val) ; $sw->destroy })->pack;
$sw->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack;
}
sub menu_select_scheme {
my $sw = $mw->Toplevel;
my @schemes;
foreach my $pkg ($tlpdb->list_packages) {
my $tlpobj = $tlpdb->{'tlps'}{$pkg};
if ($tlpobj->category eq "Scheme") {
push @schemes, $pkg;
$vars{"$pkg"}=($vars{'selected_scheme'} eq $pkg)? 1:0;
}
}
@schemes=sort @schemes;
my $selected = $vars{'selected_scheme'};
$sw->Label(-text => 'Select Scheme')->pack;
my $f2 = $sw->Frame;
my $f2l = $f2->Frame;
my $f2r = $f2->Frame;
my $nrfh = $#schemes / 2;
my $i = 0;
foreach my $scheme (@schemes) {
if ($i < $nrfh) {
$f2l->Radiobutton(-variable => \$selected, -value => $scheme,
-text => $scheme)->pack(-anchor => 'w');
} else {
$f2r->Radiobutton(-variable => \$selected, -value => $scheme,
-text => $scheme)->pack(-anchor => 'w');
}
$i++;
}
$f2l->pack(-side => 'left');
$f2r->pack(-side => 'right');
$f2->pack;
my $f3 = $sw->Frame;
$f3->Button(-text => "Return",
-command => sub { callback_select_scheme($selected) ; $sw->destroy })->pack(-side => 'left');
$f3->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack(-side => 'right');
$f3->pack(-expand => 'x');
}
sub menu_select_standard_collections {
my $sw = $mw->Toplevel;
my $fb = $sw->Frame;
my $fc = $sw->Frame;
my $f1 = $fb->Frame;
my $f2 = $fb->Frame;
$sw->Label(-text => 'Select the collections to be installed')->pack;
my $halfcol = $#collections_std / 2;
my $i = 0;
foreach my $coll (sort @collections_std) {
if ($i < $halfcol) {
$f1->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
} else {
$f2->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
}
$i++;
}
$f1->pack(-side => 'left');
$f2->pack(-side => 'right');
$fb->pack;
$fc->pack(-expand => 'x');
$fc->Button(-text => "Return",
-command => sub { callback_select_collection() ; $sw->destroy })->pack(-side => 'left');
$fc->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack(-side => 'right');
}
sub menu_select_lang_collections {
my $sw = $mw->Toplevel;
my $f1 = $sw->Frame;
$f1->pack;
my $f1lang = $f1->Frame;
my $f1doc = $f1->Frame;
$f1lang->pack(-side => 'left');
$f1doc->pack(-side => 'right');
my $f1langT = $f1lang->Frame; $f1langT->pack;
my $f1langL = $f1lang->Frame; $f1langL->pack;
$f1langT->Label(-text => 'Language Selection')->pack;
my $f1langLa = $f1langL->Frame; $f1langLa->pack(-side => 'left');
my $f1langLb = $f1langL->Frame; $f1langLb->pack(-side => 'right');
my $langh = $#collections_lang / 2;
my $i = 0;
foreach my $coll (sort @collections_lang) {
if ($i < $langh) {
$f1langLa->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
} else {
$f1langLb->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
}
$i++;
}
my $f1docT = $f1doc->Frame; $f1docT->pack;
my $f1docL = $f1doc->Frame; $f1docL->pack;
$f1docT->Label(-text => 'Doc/Language Selection')->pack;
my $f1docLa = $f1docL->Frame; $f1docLa->pack(-side => 'left');
my $f1docLb = $f1docL->Frame; $f1docLb->pack(-side => 'right');
my $doch = $#collections_lang_doc / 2;
$i = 0;
foreach my $coll (sort @collections_lang_doc) {
if ($i < $doch) {
$f1docLa->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
} else {
$f1docLb->Checkbutton(-variable => \$vars{$coll}, -text => $coll)->pack(-anchor => 'w');
}
$i++;
}
my $f2 = $sw->Frame; $f2->pack(-expand => 'x');
$f2->Button(-text => "Return",
-command => sub { callback_select_collection() ; $sw->destroy })->pack(-side => 'left');
$f2->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack(-side => 'right');
}
sub menu_select_symlink {
our ($lbin,$lman,$linfo);
our $osym = $vars{'option_symlinks'};
sub set_unset_buttons {
$lbin = ($osym ? $vars{'sys_bin'} : '');
$linfo = ($osym ? $vars{'sys_info'} : '');
$lman = ($osym ? $vars{'sys_man'} : '');
}
sub return_callback {
if ($osym) {
$vars{'sys_bin'} = $lbin;
$vars{'sys_info'} = $linfo;
$vars{'sys_man'} = $lman;
}
$vars{'option_symlinks'} = $osym;
menu_update_texts();
}
set_unset_buttons();
my $sw = $mw->Toplevel;
$sw->Checkbutton(-variable => \$osym,
-text => 'create symlinks in standard directories',
-command => sub { set_unset_buttons(); } )->pack;
my $fbin = $sw->Frame;
$fbin->Label(-text => 'binaries to: ')->pack(-side => 'left');
my $binb = $fbin->Entry(-textvariable => \$lbin, -width => 30);
$binb->pack(-side => 'right');
$fbin->pack(-expand => 'x');
my $fman = $sw->Frame;
$fman->Label(-text => 'manpages to: ')->pack(-side => 'left');
my $manb = $fman->Entry(-textvariable => \$lman, -width => 30);
$manb->pack(-side => 'right');
$fman->pack(-expand => 'x');
my $finfo = $sw->Frame;
$finfo->Label(-text => 'info to: ')->pack(-side => 'left');
my $infob = $finfo->Entry(-textvariable => \$linfo, -width => 30);
$infob->pack(-side => 'right');
$finfo->pack(-expand => 'x');
my $f2 = $sw->Frame; $f2->pack(-expand => 'x');
$f2->Button(-text => "Return",
-command => sub { return_callback(); $sw->destroy })->pack(-side => 'left');
$f2->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack(-side => 'right');
}
sub menu_select_binsystems {
my $sw = $mw->Toplevel;
my @diskarchs = ();
my @netarchs = ();
foreach my $key (keys %vars) {
if ($key=~/diskbin_(.*)/) {
push @diskarchs, $1;
$from_net{"$1"}=0;
}
if ($key=~/netbin_(.*)/) {
push @netarchs, $1;
$from_net{"$1"}=1;
}
}
$sw->Label(-text => 'Select arch/os')->pack;
my $f2 = $sw->Frame;
my $f2l = $f2->Frame;
my $f2r = $f2->Frame;
$f2l->Label(-text => 'On Disk')->pack;
foreach my $sys (sort @diskarchs) {
$f2l->Checkbutton(-variable => \$vars{"diskbin_$sys"}, -text => $sys)->pack(-anchor => 'w');
}
$f2l->pack(-side => 'left');
if ($#netarchs >= 0) {
$f2r->Label(-text => 'On Net')->pack;
foreach my $sys (sort @netarchs) {
$sw->Checkbutton(-variable => \$vars{"netbin_$sys"}, -text => "$sys")->pack(-anchor => 'w');
}
$f2r->pack(-side => 'right');
}
$f2->pack;
my $f3 = $sw->Frame;
$f3->Button(-text => "Return",
-command => sub { callback_select_systems() ; $sw->destroy })->pack(-side => 'left');
$f3->Button(-text => "Cancel",
-command => sub { $sw->destroy })->pack(-side => 'right');
$f3->pack(-expand => 'x');
}
sub menu_set_text {
my $w = shift;
my $t = shift;
$w->configure(-text => $t);
}
sub menu_set_symlink_text {
menu_set_text($symlinktext, "Install symlinks: " . (($vars{'option_symlinks'})?"Yes":"No"));
}
sub menu_set_schemebutton_text {
menu_set_text($schemebutton, "Selected Scheme: $vars{'selected_scheme'}");
}
sub menu_set_binbutton_text {
menu_set_text($bintextbutton, "Binary Systems $vars{'n_systems_selected'} out of $vars{'n_systems_available'}");
}
sub menu_set_collections_text {
menu_set_text($collectionstext, "$vars{'n_collections_selected'} collections out of $vars{'n_collections_available'}, disk space required: $vars{'total_size'} MB");
}
sub menu_set_pathes_text {
menu_set_text($texdirtext, "TEXDIR (The main TeX directory): $vars{'TEXDIR'}");
menu_set_text($texmflocaltext, "TEXMFLOCAL (Directory for local styles etc): $vars{'TEXMFLOCAL'}");
menu_set_text($texmfsysvartext, "TEXMFSYSVAR (Directory for local config): $vars{'TEXMFSYSVAR'}");
}
sub menu_update_texts {
menu_set_pathes_text;
menu_set_collections_text;
menu_set_binbutton_text;
menu_set_schemebutton_text;
if (unix()) { menu_set_symlink_text; };
}
sub callback_select_scheme {
my $s = shift;
select_scheme($s);
menu_update_texts();
}
sub callback_select_collection {
calc_depends();
update_numbers();
menu_update_texts();
}
sub callback_select_systems() {
calc_depends();
update_numbers();
menu_update_texts();
}
sub callback_edit_directories {
my ($key,$val) = @_;
$vars{$key} = $val;
if ($vars{'TEXDIR'}=~/^(.*)\/$texlive_release$/) {
$vars{'TEXMFLOCAL'}="$1/texmf-local";
$vars{'TEXMFSYSVAR'}="$1/$texlive_release/texmf-var";
} elsif ($vars{'TEXDIR'}=~/^(.*)$/) {
$vars{'TEXMFLOCAL'}="$1/texmf-local";
$vars{'TEXMFSYSVAR'}="$1/texmf-var";
}
menu_update_texts();
}
sub callback_edit_var() {
my ($key,$val) = @_;
$vars{$key} = $val;
menu_update_texts();
}
sub dump_vars_stdout {
foreach my $k (keys %vars) {
print "DEBUG: vars{$k} = $vars{$k}\n";
}
}
1;
|