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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
|
#!/usr/bin/env perl
# $Id$
#
# Copyright 2007 2008 Reinhard Kotucha, Norbert Preining
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
my $svnrev = '$Revision$';
$svnrev =~ m/: ([0-9]+) /;
$::installerrevision = $1;
# is now taken from 00texlive.config: release, $tlpdb->config_release;
our $texlive_release;
BEGIN {
$^W = 1;
my $me=$0;
$me=~s!\\!/!g if $^O=~/^MSWin(32|64)$/i;
if ($me=~m!/!) {
($::installerdir=$me)=~s!(.*)/.*$!$1!;
# we have to chdir to the Master ...
chdir($::installerdir);
} else {
$::installerdir='.';
}
# The installer uses a minimal subset of Perl for Windows. In order
# to avoid conflicts with other versions of Perl already installed on
# the system, we simply ignore them. The installer has to execute
# $::installerdir/tlpkg/bin/perl.exe and should not rely on any other
# Perl executable.
if ($^O=~/^MSWin(32|64)$/i) {
@INC="$::installerdir/tlpkg/installer/perllib";
}
unshift (@INC, "$::installerdir/tlpkg");
}
use TeXLive::TLUtils qw(initialize_installer media platform platform_desc
which getenv win32 unix program_exists
get_system_tmpdir member
mkdirhier make_var_skeleton make_local_skeleton install_package copy
install_packages dirname tllog setup_programs);
use TeXLive::TLPOBJ;
use TeXLive::TLPDB;
use TeXLive::TLConfig;
use Pod::Usage;
use Cwd 'abs_path';
if (win32) {
require TeXLive::TLWinGoo;
TeXLive::TLWinGoo->import( qw(
&wg_error
&win_version
&is_vista
&admin
&non_admin
®_country
&dir_writable
&expand_string
&global_tmpdir
&get_system_path
&get_user_path
&setenv_reg
&unsetenv_reg
&add_texbindir_to_path
&remove_texbindirs_from_path
®ister_script_type
&unregister_script_type
&broadcast_env
&update_assocs
&create_uninstaller
));
}
use Getopt::Long;
$Getopt::Long::autoabbrev=0;
use strict;
# debugging/logging cmd lines options:
# -q shut up terminal output
# -qq shut up also log file output
# -d set $::LOGLEVELFILE to $::LOG_DEBUG
# -dd set $::LOGLEVELFILE to $::LOG_DDEBUG
# -ddd set $::LOGLEVELFILE to $::LOG_DDDEBUG
#
$::LOGLEVELFILE = $::LOG_NORMAL;
$::LOGLEVELTERMINAL = $::LOG_NORMAL;
@::LOGLINES = ();
#
# $install{$packagename} == 1 if it should be installed
my %install;
# the default scheme to be installed
my $default_scheme='scheme-full';
# some arrays where the lists of collections to be installed are saved
# our for menus
our @collections_std;
our @collections_lang;
our @collections_lang_doc;
# for win dealing
#our $Registry;
# The global variable %vars is an associative list which contains all
# variables and their values which can be changed by the user.
# needs to be our since TeXLive::TLUtils uses it
our %vars=( # 'n_' means 'number of'.
'this_platform' => platform(),
'n_systems_available' => 0,
'n_systems_selected' => 0,
'n_collections_selected' => 0,
'n_collections_available' => 0,
'total_size' => 0,
'option_symlinks' => 0,
'sys_bin' => '/usr/local/bin',
'sys_man' => '/usr/local/man',
'sys_info' => '/usr/local/info',
'option_doc' => 1,
'option_src' => 1,
'option_fmt' => 0,
'option_letter' => 0,
'selected_scheme' => $default_scheme,
);
# option handling
my $opt_media = "";
my $opt_url = "";
my $opt_profile = "";
my $opt_no_cls=0;
my $opt_nogui = 0;
my $opt_debug = 0;
my $opt_ddebug = 0;
my $opt_dddebug = 0;
my $opt_quiet = 0;
my $opt_qquiet = 0;
my $opt_nonadmin = 0;
my $opt_arch = 0;
our $opt_portable = 0;
my $opt_help = 0;
my $opt_version = 0;
my $opt_gui = 0;
$opt_gui = 1 if (win32);
# default language for GUI installer
$::lang = "en";
GetOptions("media=s" => \$opt_media,
"profile=s"=> \$opt_profile,
"no-cls",
"gui", \$opt_gui,
"no-gui", \$opt_nogui,
"netarchive=s" => \$NetArchive,
"diskarchive=s" => \$DiskArchive,
"lang=s" => \$::opt_lang,
"print-arch" => \$opt_arch,
"portable" => \$opt_portable,
"d" => \$opt_debug,
"dd" => \$opt_ddebug,
"ddd" => \$opt_dddebug,
"q" => \$opt_quiet,
"qq" => \$opt_qquiet,
"url=s" => \$opt_url,
"version" => \$opt_version,
"help|?" => \$opt_help) or pod2usage(1);
if (win32()) {
pod2usage(-exitstatus => 0,
-verbose => 2,
-noperldoc => 1,
-output => \*STDOUT) if $opt_help;
} else {
pod2usage(-exitstatus => 0, -verbose => 2) if $opt_help;
}
if ($opt_version) {
print "TeX Live Cross Platform Installer, Revision $::installerrevision\n";
exit 0;
}
if (defined($::opt_lang)) {
$::lang = $::opt_lang;
}
if ($opt_quiet) {
$::LOGLEVELTERMINAL = $::LOG_ZERO;
}
if ($opt_qquiet) {
$::LOGLEVELTERMINAL = $::LOG_ZERO;
$::LOGLEVELFILE = $::LOG_ZERO;
}
if ($opt_debug) {
$::LOGLEVELFILE = $::LOG_DEBUG;
}
if ($opt_ddebug) {
$::LOGLEVELFILE = $::LOG_DDEBUG;
}
if ($opt_dddebug) {
$::LOGLEVELFILE = $::LOG_DDDEBUG;
}
if ("$opt_media" =~ m/^CD/i) {
$::_media_ = "CD";
} elsif ("$opt_media" =~ m/^NET/i) {
$::_media_ = "NET";
} elsif ("$opt_media" =~ m/^DVD/i) {
$::_media_ = "DVD";
}
if ("$opt_profile" ne "") {
if (-r "$opt_profile") {
tllog($::LOG_NORMAL, "Using automated installation using $opt_profile!");
} else {
$opt_profile = "";
tllog($::LOG_NORMAL, "Profile $opt_profile not readable, continuing in interactive mode!");
}
}
if ($opt_nonadmin and win32()) { non_admin(); }
if ("$opt_url" ne "") {
$TeXLiveURL = "$opt_url";
}
# the TLPDB instances we will use. $tlpdb is for the one from the installation
# media, while $localtlpdb is for the new installation
# $tlpdb must be our because it is used in install-menu-text.pl
our $tlpdb;
my $localtlpdb;
# $finished == 1 if the menu call already did the installation
my $finished = 0;
@::start_install_hook = ();
@::end_install_hook = ();
@::start_postinst_hook = ();
@::start_install_hook = ();
my $system_tmpdir=get_system_tmpdir();
if ($opt_arch) {
print platform;
exit 0;
} elsif ($opt_portable) {
$::LOGLEVELTERMINAL = $::LOG_ZERO;
# initialize_installer:
$::_media_ = "DVD";
$::_platform_ = platform();
$vars{'TEXDIR'} = getenv('TEXDIR');
if (not -d $vars{'TEXDIR'}.'/bin/'.$::_platform_) { # shouldn't happen
print "Platform ".$::_platform_." not supported\n";
exit 1;
}
# set_platforms_supported();
# set_texlive_default_dirs();
$vars{'TEXMFSYSVAR'} = getenv('TEXMFSYSVAR');
$vars{'TEXMFSYSCONFIG'} = getenv('TEXMFSYSCONFIG');
$vars{'TEXMFLOCAL'} = getenv('TEXMFLOCAL');
$vars{'TEXMFHOME'} = getenv('TEXMFHOME');
$vars{'TEXMFVAR'} = getenv('TEXMFVAR');
$vars{'TEXMFCONFIG'} = getenv('TEXMFCONFIG');
# initialize_collections();
# set_install_platform();
$vars{'this_platform'} = platform();
# do_installation();
# prepare_installation();
if (win32()) {
non_admin();
my $winpath = "$vars{'TEXDIR'}/bin/win32";
register_script_type(".texlua", "%TEXBINDIR%/texlua.exe");
update_assocs();
}
mkdirhier "$vars{'TEXMFCONFIG'}";
if (not -d "$vars{'TEXMFSYSVAR'}" ) {
print "About to generate some files... Press <enter>";
<STDIN>;
load_tlpdb();
$localtlpdb = $tlpdb;
$texlive_release = $tlpdb->config_release;
make_var_skeleton "$vars{'TEXMFSYSVAR'}";
#$localtlpdb=new TeXLive::TLPDB;
#$localtlpdb->root("$vars{'TEXDIR'}");
do_postinst_stuff();
}
close($::LOGFILE) if defined($::LOGFILE);
exit 0;
}
tllog($::LOG_NORMAL, "Platform: ", platform, " => \'", platform_desc(platform), "\'\n");
if (media() eq "DVD") {
tllog($::LOG_NORMAL, "Distribution: live (uncompressed)\n");
} elsif (media() eq "CD") {
tllog($::LOG_NORMAL, "Distribution: inst (compressed)\n");
} elsif (media() eq "NET") {
tllog($::LOG_NORMAL, "Distribution: net (downloading)\n");
} else {
tllog($::LOG_NORMAL, "Distribution: ", media(), "\n");
}
tllog($::LOG_NORMAL, "Directory for Temporary Files: '", $system_tmpdir, "\'\n");
tllog($::LOG_NORMAL, "Installer Directory: '$::installerdir'\n");
initialize_installer();
setup_programs("$::installerdir/tlpkg/installer", "$::_platform_");
load_tlpdb();
$texlive_release = $tlpdb->config_release;
set_platforms_supported();
set_texlive_default_dirs();
initialize_collections();
set_install_platform();
if ($opt_profile eq "") {
# do the normal interactive installation!
#
# here we could load different menu systems. Currently several things
# are "our" so that the menu implementation can use it. The $tlpdb, the
# %var, and all the @collection*
# install-menu-*.pl should implement a function run_menu() and should
# change ONLY stuff in %vars
# The allowed keys in %vars should be specified somewhere ...
# the menu implementation should return
# MENU_INSTALL do the installation
# MENU_ABORT abort every action immediately, no cleanup
# MENU_QUIT try to quit and clean up mess
our $MENU_INSTALL = 0;
our $MENU_ABORT = 1;
our $MENU_QUIT = 2;
our $MENU_ALREADYDONE = 3;
if ($opt_gui && !$opt_nogui) {
# try to load Tk.pm, but don't die if it doesn't work
eval { require Tk; };
if ($@) {
# that didn't work out, so warn the user and continue with text mode
tllog($::LOG_NORMAL, "Cannot load Tk, maybe something is missing!\n");
tllog($::LOG_NORMAL, "Error message from loading Tk:\n");
tllog($::LOG_NORMAL, "$@\n");
tllog($::LOG_NORMAL, "Continuing in Text Mode...\n");
$opt_gui = 0;
}
}
if ($opt_gui && !$opt_nogui) {
require("installer/install-menu-perltk.pl");
} else {
require("installer/install-menu-text.pl");
}
my $ret = run_menu();
if ($ret == $MENU_QUIT) {
# do_cleanup(); MISSING
flushlog();
exit(1);
}
if ($ret == $MENU_ABORT) {
# NO do_cleanup()!
flushlog();
exit(2);
}
if ($ret == $MENU_ALREADYDONE) {
tllog($::LOG_DEBUG, "run_menu has already done the work ... cleaning up!\n");
$finished = 1;
}
if (!$finished && ($ret != $MENU_INSTALL)) {
tllog($::LOG_NORMAL, "Unknown return value of run_menu: $ret\n");
exit(3);
}
} else {
read_profile("$opt_profile");
}
if (!$finished) {
# do the actual installation
do_installation();
}
# now open the log file and write out the log lines
# try to open a log file
if ($::LOGLEVELFILE > $::LOG_ZERO) {
if (open(LOGF,">$vars{'TEXDIR'}/install-tl.log")) {
$::LOGFILE = \*LOGF;
foreach my $line(@::LOGLINES) {
print $::LOGFILE "$line";
}
} else {
warn("Cannot create log file $vars{'TEXDIR'}/install-tl.log: $!\nNot writing out log lines!\n");
$::LOGLEVELFILE = $::LOG_ZERO;
}
}
# dump various things to the log file
if (defined($::LOGFILE)) {
print $::LOGFILE "\nDump of vars:\n";
foreach my $key (keys %vars) {
print $::LOGFILE "$key $vars{$key}\n";
}
create_profile($::LOGFILE);
}
dump_vars("$system_tmpdir/texlive.vars");
# write the profile out
create_profile("$vars{'TEXDIR'}/$InfraLocation/texlive.profile");
tllog($::LOG_DEBUG, "Profile written to $vars{'TEXDIR'}/$InfraLocation/texlive.profile\n");
# Close log file if present
close($::LOGFILE) if defined($::LOGFILE);
exit(0);
###################################################################
#
# FROM HERE ON ONLY SUBROUTINES
# NO VARIABLE DECLARATIONS
#
###################################################################
sub do_installation {
# do the actual installation
foreach my $h (@::start_install_hook) {
&$h();
}
calc_depends();
prepare_installation();
save_options_into_tlpdb();
do_install_packages();
if (win32()) {
do_win_registry_magic();
create_uninstaller($vars{'TEXDIR'});
}
foreach my $h (@::start_postinst_hook) {
&$h();
}
do_postinst_stuff();
$localtlpdb->save;
foreach my $h (@::end_install_hook) {
&$h();
}
}
sub dump_vars {
my $filename=shift;
my $fh;
if (ref($filename)) {
$fh = $filename;
} else {
open VARS, ">$filename";
$fh = \*VARS;
}
foreach my $key (keys %vars) {
print $fh "$key $vars{$key}\n";
}
close VARS if (!ref($filename));
tllog($::LOG_DEBUG, "\n%vars dumped to '$filename'.\n");
}
# Determine which platforms are supported.
sub set_platforms_supported {
my @binaries = $tlpdb->available_architectures;
for my $binary (@binaries) {
unless (defined $vars{"binary_$binary"}) {
$vars{"binary_$binary"}=0;
}
}
for my $key (keys %vars) {
++$vars{'n_systems_available'} if ($key=~/^binary/);
}
}
# Environment variables and default values on UNIX:
# TEXLIVE_INSTALL_PREFIX /usr/local/texlive => $tex_prefix
# TEXLIVE_INSTALL_TEXDIR $tex_prefix/2007 => $TEXDIR
# TEXLIVE_INSTALL_TEXMFSYSVAR $TEXDIR/texmf-var
# TEXLIVE_INSTALL_TEXMFLOCAL $tex_prefix/texmf-local
# TEXLIVE_INSTALL_TEXMFHOME '$HOME/texmf'
sub set_texlive_default_dirs {
my $tex_prefix;
my $texmfsysvar;
my $texmflocal;
my $texmfhome;
$tex_prefix=getenv('TEXLIVE_INSTALL_PREFIX');
if (win32) {
my $prog = getenv('ProgramFiles');
$tex_prefix ||= $prog . '/texlive';
# $tex_prefix ||= $prog . '/texlive' if TeXLive::TLWinGoo::dir_writable($prog);
# $tex_prefix||=getenv('USERPROFILE') . '/texlive';
} else {
$tex_prefix||='/usr/local/texlive';
}
$vars{'TEXDIR'}="$tex_prefix/$texlive_release";
$texmfsysvar=getenv('TEXLIVE_INSTALL_TEXMFSYSVAR');
$texmfsysvar||=$vars{'TEXDIR'} . '/texmf-var';
$vars{'TEXMFSYSVAR'}="$texmfsysvar";
$texmflocal=getenv('TEXLIVE_INSTALL_TEXMFLOCAL');
$texmflocal||="$tex_prefix/texmf-local";
$vars{'TEXMFLOCAL'}="$texmflocal";
$texmfhome=getenv('TEXLIVE_INSTALL_TEXMFHOME');
$texmfhome ||= "~";
$vars{'TEXMFHOME'}="$texmfhome/texmf";
}
sub calc_depends {
# we have to reset the install hash EVERY TIME otherwise everything will
# always be installed since the default is scheme-full which selects
# all packages and never deselects it
%install=();
# initialize the %install hash with what should be installed
# First look for packages in the selected scheme.
my $scheme=$tlpdb->get_package($vars{'selected_scheme'});
if (!defined($scheme)) {
dump_vars(\*STDOUT);
die ("Scheme $vars{'selected_scheme'} not defined!\n");
}
for my $scheme_content ($scheme->depends) {
$install{"$scheme_content"}=1 unless ($scheme_content=~/^collection-/);
}
# Now look for collections in the %vars hash. These are not
# necessarily the collections required by a scheme. The final
# decision is made in the collections/languages menu.
foreach my $key (keys %vars) {
if ($key=~/^collection-/) {
$install{$key} = 1 if $vars{$key};
}
}
# compute the list of archs to be installed
my @archs;
foreach (keys %vars) {
if (m/^binary_(.*)$/ ) {
if ($vars{$_}) { push @archs, $1; }
}
}
# if programs for arch=win32 are installed we also have to install
# bin-tlperl.win32 which provides the "hidden" perl that will be used
# to run all the perl scripts.
# Furthermore we install bin-tlgs.win32, too
if (grep(/^win32$/,@archs)) {
$install{"bin-tlperl.win32"} = 1;
$install{"bin-tlgs.win32"} = 1;
}
# loop over all the packages until it is getting stable
my $changed = 1;
while ($changed) {
# set $changed to 0
$changed = 0;
# collect the already selected packages
my @pre_selected = keys %install;
tllog($::LOG_DDEBUG, "initial number of installations: $#pre_selected\n");
# loop over all the pre_selected and add them
foreach my $p (@pre_selected) {
tllog($::LOG_DDEBUG, "pre_selected $p\n");
foreach my $p_dep ($tlpdb->get_package($p)->depends) {
if ($p_dep =~ m/^(.*)\.ARCH$/) {
my $foo = "$1";
foreach my $a (@archs) {
$install{"$foo.$a"} = 1;
}
} elsif ($p_dep =~ m/^(.*)\.win32$/) {
# a win32 package should *only* be installed if we are installing
# the win32 arch
if (grep(/^win32$/,@archs)) {
$install{$p_dep} = 1;
}
} else {
$install{$p_dep} = 1;
}
}
}
# check for newly selected packages
my @post_selected = keys %install;
tllog($::LOG_DDEBUG, "number of post installations: $#post_selected\n");
# set repeat condition
if ($#pre_selected != $#post_selected) {
$changed = 1;
}
}
# now do the size computation
my $size = 0;
foreach my $p (keys %install) {
my $tlpobj = $tlpdb->get_package($p);
if (not(defined($tlpobj))) {
die "Cannot find $p in texlive.tlpdb, strange!\n";
}
$size+=$tlpobj->docsize if $vars{'option_doc'};
$size+=$tlpobj->srcsize if $vars{'option_src'};
$size+=$tlpobj->runsize;
foreach my $a (@archs) {
$size += $tlpobj->binsize->{$a} if defined($tlpobj->binsize->{$a});
}
}
$vars{'total_size'} =
sprintf "%d", ($size * $TeXLive::TLConfig::BlockSize)/1024**2;
}
sub load_tlpdb {
my $master;
if (media eq 'NET') {
$master="$TeXLiveURL";
} else {
$master="$::installerdir";
}
tllog($::LOG_NORMAL, "Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName ...\n");
$tlpdb=TeXLive::TLPDB->new(root => "$master");
}
sub initialize_collections {
foreach my $pkg ($tlpdb->list_packages) {
my $tlpobj = $tlpdb->{'tlps'}{$pkg};
if ($tlpobj->category eq "Collection") {
$vars{"$pkg"}=0;
++$vars{'n_collections_available'};
if ($pkg=~/collection-lang/) {
push @collections_lang, $pkg;
} elsif ($pkg=~/documentation/) {
if ($pkg=~/documentation-base/) {
push @collections_std, $pkg;
} else {
push @collections_lang_doc, $pkg;
}
} else {
push @collections_std, $pkg;
}
}
}
my $scheme_tlpobj = $tlpdb->get_package($default_scheme);
if (defined ($scheme_tlpobj)) {
$vars{'n_collections_selected'}=0;
foreach my $dependent ($scheme_tlpobj->depends) {
if ($dependent=~/^(collection-.*)/) {
$vars{"$1"}=1;
++$vars{'n_collections_selected'};
}
}
}
}
sub set_install_platform {
my @available_platforms;
my $detected_platform=platform;
my $warn_nobin;
my $warn_nobin_x86_64_linux;
my $nowarn="";
my $wp='##'; # warning prefix
$warn_nobin="\n$wp WARNING! No binaries for your platform found! ";
$warn_nobin_x86_64_linux="$warn_nobin" .
"$wp No binaries for x86_64-linux found, using i386-linux instead.\n";
my $ret = $warn_nobin;
if (defined $vars{"binary_$detected_platform"}) {
$vars{"binary_$detected_platform"}=1;
$vars{'inst_platform'}=$detected_platform;
$ret = $nowarn;
} elsif ($detected_platform eq 'x86_64-linux') {
$vars{'binary_i386-linux'}=1;
$vars{'inst_platform'}='i386-linux';
$ret = $warn_nobin_x86_64_linux;
} else {
$ret = $warn_nobin;
}
foreach my $key (keys %vars) {
if ($key=~/^binary.*/) {
++$vars{'n_systems_selected'} if $vars{$key}==1;
}
}
return($ret);
}
sub create_profile {
my $profilepath = shift;
# The file "TLprofile" is created at the beginning of the
# installation process and contains information about the current
# setup. The purpose is to allow non-interactive installations.
my $fh;
if (ref($profilepath)) {
$fh = $profilepath;
} else {
open PROFILE, ">$profilepath";
$fh = \*PROFILE;
}
my $tim = gmtime(time);
print $fh "# texlive.profile written on $tim UTC\n";
print $fh "# it will NOT be overwritten and reflects only the\n";
print $fh "# installation profile at installation time\n";
print $fh "selected_scheme $vars{selected_scheme}\n";
foreach my $key (keys %vars) {
print $fh "$key $vars{$key}\n"
if $key=~/^collection/ and $vars{$key}==1;
print $fh "$key $vars{$key}\n" if $key=~/^option_letter/;
print $fh "$key $vars{$key}\n" if $key=~/^option_doc/;
print $fh "$key $vars{$key}\n" if $key=~/^option_fmt/;
print $fh "$key $vars{$key}\n" if $key=~/^option_src/;
print $fh "$key $vars{$key}\n" if $key=~/^option_symlinks/;
print $fh "$key $vars{$key}\n" if $key=~/^TEXDIR/;
print $fh "$key $vars{$key}\n" if $key=~/^TEXMFSYSVAR/;
print $fh "$key $vars{$key}\n" if $key=~/^TEXMFLOCAL/;
print $fh "$key $vars{$key}\n" if $key=~/^TEXMFHOME/;
}
if (!ref($profilepath)) {
close PROFILE;
}
}
sub read_profile {
my $profilepath = shift;
open PROFILE, "<$profilepath"
or die "Cannot open profile $profilepath for reading!\n";
my %pro;
while (<PROFILE>) {
next if m/^[[:space:]]*$/; # skip empty lines
next if m/^[[:space:]]*#/; # skip comment lines
my ($k,$v) = split;
$pro{$k} = $v;
}
foreach (keys %vars) {
# clear out collections from var
if (m/^collection-/) { $vars{$_} = 0; }
if (defined($pro{$_})) { $vars{$_} = $pro{$_}; }
}
}
sub prepare_installation {
make_var_skeleton "$vars{'TEXMFSYSVAR'}";
make_local_skeleton "$vars{'TEXMFLOCAL'}";
mkdirhier "$vars{'TEXDIR'}/texmf-config";
$localtlpdb=new TeXLive::TLPDB;
$localtlpdb->root("$vars{'TEXDIR'}");
}
sub do_install_packages {
my @what;
foreach my $package (sort keys %install) {
push @what, $package if ($install{$package} == 1);
}
install_packages($tlpdb,$localtlpdb,\@what,$vars{'option_src'},$vars{'option_doc'});
}
# for later complete removal we want to save some options and values
# into the local tlpdb:
# - should links be set, and if yes, the destination (bin,man,info)
sub save_options_into_tlpdb {
my $tlp = new TeXLive::TLPOBJ;
$tlp->name("00texlive-installation.config");
$tlp->category("TLCore");
my @deps;
push @deps, "platform/$::_platform_";
if ($::_media_ eq 'NET') {
push @deps, "location/$TeXLiveURL";
} else {
push @deps, "location/" . abs_path($::installerdir);
}
if ($vars{'option_letter'}) {
push @deps, "letter";
}
if ($vars{'option_fmt'}) {
push @deps, "formats";
}
if ($vars{'option_symlinks'}) {
push @deps, "symlinks";
push @deps, "sys_bin/$vars{'sys_bin'}";
push @deps, "sys_info/$vars{'sys_info'}";
push @deps, "sys_man/$vars{'sys_man'}";
}
if ($vars{'option_doc'}) {
push @deps, "docfiles";
}
if ($vars{'option_src'}) {
push @deps, "srcfiles";
}
$tlp->depends(@deps);
$localtlpdb->add_tlpobj($tlp);
$localtlpdb->save();
}
# do_postinst_stuff has to fix up the texmf tree and install some missing
# files. The things to do are taken from the install-live.sh installer
# of former times, and should be critically checked.
sub do_postinst_stuff {
my $TEXDIR="$vars{'TEXDIR'}";
my $TEXMFSYSVAR="$vars{'TEXMFSYSVAR'}";
my $TEXMFLOCAL="$vars{'TEXMFLOCAL'}";
# install some copies from texmf(-dist) into texmf-var
copy ("$TEXDIR/texmf-dist/tex/plain/config/language.def",
"$TEXMFSYSVAR/tex/plain/config")
if (-f "$TEXDIR/texmf-dist/tex/plain/config/language.def");
copy ("$TEXDIR/texmf/xdvi/XDvi",
"$TEXMFSYSVAR/xdvi")
if (-f "$TEXDIR/texmf/xdvi/XDvi");
# those files must exist
copy ("$TEXDIR/texmf/dvips/config/config.ps",
"$TEXMFSYSVAR/dvips/config");
# now we have to fix up dvipdfm config file to contain the right
# piping command
mkdirhier("$TEXMFSYSVAR/dvipdfm/config");
open(DVIPDFMCONFIGDIST, "<$TEXDIR/texmf/dvipdfm/config/config")
or die("Cannot open $TEXDIR/texmf/dvipdfm/config/config");
open(DVIPDFMCONFIGINST, ">$TEXMFSYSVAR/dvipdfm/config/config")
or die("Cannot open $TEXMFSYSVAR/dvipdfm/config/config");
while (<DVIPDFMCONFIGDIST>) {
if (m/^D /) {
print DVIPDFMCONFIGINST 'D "epstopdf --outfile=%o --nocompress %i"', "\n";
} else {
print DVIPDFMCONFIGINST;
}
}
close(DVIPDFMCONFIGDIST);
close(DVIPDFMCONFIGINST);
#copy ("$TEXDIR/texmf/dvipdfm/config/config",
# "$TEXMFSYSVAR/dvipdfm/config");
copy ("$TEXDIR/texmf/web2c/mktex.cnf",
"$TEXMFSYSVAR/web2c");
# the old installer copied from CDDIR, but shouldn't this be installed
# in ANY case since it is in bin-pdftex???
copy ("$TEXDIR/texmf/tex/generic/config/pdftexconfig.tex",
"$TEXMFSYSVAR/tex/generic/config");
# old installer did this, should we do this, TOO????
#cp $CDDIR/texmf-dist/tex/context/config/cont-usr.tex $TEXMFSYSVAR/tex/context/config/cont-usr.tex
do_texmf_cnf() unless $opt_portable;
# final program execution
# we have to do several things:
# - clean the environment from spurious TEXMF related variables
# - add the bin dir to the PATH
# - select perl interpreter and set the correct perllib
# - run the programs
# Step 1: Clean the environment
#my @TMFVARS=qw(VARTEXFONTS TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR
# TEXMFSYSCONFIG TEXMFHOME TEXMFVAR TEXMFCONFIG TEXMF SYSTEXMF VARTEXFONTS
# TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL
# PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF);
my @TMFVARS0=qw(VARTEXFONTS
TEXMF SYSTEXMF VARTEXFONTS
TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL
PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF);
my @TMFVARS1=qw(TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG
TEXMFHOME TEXMFVAR TEXMFCONFIG);
foreach my $tmv (@TMFVARS0) {
delete $ENV{$tmv} if (defined($ENV{$tmv}));
}
if (!$opt_portable) {
foreach my $tmv (@TMFVARS1) {
delete $ENV{$tmv} if (defined($ENV{$tmv}));
}
}
# Step 2: Setup the PATH, PATHEXT, switch to the new Perl
my $pathsep=(win32)? ';' : ':';
my $plat_bindir="$TEXDIR/bin/$vars{'this_platform'}";
my $perl_bindir="$TEXDIR/tlpkg/tlperl/bin";
my $perl_libdir="$TEXDIR/tlpkg/tlperl/lib";
tllog($::LOG_DEBUG, "Prepending $plat_bindir to PATH\n");
$ENV{'PATH'}="$plat_bindir" . "$pathsep" . "$ENV{'PATH'}";
if (win32) {
tllog($::LOG_DEBUG, "Prepending $perl_bindir to PATH\n");
$ENV{'PATH'}="$perl_bindir" . "$pathsep" . "$ENV{'PATH'}";
}
tllog($::LOG_DEBUG, "\nNew PATH is now:\n");
foreach my $dir (split $pathsep, $ENV{'PATH'}) {
tllog($::LOG_DEBUG, " $dir\n");
}
tllog($::LOG_DEBUG, "\n");
if (win32) {
$ENV{'PATHEXT'}=".texlua;" . "$ENV{'PATHEXT'}";
$ENV{'TEXBINDIR'}=$TEXDIR . "\\bin\\win32";
$ENV{'TEXBINDIR'} =~ s!/!\\!g;
$ENV{'PERL5LIB'}="$perl_libdir";
}
# Step 4: run the programs
if (!$opt_portable) {
tllog($::LOG_NORMAL, "running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n");
system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf");
}
# we have to generate the various config file. That could be done with
# texconfig generate * but Win32 does not have texconfig. But we have
# $localtlpdb and this is simple code, so do it directly, i.e., duplicate
# the code from the various generate-*.pl scripts
tllog($::LOG_NORMAL, "writing fmtutil.cnf data to $TEXMFSYSVAR/web2c/fmtutil.cnf\n");
TeXLive::TLUtils::create_fmtutil($localtlpdb,
"$TEXMFSYSVAR/web2c/fmtutil.cnf",
"$TEXMFLOCAL/web2c/fmtutil-local.cnf");
tllog($::LOG_NORMAL, "writing updmap.cfg to $TEXMFSYSVAR/web2c/updmap.cfg\n");
TeXLive::TLUtils::create_updmap ($localtlpdb,
"$TEXMFSYSVAR/web2c/updmap.cfg",
"$TEXMFLOCAL/web2c/updmap-local.cfg");
tllog($::LOG_NORMAL, "writing language.dat data to $TEXMFSYSVAR/tex/generic/config/language.dat\n");
TeXLive::TLUtils::create_language($localtlpdb,
"$TEXMFSYSVAR/tex/generic/config/language.dat",
"$TEXMFLOCAL/tex/generic/config/language-local.dat");
tllog($::LOG_NORMAL, "running updmap-sys\n");
system('updmap-sys', '--nohash');
tllog($::LOG_NORMAL, "re-running mktexlsr $TEXMFSYSVAR\n");
system('mktexlsr', "$TEXMFSYSVAR");
# now work through the options if specified at all
# letter instead of a4
if ($vars{'option_letter'}) {
tllog($::LOG_NORMAL, "Setting default paper size to letter\n");
system("texlua", "$TEXDIR/texmf/scripts/texlive/texconf.tlu", "--sys", "paper", "letter");
}
# all formats option
if ($vars{'option_fmt'}) {
tllog($::LOG_NORMAL, "pre-generation all format file (fmtutil-sys --all)\n");
system('fmtutil-sys','--all');
}
# option_links
if ($vars{'option_symlinks'}) {
# bin files
my @files;
mkdirhier $vars{'sys_bin'};
if (-w $vars{'sys_bin'}) {
tllog($::LOG_NORMAL, "linking binaries to $vars{'sys_bin'}\n");
@files = `ls $plat_bindir`;
chomp(@files);
`cd "$vars{'sys_bin'}" && rm -f @files`;
`ln -s "$plat_bindir/"* "$vars{'sys_bin'}"`;
} else {
tllog($::LOG_NORMAL, "destination of bin symlink $vars{'sys_bin'} not writable, no linking of bin files done!\n");
}
if ($vars{'option_doc'}) {
# info files
mkdirhier $vars{'sys_info'};
if (-w $vars{'sys_info'}) {
tllog($::LOG_NORMAL, "linking info pages to $vars{'sys_info'}\n");
@files = `ls "$TEXDIR/texmf/doc/info"`;
chomp(@files);
`cd "$vars{'sys_info'}" && rm -f @files`;
`ln -s "$TEXDIR/texmf/doc/info/"*info* "$vars{'sys_info'}"`;
} else {
tllog($::LOG_NORMAL, "destination of info symlink $vars{'sys_info'} not writable, no linking of info files done!\n");
}
# man files
mkdirhier $vars{'sys_man'};
if (-w $vars{'sys_man'}) {
tllog($::LOG_NORMAL, "linking man pages to $vars{'sys_man'}\n");
my $foo = `(cd "$TEXDIR/texmf/doc/man" && echo *)`;
my @mans = split ' ', $foo;
chomp(@mans);
foreach my $m (@mans) {
my $mandir = "$TEXDIR/texmf/doc/man/$m";
next unless -d $mandir;
mkdirhier "$vars{'sys_man'}/$m";
next unless -w "$vars{'sys_man'}/$m";
@files = `ls "$mandir"`;
chomp(@files);
`cd "$vars{'sys_man'}/$m" && rm -f @files`;
`ln -s "$mandir/"* "$vars{'sys_man'}/$m"`;
}
} else {
tllog($::LOG_NORMAL, "destination of man symlink $vars{'sys_man'} not writable, no linking of man files done!\n");
}
}
}
# old installer:
#$config && texconfig-sys init
#$config || echo "PLEASE RUN texconfig or texconfig-sys to make new formats."
}
# we have to adjust the texmf.cnf file to the paths set in the configuration!
sub do_texmf_cnf {
open(TMF,"<$vars{'TEXDIR'}/texmf/web2c/texmf.cnf")
or die("$vars{'TEXDIR'}/texmf/web2c/texmf.cnf not found: $!\n");
my @texmfcnflines = <TMF>;
close(TMF);
my @newtmf;
# we have to find TEXMFLOCAL TEXMFSYSVAR and TEXMFHOME
foreach my $line (@texmfcnflines) {
if ($line =~ m/^TEXMFLOCAL/) {
# by default TEXMFLOCAL = TEXDIR/../texmf-local, if this is the case
# we don't have to change anything from the default
my $deftmlocal = dirname($vars{'TEXDIR'});
$deftmlocal .= "/texmf-local";
if ("$vars{'TEXMFLOCAL'}" eq "$deftmlocal") {
push @newtmf, $line;
} else {
push @newtmf, "TEXMFLOCAL = $vars{'TEXMFLOCAL'}\n";
}
} elsif ($line =~ m/^TEXMFSYSVAR/) {
# by default TEXMFSYSVAR = TEXDIR/texmf-var, if this is the case
# we don't have to change anything from the default
if ("$vars{'TEXMFSYSVAR'}" eq "$vars{'TEXDIR'}/texmf-var") {
push @newtmf, $line;
} else {
push @newtmf, "TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}\n";
}
} elsif ($line =~ m/^TEXMFHOME/) {
# kpse now expands ~ to USERPROFILE, so we don't treat win32 and
# unix differently
push @newtmf, "TEXMFHOME = $vars{'TEXMFHOME'}\n";
} elsif ($line =~ m/^OSFONTDIR/) {
if (win32()) {
push @newtmf, "OSFONTDIR = \$SystemRoot/fonts//\n";
} else {
push @newtmf, $line;
}
} else {
push @newtmf, $line;
}
}
open(TMF,">$vars{'TEXDIR'}/texmf/web2c/texmf.cnf")
or die("Can't open $vars{'TEXDIR'}/texmf/web2c/texmf.cnf for writing: $!\n");
foreach (@newtmf) { print TMF; }
close(TMF);
}
# register texlua handlers etc etc
sub do_win_registry_magic {
# we are called under if (win32()) !!
my $texbindir = $vars{'TEXDIR'}."\\bin\\win32";
$texbindir =~ s!/!\\!g;
add_texbindir_to_path($texbindir);
setenv_reg('TEXBINDIR', $texbindir);
register_script_type(".texlua", "%TEXBINDIR%/texlua.exe");
broadcast_env();
update_assocs();
}
#
# do everything to select a scheme
#
sub select_scheme {
my $s = shift;
# set the selected scheme to $s
$vars{'selected_scheme'} = $s;
# remove the selection of all collections
foreach my $entry (keys %vars) {
if ($entry=~/^(collection-.*)/) {
$vars{"$1"}=0;
}
}
# select the collections belonging to the scheme
my $scheme_tlpobj = $tlpdb->get_package($s);
if (defined ($scheme_tlpobj)) {
$vars{'n_collections_selected'}=0;
foreach my $dependent ($scheme_tlpobj->depends) {
if ($dependent=~/^(collection-.*)/) {
$vars{"$1"}=1;
++$vars{'n_collections_selected'};
}
}
}
# for good measure, update the deps
calc_depends();
}
sub update_numbers {
$vars{'n_collections_selected'}=0;
$vars{'n_systems_available'} = 0;
$vars{'n_collections_selected'} = 0;
$vars{'n_systems_selected'} = 0;
foreach my $key (keys %vars) {
if ($key =~ /^binary/) {
++$vars{'n_systems_available'};
++$vars{'n_systems_selected'} if $vars{$key} == 1;
}
if ($key =~ /^collection-/) {
++$vars{'n_collections_available'};
++$vars{'n_collections_selected'} if $vars{$key} == 1;
}
}
}
sub flushlog {
my $fh;
if (open(LOG,">install-tl.log")) {
warn "Writing log file to current working directory!\n";
$fh = \*LOG;
} else {
$fh = \*STDERR;
warn "Not creating a log file but flushing messages to stderr:\n";
}
foreach my $l (@::LOGLINES) {
print $fh $l;
}
}
__END__
=head1 NAME
install-tl - the TeX Live Cross Platform Installer
=head1 SYNOPSIS
install-tl [OPTION] ...
install-tl.bat [OPTION] ...
=head1 OPTIONS
=over 8
=item B<-gui>
Tries to load the GUI installer using Perl/Tk. If Perl/Tk is not
available continue with the text mode installer.
=item B<-lang> I<2-letter lang code>
(only for GUI installer) tries to start the installer translated into
the language specified by the 2-letter language code. Currently supported
languages are English (en, default), Polish (pl), and German (de).
=item B<-media> I<[CD|DVD|NET]>
Overrides the autodetection of the media.
=item B<-profile> I<profile>
Preloads a TeX Live profile for equal installations on different systems.
=item B<-url> I<url>
Overrides the default URL for network installs. Should start with
either ftp:// or http://
=item B<-netarchive> I<dir>
Overrides the default settings for netarchive. Should be used with care.
=item B<-diskarchive> I<dir>
Overrides the default settings for diskarchive. Should be used with care.
=item B<-no-cls>
(only for text mode installer) do not clear the screen when entering
a new menu. For debugging purposes.
=item B<-print-arch>
Print the detected arch-os combination and exit.
=item B<-portable>
Starts the installer for portable use. See below for details.
=item B<-d>, B<-dd>, B<-ddd>
Debugging levels.
=item B<-q>, B<-qq>
B<-q> disables output to the terminal, while B<-qq> also disables output
to the logfile.
=item B<-help>, B<-h>, B<-?>
print a help message.
=back
=head1 DESCRIPTION
The TeX Live installer works across all supported platforms and allows
to install TeX Live from various media including the network.
=head1 PORTABLE USE
The TeXLive root directory contains a shell script tl-portable.sh
and a DOS batch file tl-portable.bat which start up a new shell and
command prompt in which TeXLive can be run with minimal impact on
the host system. These files start up install-tl.pl with the
-portable option for some minimal preparation. Don't use this option
directly; it makes very specific assumptions about its environment.
=head1 AUTHORS AND COPYRIGHT
This script and its documentation were written for the TeX Live
distribution (L<http://tug.org/texlive>) and both are licensed under the
GNU General Public License Version 2 or later.
=cut
### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #
|