#!/usr/bin/env perl # $Id: install-tl 73024 2024-12-03 17:12:38Z karl $ # 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: 73024 $'; $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 = ; 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 = ; 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(<; 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 :,,... # which will passed to run_menu (, , ...) # 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 <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"); } if ($opt_paper eq "letter") { $vars{'instopt_letter'} = 1; } elsif ($opt_paper eq "a4") { $vars{'instopt_letter'} = 0; } else { tlwarn("$0: cmdline option --paper value must be letter or a4, not: " . "$opt_paper (ignoring)\n"); } } elsif ($env_paper) { if ($env_paper eq "letter") { $vars{'instopt_letter'} = 1; } elsif ($env_paper eq "a4") { ; } # do nothing else { tlwarn("$0: TEXLIVE_INSTALL_PAPER value must be letter or a4, not: " . "$env_paper (ignoring)\n"); } } } # update_default_paper sub update_default_src_doc_install { if (! $opt_src_install) { $vars{'tlpdbopt_install_srcfiles'} = 0; } if (! $opt_doc_install) { $vars{'tlpdbopt_install_docfiles'} = 0; } } # update_default_src_doc_install sub do_installation { if (wndws()) { non_admin() if !$vars{'tlpdbopt_w32_multi_user'}; } if ($vars{'instopt_portable'}) { $vars{'tlpdbopt_desktop_integration'} = 0; $vars{'tlpdbopt_file_assocs'} = 0; $vars{'instopt_adjustpath'} = 0; $vars{'tlpdbopt_w32_multi_user'} = 0; } if ($vars{'selected_scheme'} ne "scheme-infraonly" && $vars{'n_collections_selected'} <= 0) { tldie("$0: Nothing selected, nothing to install, exiting!\n"); } # expand ~ in various variables just to be sure # (but not the user dirs since we want the ~ to stay literal ... must # think more ... qqq) for my $v (qw/TEXDIR TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG/) { $vars{$v} = TeXLive::TLUtils::expand_tilde($vars{$v}) if ($vars{$v}); } # maybe_make_ro tests for admin, local drive and NTFS before proceeding. # making the root read-only automatically locks everything below it. # do TEXDIR now, before it loses its final slash mkdirhier "$vars{'TEXDIR'}"; if (wndws()) { TeXLive::TLWinGoo::maybe_make_ro ($vars{'TEXDIR'}); } # check for free disk space my $diskfree = TeXLive::TLUtils::diskfree($vars{'TEXDIR'}); # -1 is returned if df not available or some other error if ($diskfree != -1) { my $reserve = 100; if ($diskfree < $reserve + $vars{'total_size'}) { my $msg = "($diskfree free < $reserve reserve " . "+ installed $vars{total_size})"; if ($ENV{'TEXLIVE_INSTALL_NO_DISKCHECK'}) { tlwarn("$0: Insufficient disk space\n$msg\n" ." but continuing anyway per envvar TEXLIVE_INSTALL_NO_DISKCHECK\n"); } else { tldie("$0: DISK SPACE INSUFFICIENT!\n$msg\nAborting installation.\n" . " To skip the check, set the environment variable\n" . " TEXLIVE_INSTALL_NO_DISKCHECK=1\n"); } } } # now remove final slash from TEXDIR even if it is the root of a drive $vars{'TEXDIR'} =~ s!/$!!; # do the actual installation make_var_skeleton "$vars{'TEXMFSYSVAR'}"; my $oldlocal = -d $vars{'TEXMFLOCAL'}; make_local_skeleton "$vars{'TEXMFLOCAL'}"; mkdirhier "$vars{'TEXMFSYSCONFIG'}"; if (wndws()) { TeXLive::TLWinGoo::maybe_make_ro ($vars{'TEXMFSYSVAR'}); TeXLive::TLWinGoo::maybe_make_ro ($vars{'TEXMFLOCAL'}) unless $oldlocal; TeXLive::TLWinGoo::maybe_make_ro ($vars{'TEXMFSYSCONFIG'}); } if ($opt_in_place) { $localtlpdb = $tlpdb; } else { $localtlpdb=new TeXLive::TLPDB; $localtlpdb->root("$vars{'TEXDIR'}"); } if (!$opt_in_place) { # have to do top-level release-texlive.txt as a special file, so # tl-update-images can insert the final version number without # having to remake any packages. But if the source does not exist, # or the destination already exists, don't worry about it (even # though these cases should never arise); it's not that important. # if (-e "$::installerdir/release-texlive.txt" && ! -e "$vars{TEXDIR}/release-texlive.txt") { copy("$::installerdir/release-texlive.txt", "$vars{TEXDIR}/"); } # calc_depends(); save_options_into_tlpdb(); # we need to do that dir, since we use the TLPDB->install_package which # might change into texmf-dist for relocated packages mkdirhier "$vars{'TEXDIR'}/texmf-dist"; do_install_packages(); if ($opt_custom_bin) { $vars{'this_platform'} = "custom"; my $TEXDIR="$vars{'TEXDIR'}"; mkdirhier("$TEXDIR/bin/custom"); for my $f (<$opt_custom_bin/*>) { copy($f, "$TEXDIR/bin/custom"); } } } # now we save every scheme that is fully covered by the stuff we have # installed to the $localtlpdb foreach my $s ($tlpdb->schemes) { my $stlp = $tlpdb->get_package($s); die ("This cannot happen, $s not defined in tlpdb") if ! defined($stlp); my $incit = 1; foreach my $d ($stlp->depends) { if (!defined($localtlpdb->get_package($d))) { $incit = 0; last; } } if ($incit) { $localtlpdb->add_tlpobj($stlp); } } # include a 00texlive.config package in the new tlpdb, # so that further installations and updates using the new installation # as the source can work. Only include the release info, the other # 00texlive.config entries are not relevant for this case. my $tlpobj = new TeXLive::TLPOBJ; $tlpobj->name("00texlive.config"); my $t = $tlpdb->get_package("00texlive.config"); $tlpobj->category($t->category); $tlpobj->depends("minrelease/" . $tlpdb->config_minrelease, "release/" . $tlpdb->config_release); $localtlpdb->add_tlpobj($tlpobj); $localtlpdb->save unless $opt_in_place; my $errcount = do_postinst_stuff(); #tlwarn("!!! Dummy test warning\n"); #tlwarn("!!! Another test warning\n"); #$errcount += 2; # check environment for possibly tex-related strings: check_env() unless $ENV{"TEXLIVE_INSTALL_ENV_NOCHECK"}; # We do clean up in the main installation part # don't do this here because it closes the log file and # further messages (warnings, welcome) are not logged. # log, profile, temp files: # do_cleanup(); # create_welcome(); already invoked in main program if (@::WARNLINES) { unshift @::WARNLINES, ("\nSummary of warnings:\n"); } my $status = 0; if ($errcount > 0) { $status = 1; warn "\n$0: errors in installation reported above\n"; } return $status; } # do_installation sub run_postinst_cmd { my ($cmd) = @_; &TeXLive::TLUtils::run_cmd_with_log ($cmd, \&log); } # # Make texmf.cnf, backup directory, cleanups, path setting, and # (most importantly) post-install subprograms: mktexlsr, fmtutil, # and more. Return count of errors detected, hopefully zero. # sub do_postinst_stuff { my $TEXDIR = $vars{'TEXDIR'}; my $TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}; my $TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}; my $TEXMFVAR = $vars{'TEXMFVAR'}; my $TEXMFCONFIG = $vars{'TEXMFCONFIG'}; my $TEXMFLOCAL = $vars{'TEXMFLOCAL'}; my $tmv; do_texmf_cnf(); # clean up useless files in texmf-dist/tlpkg as this is only # created by the relocatable packages if (-d "$TEXDIR/$TeXLive::TLConfig::RelocTree/tlpkg") { rmtree("$TEXDIR/TeXLive::TLConfig::RelocTree/tlpkg"); } # create package backup directory for tlmgr autobackup to work mkdirhier("$TEXDIR/$TeXLive::TLConfig::PackageBackupDir"); # 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. %origenv = %ENV; my @TMFVARS=qw(VARTEXFONTS TEXMF SYSTEXMF VARTEXFONTS TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG TEXMFVAR TEXMFCONFIG TEXMFHOME TEXMFCACHE); if (defined($ENV{'TEXMFCNF'})) { tlwarn "WARNING: environment variable TEXMFCNF is set. You should know what you are doing. We will unset it for the post-install actions, but all further operations might be disturbed.\n\n"; } foreach $tmv (@TMFVARS) { delete $ENV{$tmv} if (defined($ENV{$tmv})); } # Step 2: Setup the PATH, switch to the new Perl my $pathsep = (wndws())? ';' : ':'; my $plat_bindir = "$TEXDIR/bin/$vars{'this_platform'}"; my $perl_bindir = "$TEXDIR/tlpkg/tlperl/bin"; my $perl_libdir = "$TEXDIR/tlpkg/tlperl/lib"; my $progext = (wndws())? '.exe' : ''; debug("Prepending $plat_bindir to PATH\n"); $ENV{'PATH'} = $plat_bindir . $pathsep . $ENV{'PATH'}; if (wndws()) { debug("Prepending $perl_bindir to PATH\n"); $ENV{'PATH'} = "$perl_bindir" . "$pathsep" . "$ENV{'PATH'}"; $ENV{'PATH'} =~ s!/!\\!g; } debug("\nNew PATH is:\n"); foreach my $dir (split $pathsep, $ENV{'PATH'}) { debug(" $dir\n"); } debug("\n"); if (wndws()) { $ENV{'PERL5LIB'} = $perl_libdir; } # # post install actions # my $usedtlpdb = $opt_in_place ? $tlpdb : $localtlpdb; if (wndws()) { debug("Actual environment:\n" . `set` ."\n\n"); debug("Effective TEXMFCNF: " . `kpsewhich -expand-path=\$TEXMFCNF` ."\n"); } # Step 4: run the programs my $errcount = 0; if (!$opt_in_place) { wsystem("running", 'mktexlsr', "$TEXDIR/texmf-dist") && exit(1); } # we have to generate the various config file. That could be done with # texconfig generate * but Windows 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 mkdirhier "$TEXDIR/texmf-dist/web2c"; info("writing fmtutil.cnf to $TEXDIR/texmf-dist/web2c/fmtutil.cnf\n"); TeXLive::TLUtils::create_fmtutil($usedtlpdb, "$TEXDIR/texmf-dist/web2c/fmtutil.cnf"); # warn if fmtutil-local.cnf is present if (-r "$TEXMFLOCAL/web2c/fmtutil-local.cnf") { tlwarn("Old configuration file $TEXMFLOCAL/web2c/fmtutil-local.cnf found.\n"); tlwarn("fmtutil now reads *all* fmtutil.cnf files, so probably the easiest way\nis to rename the above file to $TEXMFLOCAL/web2c/fmtutil.cnf\n"); } info("writing updmap.cfg to $TEXDIR/texmf-dist/web2c/updmap.cfg\n"); TeXLive::TLUtils::create_updmap ($usedtlpdb, "$TEXDIR/texmf-dist/web2c/updmap.cfg"); info("writing language.dat to $TEXMFSYSVAR/tex/generic/config/language.dat\n"); TeXLive::TLUtils::create_language_dat($usedtlpdb, "$TEXMFSYSVAR/tex/generic/config/language.dat", "$TEXMFLOCAL/tex/generic/config/language-local.dat"); info("writing language.def to $TEXMFSYSVAR/tex/generic/config/language.def\n"); TeXLive::TLUtils::create_language_def($usedtlpdb, "$TEXMFSYSVAR/tex/generic/config/language.def", "$TEXMFLOCAL/tex/generic/config/language-local.def"); info("writing language.dat.lua to $TEXMFSYSVAR/tex/generic/config/language.dat.lua\n"); TeXLive::TLUtils::create_language_lua($usedtlpdb, "$TEXMFSYSVAR/tex/generic/config/language.dat.lua", "$TEXMFLOCAL/tex/generic/config/language-local.dat.lua"); wsystem("running", "mktexlsr", $TEXMFSYSVAR, $TEXMFSYSCONFIG, "$TEXDIR/texmf-dist") && exit(1); if (-x "$plat_bindir/updmap-sys$progext") { $errcount += run_postinst_cmd("updmap-sys --nohash"); } else { info("not running updmap-sys (not installed)\n"); } # now work through the options if specified at all # letter instead of a4 if ($vars{'instopt_letter'}) { # set paper size, but do not execute any post actions, which in this # case would be mktexlsr and fmtutil-sys -all; clearly premature # here at this point in the installer. info("setting default paper size to letter:\n"); $errcount += run_postinst_cmd("tlmgr --no-execute-actions paper letter"); } # option settings in launcher.ini if (wndws() && !$vars{'instopt_portable'}) { if ($vars{'tlpdbopt_file_assocs'} != 1 || !$vars{'instopt_adjustpath'}) { # create higher priority tlaunch.ini with adjusted settings # whether or not launcher mode (desktop integration 2) # was selected rewrite_tlaunch_ini(); } } # now rerun mktexlsr for updmap-sys and tlmgr paper letter updates. wsystem("re-running", "mktexlsr", $TEXMFSYSVAR, $TEXMFSYSCONFIG) && exit(1); if (wndws() and !$vars{'instopt_portable'} and !$opt_in_place) { if ($vars{'tlpdbopt_desktop_integration'} != 2) { create_uninstaller($vars{'TEXDIR'}); } else { $errcount += wsystem ( 'Running','tlaunch.exe', admin() ? 'admin_inst_silent' : 'user_inst_silent'); } } # lmtx/context cache setup, relegated to a common subroutine # that tlmgr can also call. if (exists($install{"context"}) && $install{"context"} == 1 && !exists $ENV{"TEXLIVE_INSTALL_NO_CONTEXT_CACHE"}) { $errcount += TeXLive::TLUtils::update_context_cache($plat_bindir, $progext, \&run_postinst_cmd); } else { debug("skipped ConTeXt cache setup, not installed or told not to\n"); } # all formats option if ($vars{'tlpdbopt_create_formats'}) { if (-x "$plat_bindir/fmtutil-sys$progext") { info("pre-generating all format files, be patient...\n"); $errcount += run_postinst_cmd( "fmtutil-sys $common_fmtutil_args --no-strict --all"); } else { info("not running fmtutil-sys (script not installed)\n"); } } else { info("not running fmtutil-sys (user option create_formats=0)\n"); } # do path adjustments: On Windows add/remove to PATH etc, # on Unix set symlinks # for portable, this option should be unset # it should not be necessary to test separately for portable $errcount += do_path_adjustments() if $vars{'instopt_adjustpath'} and $vars{'tlpdbopt_desktop_integration'} != 2; # now do the system integration: # on unix this means setting up symlinks # on w32 this means settting registry values # on both, we run the postaction directives of the tlpdb # no need to test for portable or in_place: # the menus (or profile?) should have set the required options $errcount += do_tlpdb_postactions(); return $errcount; } # do_postinst_stuff # Run the post installation code in the postaction tlpsrc entries. # Return number of errors found, or zero. sub do_tlpdb_postactions { info ("running package-specific postactions\n"); # option settings already reflect portable- and in_place options. my $usedtlpdb = $opt_in_place ? $tlpdb : $localtlpdb; my $ret = 0; # n. of errors foreach my $package ($usedtlpdb->list_packages) { # !!! alert: parameter 4 is menu shortcuts, parameter 5 does nothing !!! if ($vars{'tlpdbopt_desktop_integration'}==2) { # skip creation of shortcuts and file associations if (!TeXLive::TLUtils::do_postaction( "install", $usedtlpdb->get_package($package), 0, 0, 0, $vars{'tlpdbopt_post_code'})) { $ret += 1; } } else { # create shortcuts and file associations # according to corresponding options if (!TeXLive::TLUtils::do_postaction( "install", $usedtlpdb->get_package($package), $vars{'tlpdbopt_file_assocs'}, $vars{'tlpdbopt_desktop_integration'}, 0, $vars{'tlpdbopt_post_code'})) { $ret += 1; } } } # windows: alert the system about changed file associations if (wndws()) { TeXLive::TLWinGoo::update_assocs(); } info ("finished with package-specific postactions\n"); return $ret; } # do_tlpdb_postactions sub rewrite_tlaunch_ini { # create a higher-priority copy of tlaunch.ini in TEXMFSYSVAR # with appropriate settings in the General section my $ret = 0; # n. of errors chomp( my $tmfmain = `kpsewhich -var-value=TEXMFMAIN` ) ; chomp( my $tmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR` ) ; if (open IN, "$tmfmain/web2c/tlaunch.ini") { my $eolsave = $/; undef $/; my $ini = ; close IN; # remove general section, if any $ini =~ s/\r\n/\n/g; $ini =~ s/\[general[^\[]*//si; mkdirhier("$tmfsysvar/web2c"); if (open OUT, ">", "$tmfsysvar/web2c/tlaunch.ini") { my @fts = ('none', 'new', 'overwrite'); $\ = "\n"; print OUT $ini; print OUT "[General]"; print OUT "FILETYPES=$fts[$vars{'tlpdbopt_file_assocs'}]"; print OUT "SEARCHPATH=$vars{'instopt_adjustpath'}\n"; close OUT; `mktexlsr $tmfsysvar`; } else { $ret += 1; tlwarn("Cannot write modified tlaunch.ini\n"); } $/ = $eolsave; } else { $ret += 1; tlwarn("Cannot open tlaunch.ini for reading\n"); } return $ret; } # rewrite_tlaunch_ini sub do_path_adjustments { my $ret = 0; info ("running path adjustment actions\n"); if (wndws()) { TeXLive::TLUtils::w32_add_to_path($vars{'TEXDIR'} . '/bin/windows', $vars{'tlpdbopt_w32_multi_user'}); broadcast_env(); } else { if ($F_OK != TeXLive::TLUtils::add_symlinks($vars{'TEXDIR'}, $vars{'this_platform'}, $vars{'tlpdbopt_sys_bin'}, $vars{'tlpdbopt_sys_man'}, $vars{'tlpdbopt_sys_info'})) { $ret = 1; } } info ("finished with path adjustment actions\n"); return $ret; } # do_path_adjustments # we have to adjust the texmf.cnf file to the paths set in the configuration! sub do_texmf_cnf { open(TMF,"<$vars{'TEXDIR'}/texmf-dist/web2c/texmf.cnf") or die "$vars{'TEXDIR'}/texmf-dist/web2c/texmf.cnf not found: $!"; my @texmfcnflines = ; close(TMF); my @changedtmf = (); # install to disk: write only changed items my $yyyy = $TeXLive::TLConfig::ReleaseYear; # we have to find TEXMFLOCAL TEXMFSYSVAR and TEXMFHOME # at this point, a final slash of $vars{TEXDIR} itself has already # been removed. foreach my $line (@texmfcnflines) { if ($line =~ m/^TEXMFLOCAL\b/) { # don't find TEXMFLOCALEDIR # by default TEXMFLOCAL = TEXDIR/../texmf-local, if this is the case # we don't have to write a new setting. my $deftmflocal = Cwd::abs_path($vars{'TEXDIR'}.'/../texmf-local'); if (!defined $deftmflocal # in case abs_path couldn't resolve || Cwd::abs_path($vars{TEXMFLOCAL}) ne "$deftmflocal") { push @changedtmf, "TEXMFLOCAL = $vars{'TEXMFLOCAL'}\n"; } } elsif ($line =~ m/^TEXMFSYSVAR/) { if ("$vars{'TEXMFSYSVAR'}" ne "$vars{'TEXDIR'}/texmf-var") { push @changedtmf, "TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}\n"; } } elsif ($line =~ m/^TEXMFSYSCONFIG/) { if ("$vars{'TEXMFSYSCONFIG'}" ne "$vars{'TEXDIR'}/texmf-config") { push @changedtmf, "TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}\n"; } } elsif ($line =~ m/^TEXMFVAR/ && !$vars{'instopt_portable'}) { if ($vars{"TEXMFVAR"} ne "~/.texlive$yyyy/texmf-var") { push @changedtmf, "TEXMFVAR = $vars{'TEXMFVAR'}\n"; } } elsif ($line =~ m/^TEXMFCONFIG/ && !$vars{'instopt_portable'}) { if ("$vars{'TEXMFCONFIG'}" ne "~/.texlive$yyyy/texmf-config") { push @changedtmf, "TEXMFCONFIG = $vars{'TEXMFCONFIG'}\n"; } } elsif ($line =~ m/^TEXMFHOME/ && !$vars{'instopt_portable'}) { if ("$vars{'TEXMFHOME'}" ne "~/texmf") { push @changedtmf, "TEXMFHOME = $vars{'TEXMFHOME'}\n"; } } elsif ($line =~ m/^OSFONTDIR/) { if (wndws()) { push @changedtmf, "OSFONTDIR = \$SystemRoot/fonts//;\$LOCALAPPDATA/Microsoft/Windows/Fonts//\n"; } } } if ($vars{'instopt_portable'}) { push @changedtmf, "ASYMPTOTE_HOME = \$TEXMFCONFIG/asymptote\n"; } my ($TMF, $TMFLUA); # we want to write only changes to texmf.cnf # even for in_place installation $TMF = ">$vars{'TEXDIR'}/texmf.cnf"; open(TMF, $TMF) || die "open($TMF) failed: $!"; print TMF <= 5.14; } print TMF <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/); } } # set_platforms_supported 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)); debug("\n%vars dumped to '$filename'.\n"); } # dump_vars # Environment variables and default values on UNIX: # TEXLIVE_INSTALL_PREFIX /usr/local/texlive => $tex_prefix # $tex_prefix/2010 => $TEXDIR # TEXLIVE_INSTALL_TEXMFSYSVAR $TEXDIR/texmf-var # TEXLIVE_INSTALL_TEXMFSYSCONFIG $TEXDIR/texmf-config # TEXLIVE_INSTALL_TEXMFLOCAL $tex_prefix/texmf-local # TEXLIVE_INSTALL_TEXMFHOME '$HOME/texmf' # TEXLIVE_INSTALL_TEXMFVAR ~/.texlive2010/texmf-var # TEXLIVE_INSTALL_TEXMFCONFIG ~/.texlive2010/texmf-config sub set_var_from_alternatives { my ($what, $whatref, @alternatives) = @_; my @alt_text; for my $i (@alternatives) { push @alt_text, ($i ? $i : "undef") } my $final; while (@alternatives) { my $el = pop @alternatives; $final = $el if ($el); } debug("setting $what to $final from @alt_text\n"); $$whatref = $final; } sub set_standard_var { my ($what, $envstr, $cmdlinestr, $default) = @_; # warn if a value was set from both the profile and # via env var my $envvar = getenv($envstr); my $cmdlinevar = $pathopts{$cmdlinestr}; my %nrdefs; $nrdefs{$vars{$what}} = 1 if ($vars{$what}); $nrdefs{$envvar} = 1 if ($envvar); $nrdefs{$cmdlinevar} = 1 if ($cmdlinevar); # texmfhome/texmfvar/texmfconfig have actually been set by # via $opt_texuserdir/.... # So warn about this my $actual_cmdline_str = $cmdlinestr; my $actual_cmdline_var = $cmdlinevar; if ($opt_texuserdir) { if ($cmdlinestr eq "texmfhome" || $cmdlinestr eq "texmfvar" || $cmdlinestr eq "texmfconfig") { $actual_cmdline_str = "opt_texuserdir"; $actual_cmdline_var = $opt_texuserdir; } } if (scalar keys %nrdefs > 1) { # multiple conflicting definitions, fail! tlwarn("Trying to define $what via conflicting settings:\n"); tlwarn(" from envvar $envstr = $envvar\n") if ($envvar); tlwarn(" from profile = $vars{$what}\n") if ($vars{$what}); tlwarn(" from command line argument $actual_cmdline_str = $actual_cmdline_var\n") if ($actual_cmdline_var); tlwarn(" Preferring the last value from above!\n"); # actual preference order is given via the below call } # default for most variables, in increasing priority # - some default # - environment variable # - setting from profile saved already in $vars{$what} # - command line set_var_from_alternatives( $what, \$vars{$what}, $cmdlinevar, $vars{$what}, $envvar, $default); } sub set_texlive_default_dirs { my $homedir = (platform() =~ m/darwin/) ? "~/Library" : "~"; my $yyyy = $TeXLive::TLConfig::ReleaseYear; # # If the --texuserdir is given, assign values to texmfhome/var/config # unless the separate cmd line options are also present. if ($opt_texuserdir) { $pathopts{'texmfhome'} = "$opt_texuserdir/texmf" if (!$pathopts{'texmfhome'}); $pathopts{'texmfvar'} = "$opt_texuserdir/texmf-var" if (!$pathopts{'texmfvar'}); $pathopts{'texmfconfig'} = "$opt_texuserdir/texmf-config" if (!$pathopts{'texmfconfig'}); } # # Sources of target directory settings in priority order: # - env variable TEXLIVE_INSTALL_PREFIX # will be used with YYYY (in portable case without) # - --texdir cmd line option # will be used as is, similar to profile setting # - profile setting # # first compare whether profile setting and cmd line agree if both given if ($opt_texdir && $vars{'TEXDIR'}) { if ($opt_texdir ne $vars{'TEXDIR'}) { tlwarn("Conflicting settings for installation path given:\n"); tlwarn(" from profile TEXDIR = $vars{'TEXDIR'}\n"); tlwarn(" from command line option --texdir = $opt_texdir\n"); tlwarn(" Preferring the command line value!\n"); # actual setting of preference is done below in the # set_var_from_alternatives( \$vars{'TEXDIR'}, # call, where the order determines the preference! } } my $tlprefixenv = getenv('TEXLIVE_INSTALL_PREFIX'); if ($tlprefixenv && ($opt_texdir || $vars{'TEXDIR'})) { # NOTE we cannot compare these two values because the one might # contain the YYYY part (TEXDIR) while the other is the one without. tlwarn("Trying to set up basic path using two incompatible methods:\n"); tlwarn(" from envvar TEXLIVE_INSTALL_PREFIX = $tlprefixenv\n"); tlwarn(" from profile TEXDIR = $vars{'TEXDIR'}\n") if ($vars{'TEXDIR'}); tlwarn(" from command line option --texdir = $opt_texdir\n") if ($opt_texdir); tlwarn(" Preferring the later value!\n"); $tlprefixenv = undef; } # first set $tex_prefix my $tex_prefix; set_var_from_alternatives("TEX_PREFIX", \$tex_prefix, ($opt_in_place ? abs_path($::installerdir) : undef), $tlprefixenv, (wndws() ? getenv('SystemDrive') . '/texlive' : '/usr/local/texlive')); # set_var_from_alternatives("TEXDIR", \$vars{'TEXDIR'}, $opt_texdir, $vars{'TEXDIR'}, ($vars{'instopt_portable'} || $opt_in_place) ? $tex_prefix : "$tex_prefix/$texlive_release"); # set_standard_var('TEXMFSYSVAR', 'TEXLIVE_INSTALL_TEXMFSYSVAR', 'texmfsysvar', "$vars{'TEXDIR'}/texmf-var"); # set_standard_var('TEXMFSYSCONFIG', 'TEXLIVE_INSTALL_TEXMFSYSCONFIG', 'texmfsysconfig', "$vars{'TEXDIR'}/texmf-config"); # # TEXMFLOCAL is special because the default in texmf.cnf # TEXMFLOCAL = $SELFAUTOGRANDPARENT/texmf-local # that is # ..../texlive/texmf-local # set_standard_var('TEXMFLOCAL', 'TEXLIVE_INSTALL_TEXMFLOCAL', 'texmflocal', ($opt_texdir ? "$vars{'TEXDIR'}/texmf-local" :"$tex_prefix/texmf-local")); # set_standard_var('TEXMFHOME', 'TEXLIVE_INSTALL_TEXMFHOME', 'texmfhome', "$homedir/texmf"); # set_standard_var('TEXMFVAR', 'TEXLIVE_INSTALL_TEXMFVAR', 'texmfvar', (platform() =~ m/darwin/) ? "$homedir/texlive/$yyyy/texmf-var" : "$homedir/.texlive$yyyy/texmf-var"); # set_standard_var('TEXMFCONFIG', 'TEXLIVE_INSTALL_TEXMFCONFIG', 'texmfconfig', (platform() =~ m/darwin/) ? "$homedir/texlive/$yyyy/texmf-config" : "$homedir/.texlive$yyyy/texmf-config"); # for portable installation we want everything in one directory if ($vars{'instopt_portable'}) { $vars{'TEXMFHOME'} = "\$TEXMFLOCAL"; $vars{'TEXMFVAR'} = "\$TEXMFSYSVAR"; $vars{'TEXMFCONFIG'} = "\$TEXMFSYSCONFIG"; } if ($opt_debug_setup_vars) { print "DV:final values from setup of paths:\n"; for my $i (qw/TEXDIR TEXMFSYSVAR TEXMFSYSCONFIG TEXMFHOME TEXMFVAR TEXMFCONFIG TEXMFLOCAL/) { print "$i = $vars{$i}\n"; } } } # set_texlive_default_dirs 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. %install=(); my $p; my $a; # initialize the %install hash with what should be installed if ($vars{'selected_scheme'} ne "scheme-custom") { # First look for packages in the selected scheme. my $scheme=$tlpdb->get_package($vars{'selected_scheme'}); if (!defined($scheme)) { if ($vars{'selected_scheme'}) { # something is written in the selected scheme but not defined, that # is strange, so warn and die die ("Scheme $vars{'selected_scheme'} not defined, vars:\n"); dump_vars(\*STDOUT); } } else { 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; } } } # # ensure that packages listed in InstallExtraRequiredPackages are installed for my $p (@TeXLive::TLConfig::InstallExtraRequiredPackages) { $install{$p} = 1; } # if programs for arch=windows are installed we also have to install # tlperl.windows which provides the "hidden" perl that will be used # to run all the perl scripts. # Furthermore we install tlgs.windows if (grep(/^windows$/,@archs)) { $install{"tlperl.windows"} = 1; $install{"tlgs.windows"} = 1; # tlpsv is gone } # 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; debug("calc_depends: number of packages to install: $#pre_selected\n"); # loop over all the pre_selected and add them foreach $p (@pre_selected) { ddebug("pre_selected $p\n"); my $pkg = $tlpdb->get_package($p); if (!defined($pkg)) { tlwarn("$p is mentioned somewhere but not available, disabling it.\n"); $install{$p} = 0; next; } foreach my $p_dep ($tlpdb->get_package($p)->depends) { if ($p_dep =~ m/^(.*)\.ARCH$/) { my $foo = "$1"; foreach $a (@archs) { $install{"$foo.$a"} = 1 if defined($tlpdb->get_package("$foo.$a")); } } elsif ($p_dep =~ m/^(.*)\.windows$/) { # a windows package should *only* be installed if we are installing # the windows arch if (grep(/^windows$/,@archs)) { $install{$p_dep} = 1; } } else { $install{$p_dep} = 1; } } } # check for newly selected packages my @post_selected = keys %install; debug("calc_depends: after resolution, #packages: $#post_selected\n"); # set repeat condition if ($#pre_selected != $#post_selected) { $changed = 1; } } # after loop, now do the size computation. my $size = 0; foreach $p (keys %install) { my $tlpobj = $tlpdb->get_package($p); if (not(defined($tlpobj))) { tlwarn("$p should be installed but " . "is not in texlive.tlpdb; disabling.\n"); $install{$p} = 0; next; } $size+=$tlpobj->docsize if $vars{'tlpdbopt_install_docfiles'}; $size+=$tlpobj->srcsize if $vars{'tlpdbopt_install_srcfiles'}; $size+=$tlpobj->runsize; foreach $a (@archs) { $size += $tlpobj->binsize->{$a} if defined($tlpobj->binsize->{$a}); } } $vars{'total_size'} = sprintf "%d", ($size * $TeXLive::TLConfig::BlockSize)/1024**2; } # calc_depends sub load_tlpdb { my $master = $location; info("Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName\n"); $tlpdb = TeXLive::TLPDB->new( root => $master, 'verify' => $opt_verify_downloads); if (!defined($tlpdb)) { my $do_die = 1; # if that failed, and: # - we are installing from the network # - the location string does not contain "tlnet" # then we simply add "/systems/texlive/tlnet" in case someone just # gave an arbitrary CTAN mirror address without the full path if ($media eq "NET" && $location !~ m/tlnet/) { tlwarn("First attempt for net installation failed;\n"); tlwarn(" repository url does not contain \"tlnet\",\n"); tlwarn(" retrying with \"/systems/texlive/tlnet\" appended.\n"); $location .= "/systems/texlive/tlnet"; $master = $location; # # since we change location, we reset the error count of the # download object $::tldownload_server->enable if defined($::tldownload_server); # $tlpdb = TeXLive::TLPDB->new( root => $master, 'verify' => $opt_verify_downloads); if (!defined($tlpdb)) { tlwarn("Oh well, adding tlnet did not help.\n"); tlwarn(<option($o) if (!defined($profiledata{"tlpdbopt_$o"})); } if (wndws()) { # below, we really mean (start) menu integration. # 2016: always menu shortcuts, never desktop shortcuts, whatever the setting # 2017: new option value 2: launcher instead of menu. # in portable case, shortcuts sanitized away elsewhere $vars{'tlpdbopt_desktop_integration'} = 1; # we have to make sure that this option is set to 0 in case # that a non-admin is running the installations program $vars{'tlpdbopt_w32_multi_user'} = 0 if (!admin()); } # select scheme: either $vars{'selected_scheme'} or $default_scheme # check that the default scheme is actually present, otherwise switch to # scheme-minimal. my $selscheme; if ($opt_scheme) { $selscheme = $opt_scheme; } elsif ($vars{"selected_scheme"}) { $selscheme = $vars{"selected_scheme"}; } else { $selscheme = $default_scheme; } if (!defined($tlpdb->get_package($selscheme))) { # let us try scheme-minimal, and if also that is not available, scheme-infra # which is required to be installed if (!defined($tlpdb->get_package("scheme-minimal"))) { if (!defined($tlpdb->get_package("scheme-infra"))) { die("Aborting, cannot find either $selscheme or scheme-minimal or scheme-infra"); } $default_scheme = "scheme-infra"; } else { $default_scheme = "scheme-minimal"; } tlwarn("$0: No $selscheme, switching to $default_scheme.\n"); $vars{'selected_scheme'} = $default_scheme; } else { $vars{'selected_scheme'} = $selscheme; } # make sure that we update %vars for collection_* if only selected_scheme # is there, but no collection information my $found_collection = 0; for my $k (keys(%vars)) { if ($k =~ m/^collection-/) { $found_collection = 1; last; } } if (!$found_collection) { for my $p ($tlpdb->get_package($vars{'selected_scheme'})->depends) { $vars{$p} = 1 if ($p =~ m/^collection-/); } } return 1; } # load_tlpdb sub initialize_collections { foreach my $pkg ($tlpdb->list_packages) { my $tlpobj = $tlpdb->{'tlps'}{$pkg}; if ($tlpobj->category eq "Collection") { $vars{"$pkg"} = 0 if (!defined($vars{$pkg})); ++$vars{'n_collections_available'}; push (@collections_std, $pkg); } } my $selscheme = ($vars{'selected_scheme'} || $default_scheme); my $scheme_tlpobj = $tlpdb->get_package($selscheme); if (defined ($scheme_tlpobj)) { $vars{'n_collections_selected'}=0; foreach my $dependent ($scheme_tlpobj->depends) { if ($dependent=~/^(collection-.*)/) { $vars{"$1"}=1; } } } for my $c (keys(%vars)) { if ($c =~ m/^collection-/ && $vars{$c}) { ++$vars{'n_collections_selected'}; } } if ($vars{"binary_windows"}) { $vars{"collection-wintools"} = 1; ++$vars{'n_collections_selected'}; } } # initialize_collections sub set_install_platform { my $detected_platform=platform; if ($opt_custom_bin) { $detected_platform = "custom"; } 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 { if ($opt_custom_bin) { $ret = "$wp Using custom binaries from $opt_custom_bin.\n"; } else { $ret = $warn_nobin; } } foreach my $key (keys %vars) { if ($key=~/^binary.*/) { ++$vars{'n_systems_selected'} if $vars{$key}==1; } } return($ret); } # set_install_platform 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; } # # determine whether the set of selected collections exactly # agrees with the selected scheme. In this case we do *not* # save the actual collection setting but only the selected # scheme, as reading the profile will load all collections # if only the scheme is given. my %instcols; foreach my $key (sort keys %vars) { $instcols{$key} = 1 if $key=~/^collection/ and $vars{$key}==1; } # for anything but "scheme-custom" we delete the contained # collections from the list if ($vars{'selected_scheme'} ne "scheme-custom") { my $scheme=$tlpdb->get_package($vars{'selected_scheme'}); if (!defined($scheme)) { die ("Scheme $vars{selected_scheme} not defined.\n"); } for my $scheme_content ($scheme->depends) { delete($instcols{"$scheme_content"}) if ($scheme_content=~/^collection-/); } } # if there are still collection left, we keep all of them my $save_cols = (keys(%instcols) ? 1 : 0); # start my $tim = gmtime(time); print $fh "# texlive.profile written on $tim UTC\n"; print $fh "# It will NOT be updated and reflects only the\n"; print $fh "# installation profile at installation time.\n"; print $fh "selected_scheme $vars{selected_scheme}\n"; foreach my $key (sort keys %vars) { print $fh "$key $vars{$key}\n" if $save_cols and $key=~/^collection/ and $vars{$key}==1; # we don't save tlpdbopt_location next if ($key eq "tlpdbopt_location"); print $fh "$key $vars{$key}\n" if $key =~ /^tlpdbopt_/; print $fh "$key $vars{$key}\n" if $key =~ /^instopt_/; print $fh "$key $vars{$key}\n" if defined($path_keys{$key}); print $fh "$key $vars{$key}\n" if (($key =~ /^binary_/) && $vars{$key}); } if (!ref($profilepath)) { close PROFILE; } } # create_profile sub read_profile { my $profilepath = shift; my %opts = @_; my %keyrename = ( 'option_doc' => 'tlpdbopt_install_docfiles', 'option_fmt' => 'tlpdbopt_create_formats', 'option_src' => 'tlpdbopt_install_srcfiles', 'option_sys_bin' => 'tlpdbopt_sys_bin', 'option_sys_info' => 'tlpdbopt_sys_info', 'option_sys_man' => 'tlpdbopt_sys_man', 'option_file_assocs' => 'tlpdbopt_file_assocs', 'option_backupdir' => 'tlpdbopt_backupdir', 'option_w32_multi_user' => 'tlpdbopt_w32_multi_user', 'option_post_code' => 'tlpdbopt_post_code', 'option_autobackup' => 'tlpdbopt_autobackup', 'option_desktop_integration' => 'tlpdbopt_desktop_integration', 'option_adjustrepo' => 'instopt_adjustrepo', 'option_letter' => 'instopt_letter', 'option_path' => 'instopt_adjustpath', 'option_symlinks' => 'instopt_adjustpath', 'portable' => 'instopt_portable', 'option_write18_restricted' => 'instopt_write18_restricted', ); my %keylost = ( 'option_menu_integration' => 1, 'in_place' => 1, ); open PROFILE, "<$profilepath" or die "$0: Cannot open profile $profilepath for reading.\n"; # %pro is used to see whether there are non-recognized keys, # while %profiledata is used to make sure that the values # from the tlpdb do not overwrite -seed-profile values. my %pro; while () { # don't use chomp here since we might use files written for Windows # on Unix or the other way round. # \R is a general line terminator, \z is end of string s{\R\z}{}; next if m/^[[:space:]]*$/; # skip empty lines next if m/^[[:space:]]*#/; # skip comment lines s/^[[:space:]]+//; # ignore leading (but not trailing) whitespace my ($k,$v) = split (" ", $_, 2); # value might have spaces # skip TEXDIRW, seems not used anymore, but might be around # in some profiles next if ($k eq "TEXDIRW"); # convert old keys to new keys $k = $keyrename{$k} if ($keyrename{$k}); if ($keylost{$k}) { tlwarn("Profile key `$k' is now ignored, please remove it.\n"); next; } $pro{$k} = $v; $profiledata{$k} = $v; } foreach (keys %vars) { # clear out collections from var, just to be sure if (m/^collection-/) { $vars{$_} = 0; } } # initialize installer and tlpdb options foreach (keys %pro) { if (m/^instopt_/) { if (defined($vars{$_})) { $vars{$_} = $pro{$_}; delete($pro{$_}); } } elsif (m/^tlpdbopt_/) { my $o = $_; $o =~ s/^tlpdbopt_//; # we do not support setting the location in the profile # could be done, but might be tricky .. next if ($o eq 'location'); if (defined($TeXLive::TLConfig::TLPDBOptions{$o})) { $vars{$_} = $pro{$_}; delete($pro{$_}); } } elsif (defined($path_keys{$_}) || m/^selected_scheme$/) { if ($pro{$_}) { $vars{$_} = $pro{$_}; delete($pro{$_}); } else { tldie("$0: Quitting, profile key for path $_ must not be empty.\n"); } } elsif (m/^(binary|collection-)/) { if ($pro{$_} =~ /^[01]$/) { $vars{$_} = $pro{$_}; delete($pro{$_}); } else { tldie("$0: Quitting, profile key for $_ must be 0 or 1, not: $pro{$_}\n"); } } } #require Data::Dumper; #$Data::Dumper::Indent = 1; #print Data::Dumper->Dump([\%vars], [qw(vars)]); # # if there are still keys in the %pro array, some unknown keys have # been written in the profile, bail out if (my @foo = keys(%pro)) { tlwarn("Unknown key(s) in profile $profilepath: @foo\n"); tlwarn("Stopping here.\n"); exit 1; } # if a profile contains *only* the selected_scheme setting without # any collection, we assume that exactely that scheme should be installed my $coldefined = 0; foreach my $k (keys %profiledata) { if ($k =~ m/^collection-/) { $coldefined = 1; last; } } # if we are in seed mode, do not try to load remote db as it is # not initialized by now return if $opts{'seed'}; # # check whether the collections are actually present in case of # changes on the server foreach my $k (keys %profiledata) { if ($k =~ m/^collection-/) { if (!defined($tlpdb->get_package($k))) { tlwarn("The profile references a non-existing collection: $k\n"); tlwarn("Exiting.\n"); exit(1); } } } # Cmdline argument --scheme should override scheme selection in the profile update_default_scheme(); # if at least one collection has been defined return here return if $coldefined; # since no collections have been defined in the profile, we # set those to be installed on which the scheme depends 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) { $vars{"$scheme_content"}=1 if ($scheme_content=~/^collection-/); } } # read_profile sub do_install_packages { # We split installation of packages into two stages: # - first critical packages, those absolutely necessary for working # - all the other packages, that can be also installed afterwards # via tlmgr # If something fails in the first group, we stop the installation. # If something fails in the second group: # - if --continue is given, try to continue install # - if --continue is not given, terminate (behaviour till now) # my @criticalwhat = (); my @what = (); my @surely_fail_packages = ( @CriticalPackagesList, @TeXLive::TLConfig::InstallExtraRequiredPackages ); for my $package (keys %install) { if (member($package, @surely_fail_packages)) { push @criticalwhat, $package if ($install{$package} == 1); } else { push @what, $package if ($install{$package} == 1); } } @criticalwhat = sort @criticalwhat; @what = sort @what; # determine retrial behavior my $retry = $opt_debug_fakenet || ($media eq "NET"); # temporary unset the localtlpdb options responsible for # running all kind of postactions, since install_packages # would call them without the PATH already set up # we are doing this anyway in do_postinstall_actions $localtlpdb->option ("desktop_integration", "0"); $localtlpdb->option ("file_assocs", "0"); $localtlpdb->option ("post_code", "0"); if (!install_packages($tlpdb,$media,$localtlpdb,\@criticalwhat, $vars{'tlpdbopt_install_srcfiles'}, $vars{'tlpdbopt_install_docfiles'}, $retry, 0) || !install_packages($tlpdb,$media,$localtlpdb,\@what, $vars{'tlpdbopt_install_srcfiles'}, $vars{'tlpdbopt_install_docfiles'}, $retry, $opt_continue)) { my $profile_name = "installation.profile"; create_profile($profile_name); tlwarn("Installation failed.\n"); tlwarn("Rerunning the installer will try to restart the installation.\n"); if (-r $profile_name) { # only suggest rerunning with the profile if it exists. tlwarn("Or you can restart by running the installer with:\n"); my $repostr = ($opt_location ? " --repository $location" : ""); my $args = "--profile $profile_name [YOUR-EXTRA-ARGS]"; if (wndws()) { tlwarn(" install-tl-windows.bat$repostr $args\n"); } else { tlwarn(" install-tl$repostr $args\n"); } } flushlog(); exit(1); } # restore options in tlpdb $localtlpdb->option ( "desktop_integration", $vars{'tlpdbopt_desktop_integration'}); $localtlpdb->option ("file_assocs", $vars{'tlpdbopt_file_assocs'}); $localtlpdb->option ("post_code", $vars{'tlpdbopt_post_code'} ? "1" : "0"); $localtlpdb->save; } # do_install_packages # 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 { # if we are told to adjust the repository *and* we are *not* # installing from the network already, we adjust the repository # to the default mirror.ctan.org if ($vars{'instopt_adjustrepo'} && ($media ne 'NET')) { $localtlpdb->option ("location", $TeXLiveURL); } else { my $final_loc = ($media eq 'NET' ? $location : abs_path($location)); $localtlpdb->option ("location", $final_loc); } for my $o (keys %TeXLive::TLConfig::TLPDBOptions) { next if ($o eq "location"); # done above already $localtlpdb->option ($o, $vars{"tlpdbopt_$o"}); } my @archs; foreach (keys %vars) { if (m/^binary_(.*)$/ ) { if ($vars{$_}) { push @archs, $1; } } } if ($opt_custom_bin) { push @archs, "custom"; } if (! @archs) { tldie("$0: Quitting, no binary platform specified/available.\n" ."$0: See https://tug.org/texlive/custom-bin.html for\n" ."$0: information on other precompiled binary sets.\n"); } # only if we forced the platform we do save this option into the tlpdb if (defined($opt_force_arch)) { $localtlpdb->setting ("platform", $::_platform_); } $localtlpdb->setting("available_architectures", @archs); $localtlpdb->save() unless $opt_in_place; } # save_options_into_tlpdb sub import_settings_from_old_tlpdb { my $dn = shift; my $tlpdboldpath = "$dn/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName"; my $previoustlpdb; if (-r $tlpdboldpath) { # we found an old installation, so read that one in and save # the list installed collections into an array. info ("Trying to load old TeX Live Database,\n"); $previoustlpdb = TeXLive::TLPDB->new(root => $dn); if ($previoustlpdb) { info ("Importing settings from old installation in $dn\n"); } else { tlwarn ("Cannot load old TLPDB, continuing with normal installation.\n"); return; } } else { return; } ############# OLD CODE ################### # in former times we sometimes didn't change from scheme-full # to scheme-custom when deselecting some collections # this is fixed now. # # # first import the collections # # since the scheme is not the final word we select scheme-custom here # # and then set the single collections by hand # $vars{'selected_scheme'} = "scheme-custom"; # $vars{'n_collections_selected'} = 0; # # remove the selection of all collections # foreach my $entry (keys %vars) { # if ($entry=~/^(collection-.*)/) { # $vars{"$1"}=0; # } # } # for my $c ($previoustlpdb->collections) { # my $tlpobj = $tlpdb->get_package($c); # if ($tlpobj) { # $vars{$c} = 1; # ++$vars{'n_collections_selected'}; # } # } ############ END OF OLD CODE ############ ############ NEW CODE ################### # we simply go through all installed schemes, install # all depending collections # if we find scheme-full we use this as 'selected_scheme' # otherwise we use 'scheme_custom' as we don't know # and there is no total order on the schemes. # # we cannot use select_scheme from tlmgr.pl, as this one clears # previous selctions (hmm :-( $vars{'selected_scheme'} = "scheme-custom"; $vars{'n_collections_selected'} = 0; # remove the selection of all collections foreach my $entry (keys %vars) { if ($entry=~/^(collection-.*)/) { $vars{"$1"}=0; } } # now go over all the schemes *AND* collections and select them foreach my $s ($previoustlpdb->schemes) { my $tlpobj = $tlpdb->get_package($s); if ($tlpobj) { foreach my $e ($tlpobj->depends) { if ($e =~ /^(collection-.*)/) { # do not add collections multiple times if (!$vars{$e}) { $vars{$e} = 1; ++$vars{'n_collections_selected'}; } } } } } # Now do the same for collections: for my $c ($previoustlpdb->collections) { my $tlpobj = $tlpdb->get_package($c); if ($tlpobj) { if (!$vars{$c}) { $vars{$c} = 1; ++$vars{'n_collections_selected'}; } } } ########### END NEW CODE ############# # now take over the path my $oldroot = $previoustlpdb->root; my $newroot = abs_path("$oldroot/..") . "/$texlive_release"; $vars{'TEXDIR'} = $newroot; $vars{'TEXMFSYSVAR'} = "$newroot/texmf-var"; $vars{'TEXMFSYSCONFIG'} = "$newroot/texmf-config"; # only TEXMFLOCAL is treated differently, we use what is found by kpsewhich # in 2008 and onward this is defined as # TEXMFLOCAL = $SELFAUTOPARENT/../texmf-local # so kpsewhich -var-value=TEXMFLOCAL returns # ..../2008/../texmf-local # TODO TODO TODO chomp (my $tml = `kpsewhich -var-value=TEXMFLOCAL`); $tml = abs_path($tml); $vars{'TEXMFLOCAL'} = $tml; # # now for the settings # set the defaults to what is specified in the tlpdb $vars{'tlpdbopt_install_docfiles'} = $previoustlpdb->option_pkg("00texlive.installation", "install_docfiles"); $vars{'tlpdbopt_install_srcfiles'} = $previoustlpdb->option_pkg("00texlive.installation", "install_srcfiles"); $vars{'tlpdbopt_create_formats'} = $previoustlpdb->option_pkg("00texlive.installation", "create_formats"); $vars{'tlpdbopt_desktop_integration'} = 1 if wndws(); $vars{'instopt_adjustpath'} = $previoustlpdb->option_pkg("00texlive.installation", "path"); $vars{'instopt_adjustpath'} = 0 if !defined($vars{'instopt_adjustpath'}); $vars{'instopt_adjustpath'} = 1 if wndws(); $vars{'tlpdbopt_sys_bin'} = $previoustlpdb->option_pkg("00texlive.installation", "sys_bin"); $vars{'tlpdbopt_sys_man'} = $previoustlpdb->option_pkg("00texlive.installation", "sys_man"); $vars{'sys_info'} = $previoustlpdb->option_pkg("00texlive.installation", "sys_info"); # # import the set of selected architectures my @aar = $previoustlpdb->setting_pkg("00texlive.installation", "available_architectures"); if (@aar) { for my $b ($tlpdb->available_architectures) { $vars{"binary_$b"} = member( $b, @aar ); } $vars{'n_systems_available'} = 0; for my $key (keys %vars) { ++$vars{'n_systems_available'} if ($key=~/^binary/); } } # # try to import paper settings my $xdvi_paper; if (!wndws()) { $xdvi_paper = TeXLive::TLPaper::get_paper("xdvi"); } my $pdftex_paper = TeXLive::TLPaper::get_paper("pdftex"); my $dvips_paper = TeXLive::TLPaper::get_paper("dvips"); my $dvipdfmx_paper = TeXLive::TLPaper::get_paper("dvipdfmx"); my $context_paper; if (defined($previoustlpdb->get_package("context"))) { $context_paper = TeXLive::TLPaper::get_paper("context"); } my $common_paper = ""; if (defined($xdvi_paper)) { $common_paper = $xdvi_paper; } $common_paper = ($common_paper ne $context_paper ? "no-agree-on-paper" : $common_paper) if (defined($context_paper)); $common_paper = ($common_paper ne $pdftex_paper ? "no-agree-on-paper" : $common_paper) if (defined($pdftex_paper)); $common_paper = ($common_paper ne $dvips_paper ? "no-agree-on-paper" : $common_paper) if (defined($dvips_paper)); $common_paper = ($common_paper ne $dvipdfmx_paper ? "no-agree-on-paper" : $common_paper) if (defined($dvipdfmx_paper)); if ($common_paper eq "no-agree-on-paper") { tlwarn("Previous installation uses different paper settings.\n"); tlwarn("You will need to select your preferred paper sizes manually.\n\n"); } else { if ($common_paper eq "letter") { $vars{'instopt_letter'} = 1; } elsif ($common_paper eq "a4") { # do nothing } else { tlwarn( "Previous installation has common paper setting of: $common_paper\n"); tlwarn("After installation has finished, you will need\n"); tlwarn(" to redo this setting by running:\n"); } } # update size information $vars{'free_size'} = TeXLive::TLUtils::diskfree($vars{'TEXDIR'}); } # import_settings_from_old_tlpdb # do everything to select a scheme # sub select_scheme { my $s = shift; # set the selected scheme to $s $vars{'selected_scheme'} = $s; debug("setting selected scheme: $s\n"); # if we are working on scheme-custom simply return return if ($s eq "scheme-custom"); # 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'}; } } } # we have first set all collection-* keys to zero and than # set to 1 only those which are required by the scheme # since now scheme asks for collection-wintools we set its vars value # to 1 in case we are installing windows binaries if ($vars{"binary_windows"}) { $vars{"collection-wintools"} = 1; ++$vars{'n_collections_selected'}; } # for good measure, update the deps calc_depends(); } # select_scheme # try to give a decent order of schemes, but be so general that # if we change names of schemes nothing bad happnes (like forgetting one) sub schemes_ordered_for_presentation { my @scheme_order; my %schemes_shown; for my $s ($tlpdb->schemes) { $schemes_shown{$s} = 0 ; } # first try the size-name-schemes in decreasing order for my $sn (qw/full medium small basic minimal infraonly/) { if (defined($schemes_shown{"scheme-$sn"})) { push @scheme_order, "scheme-$sn"; $schemes_shown{"scheme-$sn"} = 1; } } # now push all the other schemes if they are there and not already shown for my $s (sort keys %schemes_shown) { push @scheme_order, $s if !$schemes_shown{$s}; } return @scheme_order; } # schemes_ordered_for_presentation sub update_numbers { $vars{'n_collections_available'}=0; $vars{'n_collections_selected'} = 0; $vars{'n_systems_available'} = 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; } } } # update_numbers # signal handler for interrupts SIGINT AND SIGTERM sub signal_handler { my ($sig) = @_; flushlog(); print STDERR "$0: caught SIG$sig -- exiting\n"; exit(1); } # to be called at exit when the installation did not complete sub flushlog { if (!defined($::LOGFILENAME)) { my $fh; my $logfile = "install-tl.log"; if (open (LOG, ">$logfile")) { my $pwd = Cwd::getcwd(); $logfile = "$pwd/$logfile"; print "$0: Writing log in current directory: $logfile\n"; $fh = \*LOG; } else { $fh = \*STDERR; print "$0: Could not write to $logfile, so flushing messages to stderr.\n"; } foreach my $l (@::LOGLINES) { print $fh $l; } } } # flushlog sub do_cleanup { # remove temporary files from TEXDIR/temp if (($media eq "local_compressed") or ($media eq "NET")) { debug("Remove temporary downloaded containers...\n"); rmtree("$vars{'TEXDIR'}/temp") if (-d "$vars{'TEXDIR'}/temp"); } # write the profile out if ($opt_in_place) { create_profile("$vars{'TEXDIR'}/texlive.profile"); debug("Profile written to $vars{'TEXDIR'}/texlive.profile\n"); } else { create_profile("$vars{'TEXDIR'}/$InfraLocation/texlive.profile"); debug("Profile written to $vars{'TEXDIR'}/$InfraLocation/texlive.profile\n"); } # now open the log file and write out the log lines if needed. # the user could have given the -logfile option in which case all the # stuff is already dumped to it and $::LOGFILE defined. So do not # redefine it. if (!defined($::LOGFILE)) { # no -logfile option; nothing written yet $::LOGFILENAME = "$vars{'TEXDIR'}/install-tl.log"; if (open(LOGF,">:utf8", $::LOGFILENAME)) { $::LOGFILE = \*LOGF; foreach my $line(@::LOGLINES) { print $::LOGFILE "$line"; } } else { tlwarn("$0: Cannot create log file $::LOGFILENAME: $!\n" . "Not writing out log lines.\n"); } } # Close log file if present close($::LOGFILE) if (defined($::LOGFILE)); if (!defined($::LOGFILENAME) and (-e "$vars{'TEXDIR'}/install-tl.log")) { $::LOGFILENAME = "$vars{'TEXDIR'}/install-tl.log"; } if (!(defined($::LOGFILENAME)) or !(-e $::LOGFILENAME)) { $::LOGFILENAME = ""; } } # do_cleanup sub check_env { # check for tex-related envvars. $::env_warns = ""; for my $evar (sort keys %origenv) { next if $evar =~ /^(_.* |.*PWD |ARGS |GENDOCS_TEMPLATE_DIR |INSTROOT |INFOPATH |MANPATH |PATH |PERL5LIB |SHELLOPTS |WISH )$/x; # don't worry about these if ("$evar $origenv{$evar}" =~ /tex/i) { # check both key and value $::env_warns .= " $evar=$origenv{$evar}\n"; } } if ($::env_warns) { $::env_warns = <<"EOF"; ---------------------------------------------------------------------- The following environment variables contain the string "tex" (case-independent). If you're doing anything but adding personal directories to the system paths, they may well cause trouble somewhere while running TeX. If you encounter problems, try unsetting them. Please ignore spurious matches unrelated to TeX. (To omit this check, set the environment variable TEXLIVE_INSTALL_ENV_NOCHECK.) $::env_warns ---------------------------------------------------------------------- EOF } } # Create a welcome message. sub create_welcome { @::welcome_arr = (); push @::welcome_arr, __("Welcome to TeX Live!"); push @::welcome_arr, __("See %s/index.html for links to documentation.\n", $::vars{'TEXDIR'}); push @::welcome_arr, __("The TeX Live web site (https://tug.org/texlive/) provides all updates\nand corrections. TeX Live is a joint project of the TeX user groups\naround the world; please consider supporting it by joining the group\nbest for you. The list of groups is available on the web\nat https://tug.org/usergroups.html.\n"); if (wndws() || ($vars{'instopt_adjustpath'} && $vars{'tlpdbopt_desktop_integration'} != 2)) { ; # don't tell them to make path adjustments on Windows, # or if they chose to "create symlinks". } else { push @::welcome_arr, __( "Add %s/texmf-dist/doc/man to MANPATH.\nAdd %s/texmf-dist/doc/info to INFOPATH.\nMost importantly, add %s/bin/%s\nto your PATH for current and future sessions.\n", $::vars{'TEXDIR'}, $::vars{'TEXDIR'}, $::vars{'TEXDIR'}, $::vars{'this_platform'}); } } # remember the warnings issued sub install_warnlines_hook { push @::warn_hook, sub { push @::WARNLINES, @_; }; } ## a summary of warnings if there were any #sub warnings_summary { # return '' unless @::WARNLINES; # my $summary = <{$_} = 1; } } sub deselect_collections { my $varref = shift; foreach (@_) { $varref->{$_} = 0; } } __END__ =head1 NAME install-tl - TeX Live cross-platform installer =head1 SYNOPSIS install-tl [I