-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathinstall-tl
executable file
·3614 lines (3146 loc) · 123 KB
/
install-tl
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
#!/usr/bin/env perl
# $Id$
# Copyright 2007-2024
# Reinhard Kotucha, Norbert Preining, Karl Berry, Siep Kroonenberg.
# This file is licensed under the GNU General Public License version 2
# or any later version.
#
# TeX Live standalone installer.
#
# Be careful when changing wording: *every* normal informational message
# output here must be recognized by the long grep in tl-update-tlnet.
use strict; use warnings;
my $svnrev = '$Revision$';
$svnrev =~ m/: ([0-9]+) /;
$::installerrevision = ($1 ? $1 : 'unknown');
# taken from 00texlive.config: release, $tlpdb->config_release;
our $texlive_release;
BEGIN {
$^W = 1;
my $Master;
my $me = $0;
$me =~ s!\\!/!g if $^O =~ /^MSWin/i;
if ($me =~ m!/!) {
($Master = $me) =~ s!(.*)/[^/]*$!$1!;
} else {
$Master = ".";
}
$::installerdir = $Master;
# All platforms: add the installer modules
unshift (@INC, "$::installerdir/tlpkg");
}
# debugging communication with external gui: use shared logfile
our $dblfile = "/tmp/dblog";
$dblfile = $ENV{'TEMP'} . "\\dblog.txt" if ($^O =~ /^MSWin/i);
$dblfile = $ENV{'TMPDIR'} . "/dblog" if ($^O eq 'darwin'
&& exists $ENV{'TMPDIR'});
sub dblog {
my $s = shift;
open(my $dbf, ">>", $dblfile);
print $dbf "PERL: $s\n";
close $dbf;
}
sub dblogsub {
my $s = shift;
my @stck = (caller(1));
dblog "$stck[3] $s";
}
# On unix, this run of install-tl may do duty as a wrapper for
# install-tl-gui.tcl, which in its turn will start an actual run of install-tl.
# Skip this wrapper block if we can easily rule out a tcl gui:
if (($^O !~ /^MSWin/i) &&
# this wrapper is only for unix, since windows has its own wrapper
($#ARGV >= 0) && ($ARGV[0] ne '-from_ext_gui')
# this run is not invoked by tcl
) {
# make syntax uniform: --a => -a, a=b => 'a b'
my @tmp_args = ();
my $p;
my $i=-1;
while ($i<$#ARGV) {
$p = $ARGV[++$i];
$p =~ s/^--/-/;
if ($p =~ /^(.*)=(.*)$/) {
push (@tmp_args, $1, $2);
} else {
push (@tmp_args, $p);
}
}
# build argument array @new_args for install-tl-gui.tcl.
# '-gui' or '-gui tcl' will not be copied to @new_args.
# quit scanning and building @new_args once tcl is ruled out.
my $want_tcl = 0;
my $asked4tcl = 0;
my $forbid = 0;
my @new_args = ();
$i = -1;
while ($i < $#tmp_args) {
$p = $tmp_args[++$i];
if ($p eq '-gui') {
# look ahead at next parameter
if ($i == $#tmp_args || $tmp_args[$i+1] =~ /^-/) {
# just -gui, without value
$want_tcl = 1;
$asked4tcl = 1;
} elsif ($tmp_args[$i+1] eq 'text') {
$want_tcl = 0;
$forbid = 1;
last;
} else {
# check all allowed values for -gui
my $q = $tmp_args[$i+1];
if ($q eq 'tcl' || $q eq 'perltk' ||
$q eq 'wizard' || $q eq 'expert') {
$want_tcl = 1;
$asked4tcl = 1;
$i++;
} else {
die "$0: invalid value for parameter -gui: $q\n";
}
}
} else {
for my $q (qw/in-place profile help print-arch print-platform
version no-gui/) {
if ($p eq "-$q") {
# ignore gui mode
$want_tcl = 0;
$forbid = 1;
last;
}
}
last if $forbid;
# not gui-related, continue collecting @new_args
push (@new_args, $p);
}
}
# done scanning arguments
if ($want_tcl) {
unshift (@new_args, "--");
unshift (@new_args, "$::installerdir/tlpkg/installer/install-tl-gui.tcl");
my @wishes = qw /wish wish8.7 wish8.6 wish8.5 tclkit/;
unshift @wishes, $ENV{'WISH'} if (defined $ENV{'WISH'});
foreach my $w (@wishes) {
if (!exec($w, @new_args)) {
next; # no return on successful exec
}
}
# no succesful exec of wish
} # else continue with main installer below
}
# end of wrapper block, start of the real installer
use Cwd 'abs_path';
use Getopt::Long qw(:config no_autoabbrev);
use Pod::Usage;
use POSIX ();
use TeXLive::TLUtils qw(platform platform_desc sort_archs
which getenv wndws unix info log debug tlwarn ddebug tldie
member process_logging_options rmtree wsystem
mkdirhier make_var_skeleton make_local_skeleton install_package copy
install_packages dirname setup_programs native_slashify forward_slashify);
use TeXLive::TLConfig;
use TeXLive::TLCrypto;
use TeXLive::TLDownload;
use TeXLive::TLPDB;
use TeXLive::TLPOBJ;
use TeXLive::TLPaper;
use Encode::Alias;
eval {
require Encode::Locale;
Encode::Locale->import ();
debug("Encode::Locale is loaded.\n");
};
if ($@) {
if (wndws()) {
die ("For Windows, Encode::Locale is required.\n");
}
debug("Encode::Locale is not found. Assuming all encodings are UTF-8.\n");
Encode::Alias::define_alias('locale' => 'UTF-8');
Encode::Alias::define_alias('locale_fs' => 'UTF-8');
Encode::Alias::define_alias('console_in' => 'UTF-8');
Encode::Alias::define_alias('console_out' => 'UTF-8');
}
binmode (STDIN, ':encoding(console_in)');
binmode (STDOUT, ':encoding(console_out)');
binmode (STDERR, ':encoding(console_out)');
if (wndws()) {
require TeXLive::TLWinGoo;
TeXLive::TLWinGoo->import( qw(
&admin
&non_admin
®_country
&expand_string
&get_system_path
&get_user_path
&setenv_reg
&unsetenv_reg
&adjust_reg_path_for_texlive
®ister_extension
&unregister_extension
®ister_file_type
&unregister_file_type
&broadcast_env
&update_assocs
&add_menu_shortcut
&remove_desktop_shortcut
&remove_menu_shortcut
&create_uninstaller
&maybe_make_ro
));
}
# global list of lines that get logged (see TLUtils.pm::_logit).
@::LOGLINES = ();
# if --version, --help, etc., this just gets thrown away, which is ok.
&log ("TeX Live installer invocation: $0", map { " $_" } @ARGV, "\n");
# global list of warnings
@::WARNLINES = ();
# we play around with the environment, place to keep original
my %origenv = ();
# $install{$packagename} == 1 if it should be installed
my %install;
# the different modules have to assign a code blob to this global variable
# which starts the installation.
# Example: In install-menu-text.pl there is
# $::run_menu = \&run_menu_text;
#
$::run_menu = sub { die "no UI defined." ; };
# the default scheme to be installed
my $default_scheme='scheme-full';
# common fmtutil args, keep in sync with tlmgr.pl.
our $common_fmtutil_args =
"--no-error-if-no-engine=$TeXLive::TLConfig::PartialEngineSupport";
# some arrays where the lists of collections to be installed are saved
# our for menus
our @collections_std;
# 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
#
# The following values are taken from the remote tlpdb using the
# $tlpdb->tlpdbopt_XXXXX
# settings (i.e., taken from tlpkg/tlpsrc/00texlive.installation.tlpsrc
#
# 'tlpdbopt_sys_bin' => '/usr/local/bin',
# 'tlpdbopt_sys_man' => '/usr/local/man',
# 'tlpdbopt_sys_info' => '/usr/local/info',
# 'tlpdbopt_install_docfiles' => 1,
# 'tlpdbopt_install_srcfiles' => 1,
# 'tlpdbopt_create_formats' => 0,
our %vars=( # 'n_' means 'number of'.
'this_platform' => '',
'n_systems_available' => 0,
'n_systems_selected' => 0,
'n_collections_selected' => 0,
'n_collections_available' => 0,
'total_size' => 0,
'src_splitting_supported' => 1,
'doc_splitting_supported' => 1,
'selected_scheme' => $default_scheme,
'instopt_portable' => 0,
'instopt_letter' => 0,
'instopt_adjustrepo' => 1,
'instopt_write18_restricted' => 1,
'instopt_adjustpath' => 0,
);
my %path_keys = (
'TEXDIR' => 1,
'TEXMFHOME' => 1,
'TEXMFLOCAL' => 1,
'TEXMFCONFIG' => 1,
'TEXMFSYSCONFIG' => 1,
'TEXMFVAR' => 1,
'TEXMFSYSVAR' => 1,
);
# option handling
# tcl gui weeded out at start
my $opt_allow_ftp = 0;
my $opt_continue = 1;
my $opt_custom_bin;
my $opt_debug_fakenet = 0;
my $opt_debug_setup_vars = 0;
my $opt_doc_install = 1;
my $opt_font;
my $opt_force_arch;
my $opt_gui = "text";
my $opt_help = 0;
my $opt_init_from_profile = "";
my $opt_installation = 1;
my $opt_interaction = 1;
my $opt_location = "";
my $opt_no_gui = 0;
my $opt_no_interaction = 0;
my $opt_nonadmin = 0;
my $opt_paper = "";
my $opt_persistent_downloads = 1;
my $opt_portable = 0;
my $opt_print_arch = 0;
my $opt_profile = "";
my $opt_scheme = "";
my $opt_src_install = 1;
my $opt_texdir = "";
my $opt_texuserdir = "";
my $opt_version = 0;
my $opt_warn_checksums = 1;
my %pathopts;
# unusual cases:
$::opt_select_repository = 0;
our $opt_in_place = 0;
# don't set this to a value, see below
my $opt_verify_downloads;
# show all options even those not relevant for that arch
$::opt_all_options = 0;
# default language for GUI installer
$::lang = "en";
# use the fancy directory selector for TEXDIR
# no longer used, although we still accept the parameter
#$::alternative_selector = 0;
# do not debug translations by default
$::debug_translation = 0;
# List of packages that failed to install but we continued due to --continue
@::installation_failed_packages = ();
#
# set up signal handlers to catch SIGINT and SIGTERM
$SIG{'INT'} = \&signal_handler;
# not necessary AFA we know
# $SIG{TERM} = &signal_handler;
# before we try to interact with the user, we need to know whether or not
# install-tl was called from an external gui. This gui will start install-tl
# with "-from_ext_gui" as its first command-line option.
my $from_ext_gui = 0;
if ((defined $ARGV[0]) && $ARGV[0] eq "-from_ext_gui") {
shift @ARGV;
$from_ext_gui = 1;
# do not buffer output to the frontend
select(STDERR); $| = 1;
select(STDOUT); $| = 1;
# windows: suppress console windows when invoking other programs
Win32::SetChildShowWindow(0) if wndws();
}
# If we find a file installation.profile we ask the user whether we should
# continue with the installation, unless there shouldn't be interaction.
# We are in the directory from which the aborted installation was run.
my %profiledata;
if (-r "installation.profile"
&& $opt_interaction
&& !exists $ENV{"TEXLIVE_INSTALL_NO_RESUME"}) {
print "mess_yesno\n" if $from_ext_gui; # prepare for dialog interaction
my $pwd = Cwd::getcwd();
print "ABORTED TL INSTALLATION FOUND: installation.profile (in $pwd)\n";
print "Do you want to continue with the same settings as before (y/N): ";
print "\nendmess\n" if $from_ext_gui;
my $answer = <STDIN>;
if ($answer && $answer =~ m/^y(es)?$/i) {
$opt_profile = "installation.profile";
}
}
# first process verbosity/quiet options
process_logging_options();
# now the others
GetOptions(
"all-options" => \$::opt_all_options,
"continue!" => \$opt_continue,
"custom-bin=s" => \$opt_custom_bin,
"debug-fakenet" => \$opt_debug_fakenet,
"debug-setup-vars" => \$opt_debug_setup_vars,
"debug-translation" => \$::debug_translation,
"doc-install!" => \$opt_doc_install,
"fancyselector",
"font=s" => \$opt_font,
"force-platform|force-arch=s" => \$opt_force_arch,
"gui:s" => \$opt_gui,
"in-place" => \$opt_in_place,
"init-from-profile=s" => \$opt_init_from_profile,
"installation!", => \$opt_installation,
"interaction!", => \$opt_interaction,
"lang|gui-lang=s" => \$::opt_lang,
"location|url|repository|repos|repo=s" => \$opt_location,
"no-cls", # $::opt_no_cls in install-menu-text-pl
"N" => \$opt_no_interaction,
"no-gui" => \$opt_no_gui,
"non-admin" => \$opt_nonadmin,
"paper=s" => \$opt_paper,
"persistent-downloads!" => \$opt_persistent_downloads,
"portable" => \$opt_portable,
"print-platform|print-arch" => \$opt_print_arch,
"profile=s" => \$opt_profile,
"scheme|s=s" => \$opt_scheme,
"select-repository" => \$::opt_select_repository,
"src-install!" => \$opt_src_install,
"tcl", # handled by wrapper
"texdir=s" => \$opt_texdir,
"texmfconfig=s" => \$pathopts{'texmfconfig'},
"texmfhome=s" => \$pathopts{'texmfhome'},
"texmflocal=s" => \$pathopts{'texmflocal'},
"texmfsysconfig=s" => \$pathopts{'texmfsysconfig'},
"texmfsysvar=s" => \$pathopts{'texmfsysvar'},
"texmfvar=s" => \$pathopts{'texmfvar'},
"texuserdir=s" => \$opt_texuserdir,
"verify-downloads!" => \$opt_verify_downloads,
"version" => \$opt_version,
"warn-checksums!" => \$opt_warn_checksums,
"help|?" => \$opt_help) or pod2usage(2);
if ($from_ext_gui) {
$opt_gui = "extl";
}
# just so we can use -N as abbreviation for --no-interaction.
$opt_interaction = 0 if $opt_no_interaction;
# informational invocations: help, version, platform
if ($opt_help) {
# theoretically we could make a subroutine with all the same
# painful checks as we do in tlmgr, but let's not bother until people ask.
my @noperldoc = ();
if (wndws() || $ENV{"NOPERLDOC"}) {
@noperldoc = ("-noperldoc", "1");
}
# Tweak less invocation same as tlmgr, though.
# less can break control characters and thus the output of pod2usage
# is broken. We add/set LESS=-R in the environment and unset
# LESSPIPE and LESSOPEN to try to help.
#
if (defined($ENV{'LESS'})) {
$ENV{'LESS'} .= " -R";
} else {
$ENV{'LESS'} = "-R";
}
delete $ENV{'LESSPIPE'};
delete $ENV{'LESSOPEN'};
pod2usage(-exitstatus => 0, -verbose => 2, @noperldoc);
die "sorry, pod2usage did not work; maybe a download failure?";
}
if ($opt_version) {
print "install-tl (TeX Live Cross Platform Installer)",
" revision $::installerrevision\n";
if (open (REL_TL, "$::installerdir/release-texlive.txt")) {
# print first and last lines, which have the TL version info.
my @rel_tl = <REL_TL>;
print $rel_tl[0];
print $rel_tl[$#rel_tl];
close (REL_TL);
}
if ($::opt_verbosity > 0) {
print "Module revisions:";
print "\nTLConfig: " . TeXLive::TLConfig->module_revision();
print "\nTLCrypto: " . TeXLive::TLCrypto->module_revision();
print "\nTLDownload: ".TeXLive::TLDownload->module_revision();
print "\nTLPDB: " . TeXLive::TLPDB->module_revision();
print "\nTLPOBJ: " . TeXLive::TLPOBJ->module_revision();
print "\nTLTREE: " . TeXLive::TLTREE->module_revision();
print "\nTLUtils: " . TeXLive::TLUtils->module_revision();
print "\nTLWinGoo: " . TeXLive::TLWinGoo->module_revision() if wndws();
print "\n";
}
exit 0;
}
if ($opt_print_arch) {
print platform()."\n";
exit 0;
}
# now load translations, if applicable
if (defined($::opt_lang)) {
$::lang = $::opt_lang;
}
require("TeXLive/trans.pl");
load_translations();
# some option checks
die "$0: Incompatible options: custom-bin and in-place.\n"
if ($opt_in_place && $opt_custom_bin);
die "$0: Incompatible options: in-place and profile ($opt_profile).\n"
if ($opt_in_place && $opt_profile);
die "$0: Incompatible options init-from-profile and in-place.\n"
if ($opt_in_place && $opt_init_from_profile);
# We now allow --texuserdir XXX --texmfhome YYYY
# die "$0: Incompatible options: texuserdir ($opt_texuserdir) and "
# . "any of texmfhome, texmfconfig, texmfvar ("
# . "$pathopts{'texmfhome'}, $pathopts{'texmfvar'}, $pathopts{'texmfconfig'}"
# . ").\n"
# if ($opt_texuserdir &&
# ($pathopts{'texmfhome'} || $pathopts{'texmfvar'}
# || $pathopts{'texmfconfig'}));
if ($#ARGV >= 0) {
die "$0: Extra arguments `@ARGV'; try --help if you need it.\n";
}
if ($opt_profile) { # not allowed if in_place
if (-r $opt_profile && -f $opt_profile) {
info("Automated TeX Live installation using profile: $opt_profile\n");
} else {
$opt_profile = "";
info(
"Profile $opt_profile not readable or not a file, continuing in interactive mode.\n");
}
}
if ($opt_nonadmin and wndws()) {
non_admin();
}
# done with options
# 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;
my $location;
@::info_hook = ();
our $media;
our @media_available;
TeXLive::TLUtils::initialize_global_tmpdir();
if (TeXLive::TLCrypto::setup_checksum_method()) {
# try to setup gpg:
# either explicitly requested or nothing requested
if ((defined($opt_verify_downloads) && $opt_verify_downloads)
||
(!defined($opt_verify_downloads))) {
if (TeXLive::TLCrypto::setup_gpg($::installerdir)) {
# make sure we actually do verify ...
$opt_verify_downloads = 1;
log("Trying to verify cryptographic signatures!\n")
} else {
if ($opt_verify_downloads) {
tldie("$0: No gpg found, but verification explicitly requested "
. "on command line, so quitting.\n");
} else {
# implicitly requested, just
debug("Couldn't detect gpg so will proceed without verification!\n");
}
}
}
} else {
if ($opt_warn_checksums) {
tldie(<<END_NO_CHECKSUMS);
$0: Quitting, cannot find a checksum implementation.
Please install Digest::SHA (from CPAN), or openssl, or sha512sum,
or use the --no-warn-checksums command line option.
END_NO_CHECKSUMS
}
}
# continuing with normal install
if (defined($opt_force_arch)) {
tlwarn("Overriding platform to $opt_force_arch\n");
$::_platform_ = $opt_force_arch;
}
# initialize the correct platform
platform();
$vars{'this_platform'} = $::_platform_;
# we do not support cygwin < 1.7, so check for that
if (!$opt_custom_bin && (platform() eq "i386-cygwin")) {
chomp( my $un = `uname -r`);
if ($un =~ m/^(\d+)\.(\d+)\./) {
if ($1 < 2 && $2 < 7) {
tldie("$0: Sorry, the TL binaries require at least cygwin 1.7, "
. "not $1.$2\n");
}
}
}
#
# More Cygwin: if the user doesn't have Cygwin's wget or curl,
# it's unlikely anything good will happen.
if ($^O eq 'cygwin'
&& (! -x "/usr/bin/curl.exe" && ! -x "/usr/bin/wget.exe")) {
print "mess_yesno\n" if $from_ext_gui; # prepare for dialog interaction
print <<END_CYGWIN_WGET_MSG;
It seems you are using Cygwin and have not installed Cygwin's
curl or wget. See the TeX Live Guide information on Cygwin for required
and recommended packages:
https://tug.org/texlive/doc/texlive-en/texlive-en.html#cygwin
END_CYGWIN_WGET_MSG
print "Continue anyway (unlikely to work) (y/N): ";
print "\nendmess\n" if $from_ext_gui;
my $answer = <STDIN>;
if (! $answer || $answer !~ m/^y(es)?$/i) {
tldie("$0: Ok, goodbye. Please install the needed packages.\n");
}
}
# determine which media are available, don't put NET here, it is
# assumed to be available at any time
{
# check the installer dir for what is present
my $tmp = $::installerdir;
$tmp = abs_path($tmp);
# remove trailing \ or / (e.g. root of dvd drive on w32)
$tmp =~ s,[\\\/]$,,;
if (-d "$tmp/$Archive") {
push @media_available, "local_compressed#$tmp";
}
if (-r "$tmp/texmf-dist/web2c/texmf.cnf") {
push @media_available, "local_uncompressed#$tmp";
}
}
# check command line arguments if given
if ($opt_location) {
my $tmp = $opt_location;
if ($tmp =~ m!^(https?|ftp)://!i) {
push @media_available, "NET#$tmp";
} elsif ($tmp =~ m!^(rsync|)://!i) {
tldie ("$0: sorry, rsync unsupported; use an http or ftp url here.\n");
} else {
# remove leading file:/+ part
$tmp =~ s!^file://*!/!i;
$tmp = abs_path($tmp);
# remove trailing \ or / (e.g. root of dvd drive on w32)
$tmp =~ s,[\\\/]$,,;
if (-d "$tmp/$Archive") {
push @media_available, "local_compressed#$tmp";
}
if (-d "$tmp/texmf-dist/web2c") {
push @media_available, "local_uncompressed#$tmp";
}
}
}
# find wget, tar, xz
if (!setup_programs ("$::installerdir/tlpkg/installer", "$::_platform_")) {
tldie("$0: Goodbye.\n");
}
if ($opt_profile eq "" && $opt_interaction) {
if ($opt_init_from_profile) {
read_profile("$opt_init_from_profile", seed => 1);
}
# 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 have to assign a code ref to $::run_menu which is
# run, 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;
$opt_gui = "text" if ($opt_no_gui);
# finally do check for additional screens in the $opt_gui setting:
# format:
# --gui <plugin>:<a1>,<a2>,...
# which will passed to run_menu (<a1>, <a2>, ...)
#
my @runargs;
if ($opt_gui =~ m/^([^:]*):(.*)$/) {
$opt_gui = $1;
@runargs = split ",", $2;
}
if (-r "$::installerdir/tlpkg/installer/install-menu-${opt_gui}.pl") {
require("installer/install-menu-${opt_gui}.pl");
} else {
tlwarn("UI plugin $opt_gui not found,\n");
tlwarn("Using text mode installer.\n");
require("installer/install-menu-text.pl");
}
# before we start the installation we check for the existence of
# a previous installation, and in case we ship inform the UI
if (!exists $ENV{"TEXLIVE_INSTALL_NO_RESUME"} && $opt_interaction) {
my $tlmgrwhich = which("tlmgr");
if ($tlmgrwhich) {
my $dn = dirname($tlmgrwhich);
$dn = abs_path("$dn/../..");
# The "make Karl happy" case, check that we are not running install-tl
# from the same tree where tlmgr is hanging around
my $install_tl_root = abs_path($::installerdir);
my $tlpdboldpath
= $dn .
"/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName";
if (-r $tlpdboldpath && $dn ne $install_tl_root) {
debug ("found old installation in $dn\n");
push @runargs, "-old-installation-found=$dn";
# only the text-mode menu will pay attention!
}
}
}
my $ret = &{$::run_menu}(@runargs);
if ($ret == $MENU_QUIT) {
do_cleanup(); # log, profile, temp files
flushlog();
exit(1);
} elsif ($ret == $MENU_ABORT) {
# here, omit do_cleanup()
flushlog();
exit(2);
}
if ($ret != $MENU_INSTALL) {
tlwarn("Unknown return value of run_menu: $ret\n");
exit(3);
}
} else { # no interactive setting of options
if (!do_remote_init()) {
die ("Exiting installation.\n");
}
read_profile($opt_profile) if ($opt_profile ne "");
}
my $varsdump = "";
foreach my $key (sort keys %vars) {
my $val = $vars{$key} || "";
$varsdump .= " $key: \"$val\"\n";
}
log("Settings:\n" . $varsdump);
# portable option overrides any system integration options
$vars{'instopt_adjustpath'} = 0 if $vars{'instopt_portable'};
$vars{'tlpdbopt_file_assocs'} = 0 if $vars{'instopt_portable'};
$vars{'tlpdbopt_desktop_integration'} = 0 if $vars{'instopt_portable'};
install_warnlines_hook(); # collect warnings in @::WARNLINES
info("Installing to: $vars{TEXDIR}\n");
if (!$opt_installation) {
print STDERR "Not doing installation due to --no-installation, terminating here.\n";
exit 0;
}
$::env_warns = "";
create_welcome();
my $status = 1;
if ($opt_gui eq 'text' or $opt_gui eq 'extl' or $opt_profile ne "") {
$status = do_installation();
if (@::WARNLINES) {
foreach my $t (@::WARNLINES) { print STDERR $t; }
}
if ($::env_warns) { tlwarn($::env_warns); }
unless ($ENV{"TEXLIVE_INSTALL_NO_WELCOME"}) {
info(join("\n", @::welcome_arr));
}
do_cleanup(); # sets $::LOGFILENAME if not already defined
if ($::LOGFILENAME) {
print STDOUT "\nLogfile: $::LOGFILENAME\n";
} else {
# do_cleanup sets $::LOGFILENAME to ""
#if no logfile could be written
print STDERR
"Cannot create logfile $vars{'TEXDIR'}/install-tl.log: $!\n";
}
printf STDOUT "Installed on platform %s at %s\n",
$vars{'this_platform'}, $vars{'TEXDIR'} if ($opt_gui eq 'extl');
if (@::installation_failed_packages) {
print <<EOF;
*** PLEASE READ THIS WARNING ***********************************
The following (inessential) packages failed to install properly:
@::installation_failed_packages
You can fix this by running this command:
tlmgr update --all --reinstall-forcibly-removed
to complete the installation.
However, if the problem was a failure to download (by far the
most common cause), check that you can connect to the chosen mirror
in a browser; you may need to specify a mirror explicitly.
******************************************************************
EOF
}
}
exit $status;
###################################################################
#
# FROM HERE ON ONLY SUBROUTINES
# NO VARIABLE DECLARATIONS OR CODE
#
###################################################################
#
# SETUP OF REMOTE STUFF
#
# this is now a sub since it is called from the ui plugins on demand
# this allows selecting a mirror first and then continuing
sub only_load_remote {
my $selected_location = shift;
# determine where we will find the distribution to install from.
#
$location = $opt_location;
$location = $selected_location if defined($selected_location);
$location || ($location = "$::installerdir");
if ($location =~ m!^(ctan$|(https?|ftp)://)!i) {
# remove any trailing tlpkg[/texlive.tlpdb] or /
$location =~ s,/(tlpkg(/texlive\.tlpdb)?|archive)?/*$,,;
if ($location =~ m/^ctan$/i) {
$location = TeXLive::TLUtils::give_ctan_mirror();
} elsif ($location =~ m/^$TeXLiveServerURLRegexp/) {
my $mirrorbase = TeXLive::TLUtils::give_ctan_mirror_base();
$location =~ s,^($TeXLiveServerURLRegexp|ctan$),$mirrorbase,;
}
$TeXLiveURL = $location;
$media = 'NET';
} else {
if (scalar grep($_ =~ m/^local_compressed/, @media_available)) {
$media = 'local_compressed';
# for in_place option we want local_uncompressed media
$media = 'local_uncompressed' if $opt_in_place &&
member('local_uncompressed', @media_available);
} elsif (scalar grep($_ =~ m/^local_uncompressed/, @media_available)) {
$media = 'local_uncompressed';
} else {
if ($opt_location) {
# user gave a --location but nothing can be found there, so die
die "$0: cannot find installation source at $opt_location.\n";
}
# no --location given, but NET installation
$TeXLiveURL = $location = TeXLive::TLUtils::give_ctan_mirror();
$media = 'NET';
}
}
if ($from_ext_gui) {print "location: $location\n";}
return load_tlpdb();
} # only_load_remote
sub do_remote_init {
if (!only_load_remote(@_)) {
tlwarn("$0: Could not load TeX Live Database from $location, goodbye.\n");
return 0;
}
if (!do_version_agree()) {
TeXLive::TLUtils::tldie <<END_MISMATCH;
=============================================================================
$0: The TeX Live versions of the local installation
and the repository being accessed are not compatible:
local: $TeXLive::TLConfig::ReleaseYear
repository: $texlive_release
Perhaps you need to use a different CTAN mirror?
(For more, see the output of install-tl --help, especially the
-repository option. Online via https://tug.org/texlive/doc.)
=============================================================================
END_MISMATCH
}
final_remote_init();
return 1;
} # do_remote_init
sub do_version_agree {
$texlive_release = $tlpdb->config_release;
if ($media eq "local_uncompressed") {
# existing installation may not have 00texlive.config metapackage
# so use TLConfig to establish what release we have
$texlive_release ||= $TeXLive::TLConfig::ReleaseYear;
}
# if the release from the remote TLPDB does not agree with the
# TLConfig::ReleaseYear in the first 4 places break out here.
# Why only the first four places: some optional network distributions
# might use
# release/2009-foobar
if ($media eq "NET"
&& $texlive_release !~ m/^$TeXLive::TLConfig::ReleaseYear/) {
return 0;
} else {
return 1;
}
} # do_version_agree
sub final_remote_init {
info("Installing TeX Live $TeXLive::TLConfig::ReleaseYear from: $location" .
($tlpdb->is_verified ? " (verified)" : " (not verified)") . "\n");
info("Platform: ", platform(), " => \'", platform_desc(platform), "\'\n");
if ($opt_custom_bin) {
if (-d $opt_custom_bin && (-r "$opt_custom_bin/kpsewhich"
|| -r "$opt_custom_bin/kpsewhich.exe")) {
info("Platform overridden, binaries taken from $opt_custom_bin\n"
. "and will be installed into .../bin/custom.\n");
} else {
tldie("$0: -custom-bin argument must be a directory "
. "with TeX Live binaries, not like: $opt_custom_bin\n");
}
}
if ($media eq "local_uncompressed") {
info("Distribution: live (uncompressed)\n");
} elsif ($media eq "local_compressed") {
info("Distribution: inst (compressed)\n");
} elsif ($media eq "NET") {
info("Distribution: net (downloading)\n");
info("Using URL: $TeXLiveURL\n");
TeXLive::TLUtils::setup_persistent_downloads(
"$::installerdir/tlpkg/installer/curl/curl-ca-bundle.crt"
) if $opt_persistent_downloads;
} else {
info("Distribution: $media\n");
}
info("Directory for temporary files: $::tl_tmpdir\n");
if ($opt_in_place and ($media ne "local_uncompressed")) {
print "TeX Live not local or not decompressed; 'in_place' option not applicable\n";
$opt_in_place = 0;
} elsif (
$opt_in_place and (!TeXLive::TLUtils::texdir_check($::installerdir))) {
print "Installer dir not writable; 'in_place' option not applicable\n";
$opt_in_place = 0;
}
$opt_scheme = "" if $opt_in_place;
$vars{'instopt_portable'} = $opt_portable;
$vars{'instopt_adjustpath'} = 1 if wndws();
log("Installer revision: $::installerrevision\n");
log("Database revision: " . $tlpdb->config_revision . "\n");
# correctly set the splitting support
# for local_uncompressed we always support splitting
if (($media eq "NET") || ($media eq "local_compressed")) {
$vars{'src_splitting_supported'} = $tlpdb->config_src_container;
$vars{'doc_splitting_supported'} = $tlpdb->config_doc_container;
}
set_platforms_supported();
set_texlive_default_dirs();
set_install_platform();
initialize_collections();
# size information
$vars{'free_size'} = TeXLive::TLUtils::diskfree($vars{'TEXDIR'});
update_default_scheme();
update_default_paper();
update_default_src_doc_install();
} # final_remote_init
sub update_default_scheme {
# initialize the scheme from the command line value, if given.
if ($opt_scheme) {
# add the scheme- prefix if they didn't give it.
$opt_scheme = "scheme-$opt_scheme" if $opt_scheme !~ /^scheme-/;
#
# add "only" if they said "infra" (Tired of making this typo, should
# have named it "infra" in the first place, but too late.)
$opt_scheme .= "only" if $opt_scheme eq "scheme-infra";
#
my $scheme = $tlpdb->get_package($opt_scheme);
if (defined($scheme)) {
select_scheme($opt_scheme); # select it
} else {
tlwarn("Scheme $opt_scheme not defined, ignoring it.\n");
}
}
} # update_default_scheme
sub update_default_paper {
# initialize default paper size from the command line or envvar value,
# if either is given.
my $env_paper = $ENV{"TEXLIVE_INSTALL_PAPER"};
if ($opt_paper) {
if (defined $env_paper && $env_paper ne $opt_paper) {
tlwarn("$0: paper selected via both envvar TEXLIVE_INSTALL_PAPER and\n");
tlwarn("$0: cmdline arg --paper, preferring the latter: $opt_paper\n");