#!/usr/bin/env perl # $Id$ # install-tl.pl # # Copyright 2007 2008 Reinhard Kotucha, Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # my $svnrev = '$Revision$'; $svnrev =~ m/: ([0-9]+) /; $::installerrevision = $1; # is now taken from 00texlive.config: release, $tlpdb->config_release; our $texlive_release; BEGIN { $^W = 1; my $me=$0; $me=~s!\\!/!g if $^O=~/^MSWin(32|64)$/i; if ($me=~m!/!) { ($::installerdir=$me)=~s!(.*)/.*$!$1!; } else { $::installerdir='.'; } # The installer uses a minimal subset of Perl for Windows. In order # to avoid conflicts with other versions of Perl already installed on # the system, we simply ignore them. The installer has to execute # $::installerdir/tlpkg/bin/perl.exe and should not rely on any other # Perl executable. if ($^O=~/^MSWin(32|64)$/i) { #$ENV{'PERL5LIB'}=undef; @INC="$::installerdir/tlpkg/lib/Perl5_lib-TL_inst"; } unshift (@INC, "$::installerdir/tlpkg"); } use TeXLive::TLUtils qw(initialize_installer media platform platform_desc which getenv win32 unix program_exists architectures_available additional_architectures_available_from_net get_system_tmpdir member mkdirhier make_var_skeleton make_local_skeleton install_package copy install_packages dirname tllog); use TeXLive::TLPOBJ; use TeXLive::TLPDB; use TeXLive::TLConfig qw($DefaultContainerExtension $InfraLocation); use TeXLive::TLWinGoo; use Getopt::Long; use utf8; no utf8; # default language $::lang = "en"; if ($^O !~ /^MSWin(32|64)$/i) { # we load POSIX and locale stuff require POSIX; import POSIX qw/locale_h/; # now we try to deduce $::lang my $loc = setlocale(&POSIX::LC_CTYPE); my ($lang,$area,$codeset); if ($loc =~ m/^([^_.]*)(_([^.]*))?(\.([^@]*))?(@.*)?$/) { $lang = defined($1)?$1:""; } $::lang = $lang if ($lang); } use strict; # debugging/logging cmd lines options: # -q shut up terminal output # -qq shut up also log file output # -d set $::LOGLEVELFILE to $::LOG_DEBUG # -dd set $::LOGLEVELFILE to $::LOG_DDEBUG # -ddd set $::LOGLEVELFILE to $::LOG_DDDEBUG # $::LOGLEVELFILE = $::LOG_NORMAL; $::LOGLEVELTERMINAL = $::LOG_NORMAL; @::LOGLINES = (); # # $install{$packagename} == 1 if it should be installed my %install; # if we should try to get additional binaries from the net # needs our since for menu ... our $trynet=0; # the url of net location, can be changed with -url .... # # for now it is my testing archive on tug.org #$::texlive_url = 'http://tug.org/svn/texlive/trunk/Master'; # for my own testing in the virtual machine #$::texlive_url = 'http://localhost/norbert/tltesting'; #$::texlive_url = 'http://10.0.2.2/norbert/tltesting'; $::texlive_url = 'http://tug.org/~preining/tltesting'; # the default scheme to be installed my $default_scheme='scheme-full'; # some arrays where the lists of collections to be installed are saved # our for menus our @collections_std; our @collections_lang; our @collections_lang_doc; # The maximum number of binary systems on the CD. This number must be # smaller than the number of binaries available from the network. our $max_bins_on_CD=7; # for win dealing #our $Registry; # The global variable %vars is an associative list which contains all # variables and their values which can be changed by the user. # needs to be our since TeXLive::TLUtils uses it our %vars=( # 'n_' means 'number of'. 'this_platform' => platform(), 'n_systems_available' => 0, 'n_systems_selected' => 0, 'n_collections_selected' => 0, 'n_collections_available' => 0, 'total_size' => 0, 'option_symlinks' => 0, 'sys_bin' => '/usr/local/bin', 'sys_man' => '/usr/local/man', 'sys_info' => '/usr/local/info', 'option_doc' => 1, 'option_src' => 1, 'option_fmt' => 0, 'option_letter' => 0, 'selected_scheme' => $default_scheme, ); # option handling my $opt_media = ""; my $opt_url = ""; my $opt_profile = ""; my $opt_no_cls=0; my $opt_gui = 0; my $opt_debug = 0; my $opt_ddebug = 0; my $opt_dddebug = 0; my $opt_quiet = 0; my $opt_qquiet = 0; $::netarchive = "archive"; $::diskarchive = "archive"; GetOptions("media=s" => \$opt_media, "profile=s"=> \$opt_profile, "no-cls", "gui", \$opt_gui, "netarchive=s" => \$::netarchive, "diskarchive=s" => \$::diskarchive, "lang=s" => \$::lang, "d" => \$opt_debug, "dd" => \$opt_ddebug, "ddd" => \$opt_dddebug, "q" => \$opt_quiet, "qq" => \$opt_qquiet, "url=s" => \$opt_url ) or die("No pod doc till now!"); if ($opt_quiet) { $::LOGLEVELTERMINAL = $::LOG_ZERO; } if ($opt_qquiet) { $::LOGLEVELTERMINAL = $::LOG_ZERO; $::LOGLEVELFILE = $::LOG_ZERO; } if ($opt_debug) { $::LOGLEVELFILE = $::LOG_DEBUG; } if ($opt_ddebug) { $::LOGLEVELFILE = $::LOG_DDEBUG; } if ($opt_dddebug) { $::LOGLEVELFILE = $::LOG_DDDEBUG; } if ("$opt_media" =~ m/^CD/i) { $::_media_ = "CD"; } elsif ("$opt_media" =~ m/^NET/i) { $::_media_ = "NET"; } elsif ("$opt_media" =~ m/^DVD/i) { $::_media_ = "DVD"; } if ("$opt_profile" ne "") { if (-r "$opt_profile") { tllog($::LOG_NORMAL, "Using automated installation using $opt_profile!"); } else { $opt_profile = ""; tllog($::LOG_NORMAL, "Profile $opt_profile not readable, continuing in interactive mode!"); } } if ("$opt_url" ne "") { $::texlive_url = "$opt_url"; } # the TLPDB instances we will use. $tlpdb is for the one from the installation # media, while $localtlpdb is for the new installation # $tlpdb must be our because it is used in install-menu-text.pl our $tlpdb; my $localtlpdb; # $finished == 1 if the menu call already did the installation my $finished = 0; @::start_install_hook = (); @::end_install_hook = (); @::start_postinst_hook = (); @::start_install_hook = (); my $system_tmpdir=get_system_tmpdir(); tllog($::LOG_NORMAL, "Platform: ", platform, " => \'", platform_desc(platform), "\'\n"); if (media() eq "DVD") { tllog($::LOG_NORMAL, "Distribution: live (uncompressed)\n"); } elsif (media() eq "CD") { tllog($::LOG_NORMAL, "Distribution: inst (compressed)\n"); } elsif (media() eq "NET") { tllog($::LOG_NORMAL, "Distribution: net (downloading)\n"); } else { tllog($::LOG_NORMAL, "Distribution: ", media(), "\n"); } tllog($::LOG_NORMAL, "Directory for Temporary Files: '", $system_tmpdir, "\'\n"); tllog($::LOG_NORMAL, "Installer Directory: '$::installerdir'\n"); initialize_installer(); load_tlpdb(); $texlive_release = $tlpdb->config_release; set_platforms_supported(); set_texlive_default_dirs(); initialize_collections(); set_install_platform(); if ($opt_profile eq "") { # do the normal interactive installation! # # here we could load different menu systems. Currently several things # are "our" so that the menu implementation can use it. The $tlpdb, the # %var, and all the @collection* # install-menu-*.pl should implement a function run_menu() and should # change ONLY stuff in %vars # The allowed keys in %vars should be specified somewhere ... # the menu implementation should return # MENU_INSTALL do the installation # MENU_ABORT abort every action immediately, no cleanup # MENU_QUIT try to quit and clean up mess our $MENU_INSTALL = 0; our $MENU_ABORT = 1; our $MENU_QUIT = 2; our $MENU_ALREADYDONE = 3; if ($opt_gui) { # try to load Tk.pm, but don't die if it doesn't work eval { require Tk; }; if ($@) { # that didn't work out, so warn the user and continue with text mode tllog($::LOG_NORMAL, "Cannot load Tk, maybe something is missing!\n"); tllog($::LOG_NORMAL, "Error message from loading Tk:\n"); tllog($::LOG_NORMAL, "$@\n"); tllog($::LOG_NORMAL, "Continuing in Text Mode...\n"); $opt_gui = 0; } } if ($opt_gui) { require("installer/install-menu-perltk.pl"); } else { require("installer/install-menu-text.pl"); } my $ret = run_menu(); if ($ret == $MENU_QUIT) { # do_cleanup(); MISSING flushlog(); exit(1); } if ($ret == $MENU_ABORT) { # NO do_cleanup()! flushlog(); exit(2); } if ($ret == $MENU_ALREADYDONE) { tllog($::LOG_DEBUG, "run_menu has already done the work ... cleaning up!\n"); $finished = 1; } if (!$finished && ($ret != $MENU_INSTALL)) { tllog($::LOG_NORMAL, "Unknown return value of run_menu: $ret\n"); exit(3); } } else { read_profile("$opt_profile"); } if (!$finished) { # do the actual installation do_installation(); } # now open the log file and write out the log lines # try to open a log file if ($::LOGLEVELFILE > $::LOG_ZERO) { if (open(LOGF,">$vars{'TEXDIR'}/install-tl.log")) { $::LOGFILE = \*LOGF; foreach my $line(@::LOGLINES) { print $::LOGFILE "$line"; } } else { warn("Cannot create log file $vars{'TEXDIR'}/install-tl.log: $!\nNot writing out log lines!\n"); $::LOGLEVELFILE = $::LOG_ZERO; } } # dump various things to the log file if (defined($::LOGFILE)) { print $::LOGFILE "\nDump of vars:\n"; foreach my $key (keys %vars) { print $::LOGFILE "$key $vars{$key}\n"; } create_profile($::LOGFILE); } dump_vars("$system_tmpdir/texlive.vars"); # write the profile out create_profile("$vars{'TEXDIR'}/$InfraLocation/texlive.profile"); tllog($::LOG_DEBUG, "Profile written to $vars{'TEXDIR'}/$InfraLocation/texlive.profile\n"); # Close log file if present close($::LOGFILE) if defined($::LOGFILE); exit(0); ################################################################### # # FROM HERE ON ONLY SUBROUTINES # NO VARIABLE DECLARATIONS # ################################################################### sub do_installation { # do the actual installation foreach my $h (@::start_install_hook) { &$h(); } calc_depends(); prepare_installation(); do_install_packages(); if (win32()) { do_win_registry_magic(); } foreach my $h (@::start_postinst_hook) { &$h(); } do_postinst_stuff(); foreach my $h (@::end_install_hook) { &$h(); } } sub dump_vars { my $filename=shift; my $fh; if (ref($filename)) { $fh = $filename; } else { open VARS, ">$filename"; $fh = \*VARS; } foreach my $key (keys %vars) { print $fh "$key $vars{$key}\n"; } close VARS if (!ref($filename)); tllog($::LOG_DEBUG, "\n%vars dumped to '$filename'.\n"); } # Determine which platforms are supported. sub set_platforms_supported { my @binaries=architectures_available; for my $binary (@binaries) { unless (defined $vars{"diskbin_$binary"}) { $vars{"diskbin_$binary"}=0; } } if ($trynet==1) { my @binaries=additional_architectures_available_from_net \%vars; for my $binary (@binaries) { $vars{"netbin_$binary"}=0; } } for my $key (keys %vars) { ++$vars{'n_systems_available'} if ($key=~/^(disk|net)bin/); } } # Environment variables and default values on UNIX: # TEXLIVE_INSTALL_PREFIX /usr/local/texlive => $tex_prefix # TEXLIVE_INSTALL_TEXDIR $tex_prefix/2007 => $TEXDIR # TEXLIVE_INSTALL_TEXMFSYSVAR $TEXDIR/texmf-var # TEXLIVE_INSTALL_TEXMFLOCAL $tex_prefix/texmf-local # TEXLIVE_INSTALL_TEXMFHOME '$HOME/texmf' sub set_texlive_default_dirs { my $tex_prefix; my $texmfsysvar; my $texmflocal; my $texmfhome; $tex_prefix=getenv('TEXLIVE_INSTALL_PREFIX'); if (win32) { #require("TeXLive/win-admin.pl"); $vars{'win-admin'} = admin(); if ($vars{'win-admin'}) { $tex_prefix||=getenv('ProgramFiles') . '/texlive'; } else { $tex_prefix||=getenv('USERPROFILE') . '/texlive'; } } else { $tex_prefix||='/usr/local/texlive'; } $vars{'TEXDIR'}="$tex_prefix/$texlive_release"; $texmfsysvar=getenv('TEXLIVE_INSTALL_TEXMFSYSVAR'); $texmfsysvar||=$vars{'TEXDIR'} . '/texmf-var'; $vars{'TEXMFSYSVAR'}="$texmfsysvar"; $texmflocal=getenv('TEXLIVE_INSTALL_TEXMFLOCAL'); $texmflocal||="$tex_prefix/texmf-local"; $vars{'TEXMFLOCAL'}="$texmflocal"; $texmfhome=getenv('TEXLIVE_INSTALL_TEXMFHOME'); $texmfhome ||= "~"; $vars{'TEXMFHOME'}="$texmfhome/texmf"; } sub calc_depends { # we have to reset the install hash EVERY TIME otherwise everything will # always be installed since the default is scheme-full which selects # all packages and never deselects it %install=(); # initialize the %install hash with what should be installed # First look for packages in the selected scheme. my $scheme=$tlpdb->get_package($vars{'selected_scheme'}); if (!defined($scheme)) { dump_vars(\*STDOUT); die ("Scheme $vars{'selected_scheme'} not defined!\n"); } for my $scheme_content ($scheme->depends) { $install{"$scheme_content"}=1 unless ($scheme_content=~/^collection-/); } # Now look for collections in the %vars hash. These are not # necessarily the collections required by a scheme. The final # decision is made in the collections/languages menu. foreach my $key (keys %vars) { if ($key=~/^collection-/) { $install{$key} = 1 if $vars{$key}; } } # compute the list of archs to be installed my @archs; foreach (keys %vars) { if (m/^diskbin_(.*)$/ ) { if ($vars{$_}) { push @archs, $1; } } if (m/^netbin_(.*)$/ ) { if ($vars{$_}) { push @archs, $1; } } } # if programs for arch=win32 are installed we also have to install # bin-tlperl.win32 which provides the "hidden" perl that will be used # to run all the perl scripts. if (grep(/^win32$/,@archs)) { $install{"bin-tlperl.win32"} = 1; } # loop over all the packages until it is getting stable my $changed = 1; while ($changed) { # set $changed to 0 $changed = 0; # collect the already selected packages my @pre_selected = keys %install; tllog($::LOG_DDEBUG, "initial number of installations: $#pre_selected\n"); # loop over all the pre_selected and add them foreach my $p (@pre_selected) { tllog($::LOG_DDEBUG, "pre_selected $p\n"); foreach my $p_dep ($tlpdb->get_package($p)->depends) { if ($p_dep =~ m/^(.*)\.ARCH$/) { my $foo = "$1"; foreach my $a (@archs) { $install{"$foo.$a"} = 1; } } elsif ($p_dep =~ m/^(.*)\.win32$/) { # a win32 package should *only* be installed if we are installing # the win32 arch if (grep(/^win32$/,@archs)) { $install{$p_dep} = 1; } } else { $install{$p_dep} = 1; } } } # check for newly selected packages my @post_selected = keys %install; tllog($::LOG_DDEBUG, "number of post installations: $#post_selected\n"); # set repeat condition if ($#pre_selected != $#post_selected) { $changed = 1; } } # now do the size computation my $size = 0; foreach my $p (keys %install) { my $tlpobj = $tlpdb->get_package($p); if (not(defined($tlpobj))) { die "Cannot find $p in texlive.tlpdb, strange!\n"; } $size+=$tlpobj->docsize if $vars{'option_doc'}; $size+=$tlpobj->srcsize if $vars{'option_src'}; $size+=$tlpobj->runsize; foreach my $a (@archs) { $size += $tlpobj->binsize->{$a} if defined($tlpobj->binsize->{$a}); } } $vars{'total_size'} = sprintf "%d", ($size * $TeXLive::TLConfig::BlockSize)/1024**2; } sub load_tlpdb { my $master; if (media eq 'NET') { $master="$::texlive_url"; } else { $master="$::installerdir"; } tllog($::LOG_NORMAL, "Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName ...\n"); $tlpdb=TeXLive::TLPDB->new(root => "$master"); } sub initialize_collections { foreach my $pkg ($tlpdb->list_packages) { my $tlpobj = $tlpdb->{'tlps'}{$pkg}; if ($tlpobj->category eq "Collection") { $vars{"$pkg"}=0; ++$vars{'n_collections_available'}; if ($pkg=~/collection-lang/) { push @collections_lang, $pkg; } elsif ($pkg=~/documentation/) { if ($pkg=~/documentation-base/) { push @collections_std, $pkg; } else { push @collections_lang_doc, $pkg; } } else { push @collections_std, $pkg; } } } my $scheme_tlpobj = $tlpdb->get_package($default_scheme); if (defined ($scheme_tlpobj)) { $vars{'n_collections_selected'}=0; foreach my $dependent ($scheme_tlpobj->depends) { if ($dependent=~/^(collection-.*)/) { $vars{"$1"}=1; ++$vars{'n_collections_selected'}; } } } } sub set_install_platform { my @available_platforms; my $detected_platform=platform; my $warn_nobin; my $warn_nobin_x86_64_linux; my $nowarn=""; my $wp='##'; # warning prefix $warn_nobin="\n$wp WARNING! No binaries for your platform found! "; if (media eq 'CD') { $warn_nobin.="More binaries are available\n$wp on the DVD. The binary " . "systems menu allows you to download extra binaries\n" . "$wp from the network.\n"; } $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{"diskbin_$detected_platform"}) { $vars{"diskbin_$detected_platform"}=1; $vars{'inst_platform'}=$detected_platform; $ret = $nowarn; } elsif (defined $vars{"netbin_$detected_platform"}) { $vars{"netbin_$detected_platform"}=1; $vars{'inst_platform'}=$detected_platform; $ret = $nowarn; } elsif ($detected_platform eq 'x86_64-linux') { $vars{'diskbin_i386-linux'}=1; $vars{'inst_platform'}='i386-linux'; $ret = $warn_nobin_x86_64_linux; } else { $ret = $warn_nobin; } foreach my $key (keys %vars) { if ($key=~/^diskbin.*/ or $key=~/^netbin.*/) { ++$vars{'n_systems_selected'} if $vars{$key}==1; } } return($ret); } sub create_profile { my $profilepath = shift; # The file "TLprofile" is created at the beginning of the # installation process and contains information about the current # setup. The purpose is to allow non-interactive installations. my $fh; if (ref($profilepath)) { $fh = $profilepath; } else { open PROFILE, ">$profilepath"; $fh = \*PROFILE; } my $tim = gmtime(time); print $fh "# texlive.profile written on $tim UTC\n"; print $fh "# it will NOT be overwritten and reflects only the\n"; print $fh "# installation profile at installation time\n"; print $fh "selected_scheme $vars{selected_scheme}\n"; foreach my $key (keys %vars) { print $fh "$key $vars{$key}\n" if $key=~/^collection/ and $vars{$key}==1; print $fh "$key $vars{$key}\n" if $key=~/^option_letter/; print $fh "$key $vars{$key}\n" if $key=~/^option_doc/; print $fh "$key $vars{$key}\n" if $key=~/^option_fmt/; print $fh "$key $vars{$key}\n" if $key=~/^option_src/; print $fh "$key $vars{$key}\n" if $key=~/^option_symlinks/; print $fh "$key $vars{$key}\n" if $key=~/^TEXDIR/; print $fh "$key $vars{$key}\n" if $key=~/^TEXMFSYSVAR/; print $fh "$key $vars{$key}\n" if $key=~/^TEXMFLOCAL/; print $fh "$key $vars{$key}\n" if $key=~/^TEXMFHOME/; } if (!ref($profilepath)) { close PROFILE; } } sub read_profile { my $profilepath = shift; open PROFILE, "<$profilepath" or die "Cannot open profile $profilepath for reading!\n"; my %pro; while () { next if m/^[[:space:]]*$/; # skip empty lines next if m/^[[:space:]]*#/; # skip comment lines my ($k,$v) = split; $pro{$k} = $v; } foreach (keys %vars) { # clear out collections from var if (m/^collection-/) { $vars{$_} = 0; } if (defined($pro{$_})) { $vars{$_} = $pro{$_}; } } } sub prepare_installation { make_var_skeleton "$vars{'TEXMFSYSVAR'}"; make_local_skeleton "$vars{'TEXMFLOCAL'}"; mkdirhier "$vars{'TEXDIR'}/texmf-config"; $localtlpdb=new TeXLive::TLPDB; $localtlpdb->root("$vars{'TEXDIR'}"); } sub do_install_packages { my @what; foreach my $package (sort keys %install) { push @what, $package if ($install{$package} == 1); } my @netarchs; foreach my $k (keys %vars) { if ($k =~ m/^netbin_(.*)$/) { my $a = $1; if ($vars{$k}) { push @netarchs, $a; } } } install_packages($tlpdb,$localtlpdb,\@what,\@netarchs,$vars{'option_src'},$vars{'option_doc'}); } # do_postinst_stuff has to fix up the texmf tree and install some missing # files. The things to do are taken from the install-live.sh installer # of former times, and should be critically checked. sub do_postinst_stuff { # install some copies from texmf(-dist) into texmf-var copy ("$vars{'TEXDIR'}/texmf-dist/tex/plain/config/language.def", "$vars{'TEXMFSYSVAR'}/tex/plain/config") if (-f "$vars{'TEXDIR'}/texmf-dist/tex/plain/config/language.def"); copy ("$vars{'TEXDIR'}/texmf/xdvi/XDvi", "$vars{'TEXMFSYSVAR'}/xdvi") if (-f "$vars{'TEXDIR'}/texmf/xdvi/XDvi"); # those files must exist copy ("$vars{'TEXDIR'}/texmf/dvips/config/config.ps", "$vars{'TEXMFSYSVAR'}/dvips/config"); copy ("$vars{'TEXDIR'}/texmf/dvipdfm/config/config", "$vars{'TEXMFSYSVAR'}/dvipdfm/config"); copy ("$vars{'TEXDIR'}/texmf/web2c/mktex.cnf", "$vars{'TEXMFSYSVAR'}/web2c"); # the old installer copied from CDDIR, but shouldn't this be installed # in ANY case since it is in bin-pdftex??? copy ("$vars{'TEXDIR'}/texmf/tex/generic/config/pdftexconfig.tex", "$vars{'TEXMFSYSVAR'}/tex/generic/config"); # old installer did this, should we do this, TOO???? #cp $CDDIR/texmf-dist/tex/context/config/cont-usr.tex $TEXMFSYSVAR/tex/context/config/cont-usr.tex # do_texmf_cnf(); # final program execution # we have to do several things: # - clean the environment from spurious TEXMF related variables # - add the bin dir to the PATH # - select perl interpreter and set the correct perllib # - run the programs # # Step 1: Clean the environment my @TMFVARS = qw(VARTEXFONTS TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG TEXMFHOME TEXMFVAR TEXMFCONFIG TEXMF SYSTEXMF VARTEXFONTS TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF); foreach my $tmv (@TMFVARS) { $ENV{$tmv} = undef if (defined($ENV{$tmv})); } # Step 2: Setup the PATH my $path = ""; if (defined($ENV{'PATH'})) { $path = $ENV{'PATH'}; } if (win32()) { $path = "$vars{'TEXDIR'}/bin/$vars{'this_platform'};$path"; } else { $path = "$vars{'TEXDIR'}/bin/$vars{'this_platform'}:$path"; } tllog($::LOG_NORMAL,"Setting PATH to $path\n"); $ENV{'PATH'} = "$path"; # Step 3: Make Perl find the right modules if (win32()) { # we are working with our version of perl # thus, we have to set the PERLLIB envvar right #my $perllib = ""; #if (defined($ENV{'PERL5LIB'})) { # $perllib = $ENV{'PERL5LIB'}; #} #$perllib .= ";$vars{'TEXDIR'}/tlpkg/tlperl/lib"; #$ENV{'PERL5LIB'} = $perllib; $ENV{'PERL5LIB'} = "$vars{'TEXDIR'}/tlpkg/tlperl/lib"; } # # Step 4: run the programs # how hackish: on windows it is hard to find the perl scripts ... my $perlint = (win32() ? "$vars{'TEXDIR'}/tlpkg/tlperl/bin/perl.exe" : ""); # for arch != win32 $perlint is empty so the usual perl invocation is done if (win32()) { tllog($::LOG_NORMAL, "running ${perlint} $vars{'TEXDIR'}/tlpkg/bin/generate-fmtutil\n"); `"${perlint}" "$vars{'TEXDIR'}/tlpkg/bin/generate-fmtutil"`; tllog($::LOG_NORMAL, "running ${perlint} $vars{'TEXDIR'}/tlpkg/bin/generate-updmap\n"); `"${perlint}" "$vars{'TEXDIR'}/tlpkg/bin/generate-updmap"`; tllog($::LOG_NORMAL, "running ${perlint} $vars{'TEXDIR'}/tlpkg/bin/generate-language\n"); `"${perlint}" "$vars{'TEXDIR'}/tlpkg/bin/generate-language"`; } else { tllog($::LOG_NORMAL, "running $vars{'TEXDIR'}/tlpkg/bin/generate-fmtutil\n"); `"$vars{'TEXDIR'}/tlpkg/bin/generate-fmtutil"`; tllog($::LOG_NORMAL, "running $vars{'TEXDIR'}/tlpkg/bin/generate-updmap\n"); `"$vars{'TEXDIR'}/tlpkg/bin/generate-updmap"`; tllog($::LOG_NORMAL, "running $vars{'TEXDIR'}/tlpkg/bin/generate-language\n"); `"$vars{'TEXDIR'}/tlpkg/bin/generate-language"`; } tllog($::LOG_NORMAL, "running mktexlsr $vars{'TEXDIR'}/texmf-dist $vars{'TEXDIR'}/texmf $vars{'TEXDIR'}/texmf-local\n"); `mktexlsr "$vars{'TEXDIR'}/texmf-dist" "$vars{'TEXDIR'}/texmf" "$vars{'TEXDIR'}/texmf-local"`; # my $updmap = (win32() ? "$perlint $vars{'TEXDIR'}/bin/win32/updmap-sys.pl" : "updmap-sys"); # `$updmap --nohash`; # we hope that the updmap-sys.texlua is executed ... # but to be sure we set the PATHEXT ... if (win32()) { my $pathext = $ENV{'PATHEXT'}; $pathext .= ";.texlua"; $ENV{'PATHEXT'} = $pathext; } tllog($::LOG_NORMAL, "running updmap-sys\n"); `updmap-sys --nohash`; tllog($::LOG_NORMAL, "re-running mktexlsr $vars{'TEXMFSYSVAR'}\n"); `mktexlsr "$vars{'TEXMFSYSVAR'}"`; # old installer: #$config && texconfig-sys init #$config || echo "PLEASE RUN texconfig or texconfig-sys to make new formats." } # we have to adjust the texmf.cnf file to the paths set in the configuration! sub do_texmf_cnf { open(TMF,"<$vars{'TEXDIR'}/texmf/web2c/texmf.cnf") or die("Huu, hasn't $vars{'TEXDIR'}/texmf/web2c/texmf.cnf not been installed?\n"); my @texmfcnflines = ; close(TMF); my @newtmf; # we have to find TEXMFLOCAL TEXMFSYSVAR and TEXMFHOME foreach my $line (@texmfcnflines) { if ($line =~ m/^TEXMFLOCAL/) { # by default TEXMFLOCAL = TEXDIR/../texmf-local, if this is the case # we don't have to change anything from the default my $deftmlocal = dirname($vars{'TEXDIR'}); $deftmlocal .= "/texmf-local"; if ("$vars{'TEXMFLOCAL'}" eq "$deftmlocal") { push @newtmf, $line; } else { push @newtmf, "TEXMFLOCAL = $vars{'TEXMFLOCAL'}\n"; } } elsif ($line =~ m/^TEXMFSYSVAR/) { # by default TEXMFSYSVAR = TEXDIR/texmf-var, if this is the case # we don't have to change anything from the default if ("$vars{'TEXMFSYSVAR'}" eq "$vars{'TEXDIR'}/texmf-var") { push @newtmf, $line; } else { push @newtmf, "TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}\n"; } } elsif ($line =~ m/^TEXMFHOME/) { # kpse now expands ~ to USERPROFILE, so we don't treat win32 and # unix differently push @newtmf, "TEXMFHOME = $vars{'TEXMFHOME'}\n"; } elsif ($line =~ m/^OSFONTDIR/) { if (win32()) { push @newtmf, "OSFONTDIR = \$SystemRoot/fonts//\n"; } else { push @newtmf, $line; } } else { push @newtmf, $line; } } open(TMF,">$vars{'TEXDIR'}/texmf/web2c/texmf.cnf") or die("Huu, cannot open $vars{'TEXDIR'}/texmf/web2c/texmf.cnf for writing: $!\n"); foreach (@newtmf) { print TMF; } close(TMF); } # register texlua handlers etc etc sub do_win_registry_magic { # we are called under if (win32()) !! my $winpath = "$vars{'TEXDIR'}/bin/win32"; #$winpath =~ s!/!\\!g; add_texbindir_to_path($winpath); register_script_type(".texlua", $winpath."/texlua.exe"); broadcast_env; } # # do everything to select a scheme # sub select_scheme { my $s = shift; # set the selected scheme to $s $vars{'selected_scheme'} = $s; # remove the selection of all collections foreach my $entry (keys %vars) { if ($entry=~/^(collection-.*)/) { $vars{"$1"}=0; } } # select the collections belonging to the scheme my $scheme_tlpobj = $tlpdb->get_package($s); if (defined ($scheme_tlpobj)) { $vars{'n_collections_selected'}=0; foreach my $dependent ($scheme_tlpobj->depends) { if ($dependent=~/^(collection-.*)/) { $vars{"$1"}=1; ++$vars{'n_collections_selected'}; } } } # for good measure, update the deps calc_depends(); } sub update_numbers { $vars{'n_collections_selected'}=0; $vars{'n_systems_available'} = 0; $vars{'n_collections_selected'} = 0; $vars{'n_systems_selected'} = 0; foreach my $key (keys %vars) { if ($key =~ /^(disk|net)bin/) { ++$vars{'n_systems_available'}; ++$vars{'n_systems_selected'} if $vars{$key} == 1; } if ($key =~ /^collection-/) { ++$vars{'n_collections_available'}; ++$vars{'n_collections_selected'} if $vars{$key} == 1; } } } sub flushlog { my $fh; if (open(LOG,">install-tl.log")) { warn "Writing log file to current working directory!\n"; $fh = \*LOG; } else { $fh = \*STDERR; warn "Not creating a log file but flushing messages to stderr:\n"; } foreach my $l (@::LOGLINES) { print $fh $l; } } __END__ ### Local Variables: ### perl-indent-level: 2 ### tab-width: 2 ### indent-tabs-mode: nil ### End: # vim:set tabstop=2 expandtab: #