diff options
author | Norbert Preining <preining@logic.at> | 2009-05-12 15:53:11 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2009-05-12 15:53:11 +0000 |
commit | 7e5585bcd4f8ba119cad8f0a7e13b6a7a610776f (patch) | |
tree | c48db3cea0e4511d09d0e7b7fdf7ef7a04f68f6e /Master/install-tl | |
parent | c84165218f94bc15a1441e91a421f4d070bc5eb7 (diff) |
Move most of the stuff from tlpkg, tlmgr from branch to trunk
git-svn-id: svn://tug.org/texlive/trunk@13054 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/install-tl')
-rwxr-xr-x | Master/install-tl | 799 |
1 files changed, 455 insertions, 344 deletions
diff --git a/Master/install-tl b/Master/install-tl index 073061c4f10..ecc989cce22 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -50,11 +50,10 @@ use TeXLive::TLUtils qw(platform platform_desc get_system_tmpdir member process_logging_options rmtree mkdirhier make_var_skeleton make_local_skeleton install_package copy install_packages dirname setup_programs welcome welcome_paths); -use TeXLive::TLMedia; +#use TeXLive::TLMedia; use TeXLive::TLPOBJ; use TeXLive::TLPDB; use TeXLive::TLConfig; -use TeXLive::TLPostActions; if (win32) { require TeXLive::TLWinGoo; @@ -82,7 +81,6 @@ if (win32) { &add_menu_shortcut &remove_desktop_shortcut &remove_menu_shortcut - &init_unshortbat &create_uninstaller )); } @@ -121,7 +119,7 @@ our @collections_lang_doc; # # The following values are taken from the remote tlpdb using the # $tlpdb->option_XXXXX -# settings (i.e., taken from tlpkg/tlpsrc/00texlive-installation.tlpsrc +# settings (i.e., taken from tlpkg/tlpsrc/00texlive.installation.tlpsrc # # 'option_symlinks' => 0, # 'sys_bin' => '/usr/local/bin', @@ -146,7 +144,7 @@ our %vars=( # 'n_' means 'number of'. # option handling my $opt_from_dvd = ""; -my $opt_gui = (win32() ? "perltk" : "text"); +my $opt_gui = (win32() ? "wizard" : "text"); my $opt_help = 0; my $opt_location = ""; my $opt_no_gui = 0; @@ -256,6 +254,7 @@ if ($opt_nonadmin and win32()) { # media, while $localtlpdb is for the new installation # $tlpdb must be our because it is used in install-menu-text.pl our $tlpdb; +our $previoustlpdb; my $localtlpdb; my $location; @@ -380,6 +379,14 @@ if (($media eq "NET") || ($media eq "CD")) { $vars{'doc_splitting_supported'} = $tlpdb->config_doc_container; } $texlive_release = $tlpdb->config_release; +# 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 ($texlive_release !~ m/^$TeXLive::TLConfig::ReleaseYear/) { + die "The release version of the installation source and\nthe installation media do not agree:\nsource: $texlive_release\nmedia: $TeXLive::TLConfig::ReleaseYear\nPlease report to tex-live\@tug.org"; +} set_platforms_supported(); set_texlive_default_dirs(); initialize_collections(); @@ -437,9 +444,29 @@ if ($opt_profile eq "") { 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 + { + my $tlmgrwhich = which("tlmgr"); + if ($tlmgrwhich) { + my $dn = dirname($tlmgrwhich); + $dn = abs_path("$dn/../.."); + my $tlpdboldpath = "$dn/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName"; + if (-r $tlpdboldpath) { + # we found an old installation, so read that one in and save + # the list installed collections into an array. + $previoustlpdb = TeXLive::TLPDB->new(root => $dn); + if ($previoustlpdb) { + debug ("found old installation in $dn\n"); + push @runargs, "-old-installation-found"; + } + } + } + } + my $ret = &{$::run_menu}(@runargs); if ($ret == $MENU_QUIT) { - do_cleanup(); MISSING + do_cleanup(); flushlog(); exit(1); } @@ -483,6 +510,10 @@ exit(0); ################################################################### sub do_installation { + if (win32()) { + debug("Switching to non-admin mode due to explict user request!\n"); + non_admin() if !$vars{'option_w32_multi_user'}; + } # do the actual installation my $h; prepare_installation(); @@ -491,7 +522,233 @@ sub do_installation { save_options_into_tlpdb(); do_install_packages(); } + # 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 ("That cannot happen, $s not defined in tlpdb") unless 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); + } + } + $localtlpdb->save unless $vars{'from_dvd'}; + do_postinst_stuff(); +} + +# do_postinst_stuff has to fix up the texmf tree and install some missing +# files. The things to do are taken from the install-live.sh installer +# of former times, and should be critically checked. +sub do_postinst_stuff { + my $TEXDIR="$vars{'TEXDIR'}"; + my $TEXDIRW="$vars{'TEXDIRW'}"; + my $TEXMFSYSVAR="$vars{'TEXMFSYSVAR'}"; + my $TEXMFSYSCONFIG="$vars{'TEXMFSYSCONFIG'}"; + my $TEXMFLOCAL="$vars{'TEXMFLOCAL'}"; + my $tmv; + + do_texmf_cnf() unless ($opt_portable); + + # + # 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"); + } + + # 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 @TMFVARS0=qw(VARTEXFONTS + TEXMF SYSTEXMF VARTEXFONTS + TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL + PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF); + my @TMFVARS1=qw(TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG + TEXMFHOME TEXMFVAR TEXMFCONFIG); + + if (defined($ENV{'TEXMFCNF'}) and !$vars{'from_dvd'} and !$opt_portable) { + print "WARNING: environment variable TEXMFCNF is set. +You should know what you are doing. +We will remove that for the post install actions, but all further +operations might be disturbed.\n\n"; + } + foreach $tmv (@TMFVARS0) { + delete $ENV{$tmv} if (defined($ENV{$tmv})); + } + if (!$opt_portable) { + foreach $tmv (@TMFVARS1) { + delete $ENV{$tmv} if (defined($ENV{$tmv})); + } + } + $ENV{'TEXMFSYSVAR'} = $vars{'TEXMFSYSVAR'} if $vars{'from_dvd'}; + + # Step 2: Setup the PATH, switch to the new Perl + + my $pathsep=(win32)? ';' : ':'; + my $plat_bindir="$TEXDIR/bin/$vars{'this_platform'}"; + my $perl_bindir="$TEXDIR/tlpkg/tlperl/bin"; + my $perl_libdir="$TEXDIR/tlpkg/tlperl/lib"; + +## This won't do any good; +## have to remove other tex directories in calling batchfile +# if (win32) { +# debug("Removing other TeXs from path\n"); +# my @newpt = (); +# foreach my $d (split (';', $ENV{'PATH'})) { +# push @newpt, $d unless TeXLive::TLWinGoo::is_a_texdir($d); +# } +# $ENV{'PATH'} = join($pathsep, @newpt); +# debug("Path after removals(s):\n $ENV{'PATH'}\n"); +# } + + debug("Prepending $plat_bindir to PATH\n"); + + $ENV{'PATH'}="$plat_bindir" . "$pathsep" . "$ENV{'PATH'}"; + + if (win32) { + debug("Prepending $perl_bindir to PATH\n"); + $ENV{'PATH'}="$perl_bindir" . "$pathsep" . "$ENV{'PATH'}"; + $ENV{'PATH'} =~ s!/!\\!g; + } + + debug("\nNew PATH is now:\n"); + foreach my $dir (split $pathsep, $ENV{'PATH'}) { + debug(" $dir\n"); + } + debug("\n"); + + if (win32) { + $ENV{'PERL5LIB'}="$perl_libdir"; + } + + # + # post install actions + # + + # in case we are running from DVD we use the tlpdb from the DVD, otherwise + # the one we have locally created, for all the further actions + my $usedtlpdb = $vars{'from_dvd'} ? $tlpdb : $localtlpdb; + + + if (win32()) { + debug "Actual environment:\n".`set`."\n\n"; + debug 'Effective TEXMFCNF: '.`kpsewhich -expand-path=\$TEXMFCNF`."\n"; + } + + # TODO: can the following two clauses be merged? if (win32()) { + create_uninstaller($vars{'TEXDIR'}, $vars{'TEXDIRW'}, + $vars{'TEXMFSYSVAR'}, $vars{'TEXMFSYSCONFIG'}); + } + # (re-)initialize batchfile for uninstalling shortcuts + if (win32() and !$opt_portable) { + mkdirhier("$TEXDIRW/tlpkg/installer") if $vars{'from_dvd'}; + } + + # Step 4: run the programs + + if (!$opt_portable and !$vars{'from_dvd'}) { + info("running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); + system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf"); + } + + # we have to generate the various config file. That could be done with + # texconfig generate * but Win32 does not have texconfig. But we have + # $localtlpdb and this is simple code, so do it directly, i.e., duplicate + # the code from the various generate-*.pl scripts + + info("writing fmtutil.cnf data to $TEXMFSYSVAR/web2c/fmtutil.cnf\n"); + TeXLive::TLUtils::create_fmtutil($usedtlpdb, + "$TEXMFSYSVAR/web2c/fmtutil.cnf", + "$TEXMFLOCAL/web2c/fmtutil-local.cnf"); + + mkdirhier "$vars{'TEXMFSYSCONFIG'}/web2c"; + info("writing updmap.cfg to $TEXMFSYSCONFIG/web2c/updmap.cfg\n"); + TeXLive::TLUtils::create_updmap ($usedtlpdb, + "$TEXMFSYSCONFIG/web2c/updmap.cfg", + "$TEXMFLOCAL/web2c/updmap-local.cfg"); + + info("writing language.dat data 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 data 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("running mktexlsr $TEXMFSYSVAR\n"); + system('mktexlsr', "$TEXMFSYSVAR"); + + info("running updmap-sys... "); + # system('updmap-sys', '--nohash'); + log(`updmap-sys --nohash 2>&1`); + info("done\n"); + + info("re-running mktexlsr $TEXMFSYSVAR\n"); + system('mktexlsr', "$TEXMFSYSVAR"); + + # now work through the options if specified at all + + # letter instead of a4 + if ($vars{'option_letter'}) { + info("Setting default paper size to letter\n"); + system("tlmgr", "paper", "letter"); + } + + # all formats option + if ($vars{'option_fmt'}) { + info("pre-generating all format files (fmtutil-sys --all), be patient..."); + log(`fmtutil-sys --all 2>&1`); + info("done\n"); + } + + # + # do path adjustments: On Windows add/remove to PATH etc, on Unix + # set symlinks + do_path_adjustments() if $vars{'option_path'}; + + # no do the system integration: + # on unix this means setting up symlinks + # on w32 this means adding to path, settting registry values + # on both, we run the postaction directives of the tlp + do_tlpdb_postactions(); +} + + +sub do_tlpdb_postactions { + info ("running package specific postactions\n"); + # Run the post installation code in the postaction tlpsrc entries + my $usedtlpdb = $vars{'from_dvd'} ? $tlpdb : $localtlpdb; + foreach my $package (sort keys %install) { + if ($install{$package}) { + &TeXLive::TLUtils::do_postaction("install", + $usedtlpdb->get_package($package), + $vars{'option_file_assocs'}, + $vars{'option_desktop_integration'}, + $vars{'option_post_code'}); + } + } + info ("finished with package specific postactions\n"); +} + +sub do_path_adjustments { + info ("running path adjustment actions\n"); + if (win32()) { + update_assocs(); + my $path = TeXLive::TLWinGoo::get_system_env() -> {'/Path'}; $path =~ s/[\s\x00]+$//; log("Old system path: $path\n"); @@ -516,29 +773,98 @@ sub do_installation { # setenv_reg('TEXMFSYSVAR', $vars{'TEXMFSYSVAR'}) if $vars{'from_dvd'}; setenv_reg('TEXMFCNF', $vars{'TEXMFSYSVAR'}.'/web2c') if $vars{'from_dvd'}; broadcast_env(); - create_uninstaller($vars{'TEXDIR'}, $vars{'TEXDIRW'}, - $vars{'TEXMFSYSVAR'}, $vars{'TEXMFSYSCONFIG'}); + } else { + $localtlpdb->add_symlinks() } - do_postinst_stuff(); - # 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 ("That cannot happen, $s not defined in tlpdb") unless defined($stlp); - my $incit = 1; - foreach my $d ($stlp->depends) { - if (!defined($localtlpdb->get_package($d))) { - $incit = 0; - last; + info ("finished with path adjustment actions\n"); +} + + +# we have to adjust the texmf.cnf file to the paths set in the configuration! +sub do_texmf_cnf { + open(TMF,"<$vars{'TEXDIR'}/texmf/web2c/texmf.cnf") + or die "$vars{'TEXDIR'}/texmf/web2c/texmf.cnf not found: $!"; + my @texmfcnflines = <TMF>; + close(TMF); + my @newtmf; + my @changedtmf; + # 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"; + push @changedtmf, "TEXMFLOCAL = $vars{'TEXMFLOCAL'}\n"; } - } - if ($incit) { - $localtlpdb->add_tlpobj($stlp); + } 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"; + push @changedtmf, "TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}\n"; + } + } elsif ($line =~ m/^TEXMFSYSCONFIG/) { + # by default TEXMFSYSCONFIG = TEXDIR/texmf-config, if this is the case + # we don't have to change anything from the default + if ("$vars{'TEXMFSYSCONFIG'}" eq "$vars{'TEXDIR'}/texmf-config") { + push @newtmf, $line; + } else { + push @newtmf, "TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}\n"; + push @changedtmf, "TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}\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"; + if ("$vars{'TEXMFHOME'}" ne "~/texmf") { + push @changedtmf, "TEXMFHOME = $vars{'TEXMFHOME'}\n"; + } + } elsif ($line =~ m/^OSFONTDIR/) { + if (win32()) { + push @newtmf, "OSFONTDIR = \$SystemRoot/fonts//\n"; + push @changedtmf, "OSFONTDIR = \$SystemRoot/fonts//\n"; + } else { + push @newtmf, $line; + } + } else { + push @newtmf, $line; } } - $localtlpdb->save unless $vars{'from_dvd'}; + my $TMF; + if (!$vars{'from_dvd'}) { + $TMF = ">$vars{'TEXDIR'}/texmf.cnf"; + open(TMF, $TMF) || die "open($TMF) failed: $!"; + print TMF <<EOF; +% This texmf.cnf file should contain only your personal changes from the +% main texmf.cnf. +% +% Do NOT change values in the main file (which is in +% .../texlive/YYYY/texmf/web2c/texmf.cnf), as YOUR CHANGES WILL BE LOST +% by later updates. +% +% If you need to make changes to texmf.cnf, put your custom settings in +% this file instead, which is YYYY/texmf.cnf. And insert *only* your +% changed values. +% +EOF +; + foreach (@changedtmf) { print TMF; } + } else { + $TMF = ">$vars{'TEXMFSYSVAR'}/web2c/texmf.cnf"; + open (TMF, $TMF) || die "open($TMF) failed: $!\n"; + foreach (@newtmf) { print TMF; } + } + close(TMF) || warn "close($TMF) failed: $!"; } + sub dump_vars { my $filename=shift; my $fh; @@ -625,15 +951,21 @@ sub calc_depends { # 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)) { - die ("Scheme $vars{'selected_scheme'} not defined, vars:\n"); - dump_vars(\*STDOUT); - } - - for my $scheme_content ($scheme->depends) { - $install{"$scheme_content"}=1 unless ($scheme_content=~/^collection-/); + 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 @@ -744,7 +1076,14 @@ sub load_tlpdb { $vars{'option_fmt'} = $tlpdb->option_create_formats; $vars{'option_letter'} = defined($tlpdb->option_paper) && ($tlpdb->option_paper eq "letter" ? 1 : 0); - $vars{'option_symlinks'} = $tlpdb->option_create_symlinks; + $vars{'option_desktop_integration'} = $tlpdb->option_desktop_integration; + $vars{'option_desktop_integration'} = 1 if win32(); + $vars{'option_path'} = $tlpdb->option_path; + $vars{'option_path'} = 1 if win32(); + $vars{'option_w32_multi_user'} = $tlpdb->option_w32_multi_user; + $vars{'option_file_assocs'} = $tlpdb->option_file_assocs; + # $vars{'option_file_assocs'} = 1 if win32(); + $vars{'option_post_code'} = $tlpdb->option_post_code; $vars{'sys_bin'} = $tlpdb->option_sys_bin; $vars{'sys_man'} = $tlpdb->option_sys_man; $vars{'sys_info'} = $tlpdb->option_sys_info; @@ -846,12 +1185,9 @@ sub create_profile { foreach my $key (sort 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/; - if ($vars{'option_symlinks'}) { + print $fh "$key $vars{$key}\n" if $key =~ /^option_/; + print $fh "$key $vars{$key}\n" if (($key =~ /^binary_/) && $vars{$key}); + if ($vars{'option_desktop_integration'} && unix()) { print $fh "sys_bin ", $vars{'sys_bin'}, "\n" if $key =~ /^sys_bin/; print $fh "sys_man ", $vars{'sys_man'}, "\n" if $key =~ /^sys_man/; print $fh "sys_info ", $vars{'sys_info'}, "\n" if $key =~ /^sys_info/; @@ -873,9 +1209,9 @@ sub read_profile { or die "$0: Cannot open profile $profilepath for reading.\n"; my %pro; while (<PROFILE>) { + chomp; next if m/^[[:space:]]*$/; # skip empty lines next if m/^[[:space:]]*#/; # skip comment lines - chomp; # remove eol my ($k,$v) = split (" ", $_, 2); # value might have spaces $pro{$k} = $v; } @@ -949,7 +1285,11 @@ sub save_options_into_tlpdb { $localtlpdb->option_location($location); $localtlpdb->option_paper($vars{'option_letter'} ? "letter" : "a4"); $localtlpdb->option_create_formats($vars{'option_fmt'} ? "1" : "0"); - $localtlpdb->option_create_symlinks($vars{'option_symlinks'} ? "1" : "0"); + $localtlpdb->option_desktop_integration($vars{'option_desktop_integration'} ? "1" : "0"); + $localtlpdb->option_file_assocs($vars{'option_file_assocs'} ? "1" : "0"); + $localtlpdb->option_path($vars{'option_path'} ? "1" : "0"); + $localtlpdb->option_post_code($vars{'option_post_code'} ? "1" : "0"); + $localtlpdb->option_w32_multi_user($vars{'option_w32_multi_user'} ? "1" : "0"); $localtlpdb->option_sys_bin($vars{'sys_bin'}); $localtlpdb->option_sys_info($vars{'sys_info'}); $localtlpdb->option_sys_man($vars{'sys_man'}); @@ -965,318 +1305,87 @@ sub save_options_into_tlpdb { $localtlpdb->save() unless $vars{'from_dvd'}; } -# do_postinst_stuff has to fix up the texmf tree and install some missing -# files. The things to do are taken from the install-live.sh installer -# of former times, and should be critically checked. -sub do_postinst_stuff { - my $TEXDIR="$vars{'TEXDIR'}"; - my $TEXDIRW="$vars{'TEXDIRW'}"; - my $TEXMFSYSVAR="$vars{'TEXMFSYSVAR'}"; - my $TEXMFSYSCONFIG="$vars{'TEXMFSYSCONFIG'}"; - my $TEXMFLOCAL="$vars{'TEXMFLOCAL'}"; - my $tmv; - - do_texmf_cnf() unless ($opt_portable); - - - # final program execution - # we have to do several things: - # - clean the environment from spurious TEXMF related variables - # - add the bin dir to the PATH - # - select perl interpreter and set the correct perllib - # - run the programs - - # Step 1: Clean the environment - my @TMFVARS0=qw(VARTEXFONTS - TEXMF SYSTEXMF VARTEXFONTS - TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL - PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF); - my @TMFVARS1=qw(TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG - TEXMFHOME TEXMFVAR TEXMFCONFIG); - if (defined($ENV{'TEXMFCNF'}) and !$vars{'from_dvd'} and !$opt_portable) { - print "WARNING: environment variable TEXMFCNF is set. -You should know what you are doing. -We will remove that for the post install actions, but all further -operations might be disturbed.\n\n"; - } - foreach $tmv (@TMFVARS0) { - delete $ENV{$tmv} if (defined($ENV{$tmv})); - } - if (!$opt_portable) { - foreach $tmv (@TMFVARS1) { - delete $ENV{$tmv} if (defined($ENV{$tmv})); +sub import_settings_from_old_tlpdb { + # 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; } } - $ENV{'TEXMFSYSVAR'} = $vars{'TEXMFSYSVAR'} if $vars{'from_dvd'}; - - # Step 2: Setup the PATH, switch to the new Perl - - my $pathsep=(win32)? ';' : ':'; - my $plat_bindir="$TEXDIR/bin/$vars{'this_platform'}"; - my $perl_bindir="$TEXDIR/tlpkg/tlperl/bin"; - my $perl_libdir="$TEXDIR/tlpkg/tlperl/lib"; - -## This won't do any good; -## have to remove other tex directories in calling batchfile -# if (win32) { -# debug("Removing other TeXs from path\n"); -# my @newpt = (); -# foreach my $d (split (';', $ENV{'PATH'})) { -# push @newpt, $d unless TeXLive::TLWinGoo::is_a_texdir($d); -# } -# $ENV{'PATH'} = join($pathsep, @newpt); -# debug("Path after removals(s):\n $ENV{'PATH'}\n"); -# } - - debug("Prepending $plat_bindir to PATH\n"); - - $ENV{'PATH'}="$plat_bindir" . "$pathsep" . "$ENV{'PATH'}"; - - if (win32) { - debug("Prepending $perl_bindir to PATH\n"); - $ENV{'PATH'}="$perl_bindir" . "$pathsep" . "$ENV{'PATH'}"; - $ENV{'PATH'} =~ s!/!\\!g; - } - - debug("\nNew PATH is now:\n"); - foreach my $dir (split $pathsep, $ENV{'PATH'}) { - debug(" $dir\n"); - } - debug("\n"); - - if (win32) { - $ENV{'PERL5LIB'}="$perl_libdir"; + for my $c ($previoustlpdb->collections) { + my $tlpobj = $tlpdb->get_package($c); + if ($tlpobj) { + $vars{$c} = 1; + ++$vars{'n_collections_selected'}; + } } - + # now take over the path + my $oldroot = $previoustlpdb->root; + my $newroot = abs_path("$oldroot/..") . "/$texlive_release"; + $vars{'TEXDIR'} = $newroot; + $vars{'TEXDIRW'} = $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; # - # post install actions + # now for the settings + # set the defaults to what is specified in the tlpdb + $vars{'option_doc'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_install_docfiles"); + $vars{'option_src'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_install_srcfiles"); + $vars{'option_fmt'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_create_formats"); + my $tmp = $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_paper"); + $vars{'option_letter'} = defined($tmp) && ($tmp eq "letter" ? 1 : 0); + $vars{'option_desktop_integration'} = 1 if win32(); + # option_path does not exist in older installation + $vars{'option_path'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_create_symlinks"); + $vars{'option_path'} = 1 if win32(); + $vars{'sys_bin'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_sys_bin"); + $vars{'sys_man'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_sys_man"); + $vars{'sys_info'} = + $previoustlpdb->option_pkg("00texlive-installation.config", + "opt_sys_info"); # - - if (win32()) { - debug "Actual environment:\n".`set`."\n\n"; - debug 'Effective TEXMFCNF: '.`kpsewhich -expand-path=\$TEXMFCNF`."\n"; - } - - # (re-)initialize batchfile for uninstalling shortcuts - if (win32() and !$opt_portable) { - mkdirhier("$TEXDIRW/tlpkg/installer") if $vars{'from_dvd'}; - init_unshortbat($TEXDIRW); - } - - foreach my $package (sort keys %install) { - if ($install{$package} && defined($PostInstall{$package})) { - info("running post install action for $package\n"); - &{$PostInstall{$package}}($TEXDIR, $TEXDIRW, $TEXMFSYSVAR, $TEXMFLOCAL); - } - } - # $opt_portable: no %install but we still want xetex postinstall - &{$PostInstall{'xetex'}}($TEXDIR, $TEXDIRW, $TEXMFSYSVAR, $TEXMFLOCAL) - if $opt_portable; - update_assocs() if win32(); - - # Step 4: run the programs - - if (!$opt_portable and !$vars{'from_dvd'}) { - info("running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); - system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf"); - } - - # we have to generate the various config file. That could be done with - # texconfig generate * but Win32 does not have texconfig. But we have - # $localtlpdb and this is simple code, so do it directly, i.e., duplicate - # the code from the various generate-*.pl scripts - info("writing fmtutil.cnf data to $TEXMFSYSVAR/web2c/fmtutil.cnf\n"); - my $tlp = $vars{'from_dvd'} ? $tlpdb : $localtlpdb; - TeXLive::TLUtils::create_fmtutil($tlp, #$localtlpdb, - "$TEXMFSYSVAR/web2c/fmtutil.cnf", - "$TEXMFLOCAL/web2c/fmtutil-local.cnf"); - - mkdirhier "$vars{'TEXMFSYSCONFIG'}/web2c"; - info("writing updmap.cfg to $TEXMFSYSCONFIG/web2c/updmap.cfg\n"); - TeXLive::TLUtils::create_updmap ($tlp, #$localtlpdb, - "$TEXMFSYSCONFIG/web2c/updmap.cfg", - "$TEXMFLOCAL/web2c/updmap-local.cfg"); - - info("writing language.dat data to $TEXMFSYSVAR/tex/generic/config/language.dat\n"); - TeXLive::TLUtils::create_language_dat($tlp, #$localtlpdb, - "$TEXMFSYSVAR/tex/generic/config/language.dat", - "$TEXMFLOCAL/tex/generic/config/language-local.dat"); - - info("writing language.def data to $TEXMFSYSVAR/tex/generic/config/language.def\n"); - TeXLive::TLUtils::create_language_def($tlp, #$localtlpdb, - "$TEXMFSYSVAR/tex/generic/config/language.def", - "$TEXMFLOCAL/tex/generic/config/language-local.def"); - - info("running mktexlsr $TEXMFSYSVAR\n"); - system('mktexlsr', "$TEXMFSYSVAR"); - - info("running updmap-sys... "); - # system('updmap-sys', '--nohash'); - log(`updmap-sys --nohash 2>&1`); - info("done\n"); - - info("re-running mktexlsr $TEXMFSYSVAR\n"); - system('mktexlsr', "$TEXMFSYSVAR"); - - # now work through the options if specified at all - - # letter instead of a4 - if ($vars{'option_letter'}) { - info("Setting default paper size to letter\n"); - if (platform() eq "hppa-hpux") { - # we didn't get a texlua binary for hppa-hpux, so try texconfig - system("texconfig", "paper", "letter"); - } else { - system("texlua", "$TEXDIR/texmf/scripts/texlive/texconf.tlu", "--sys", "--noformat", "paper", "letter"); - } - } - - # all formats option - if ($vars{'option_fmt'}) { - info("pre-generating all format files (fmtutil-sys --all), be patient... "); - #system('fmtutil-sys', '--all'); - # try to capture that output - log(`fmtutil-sys --all 2>&1`); - info("done.\n"); - } - - # option_links - if ($vars{'option_symlinks'}) { - # bin files - my @files; - mkdirhier $vars{'sys_bin'}; - if (-w $vars{'sys_bin'}) { - info("linking binaries to $vars{'sys_bin'}\n"); - @files = `ls $plat_bindir`; - chomp(@files); - `cd "$vars{'sys_bin'}" && rm -f @files`; - `ln -s "$plat_bindir/"* "$vars{'sys_bin'}"`; - } else { - info("destination of bin symlink $vars{'sys_bin'} not writable, " - . "no linking of bin files done.\n"); - } - if ($vars{'option_doc'}) { - # info files - mkdirhier $vars{'sys_info'}; - if (-w $vars{'sys_info'}) { - info("linking info pages to $vars{'sys_info'}\n"); - @files = `ls "$TEXDIR/texmf/doc/info"`; - chomp(@files); - `cd "$vars{'sys_info'}" && rm -f @files`; - `ln -s "$TEXDIR/texmf/doc/info/"*info* "$vars{'sys_info'}"`; - } else { - info("destination of info symlink $vars{'sys_info'} not writable, " - . "no linking of info files done.\n"); - } - # man files - mkdirhier $vars{'sys_man'}; - if (-w $vars{'sys_man'}) { - info("linking man pages to $vars{'sys_man'}\n"); - my $foo = `(cd "$TEXDIR/texmf/doc/man" && echo *)`; - my @mans = split ' ', $foo; - chomp(@mans); - foreach my $m (@mans) { - my $mandir = "$TEXDIR/texmf/doc/man/$m"; - next unless -d $mandir; - mkdirhier "$vars{'sys_man'}/$m"; - next unless -w "$vars{'sys_man'}/$m"; - @files = `ls "$mandir"`; - chomp(@files); - `cd "$vars{'sys_man'}/$m" && rm -f @files`; - `ln -s "$mandir/"* "$vars{'sys_man'}/$m"`; - } - } else { - info("destination of man symlink $vars{'sys_man'} not writable, " - . "no linking of man files done.\n"); - } + # import the set of selected architectures + my $val = $previoustlpdb->option_pkg("00texlive-installation.config", + "available_architectures"); + my @aar; + if (defined($val)) { + @aar = split(" ", $val); + for my $b ($tlpdb->available_architectures) { + $vars{"binary_$b"} = member( $b, @aar ); } - } -} - - -# we have to adjust the texmf.cnf file to the paths set in the configuration! -sub do_texmf_cnf { - open(TMF,"<$vars{'TEXDIR'}/texmf/web2c/texmf.cnf") - or die "$vars{'TEXDIR'}/texmf/web2c/texmf.cnf not found: $!"; - my @texmfcnflines = <TMF>; - close(TMF); - my @newtmf; - my @changedtmf; - # 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"; - push @changedtmf, "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"; - push @changedtmf, "TEXMFSYSVAR = $vars{'TEXMFSYSVAR'}\n"; - } - } elsif ($line =~ m/^TEXMFSYSCONFIG/) { - # by default TEXMFSYSCONFIG = TEXDIR/texmf-config, if this is the case - # we don't have to change anything from the default - if ("$vars{'TEXMFSYSCONFIG'}" eq "$vars{'TEXDIR'}/texmf-config") { - push @newtmf, $line; - } else { - push @newtmf, "TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}\n"; - push @changedtmf, "TEXMFSYSCONFIG = $vars{'TEXMFSYSCONFIG'}\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"; - if ("$vars{'TEXMFHOME'}" ne "~/texmf") { - push @changedtmf, "TEXMFHOME = $vars{'TEXMFHOME'}\n"; - } - } elsif ($line =~ m/^OSFONTDIR/) { - if (win32()) { - push @newtmf, "OSFONTDIR = \$SystemRoot/fonts//\n"; - push @changedtmf, "OSFONTDIR = \$SystemRoot/fonts//\n"; - } else { - push @newtmf, $line; - } - } else { - push @newtmf, $line; + $vars{'n_systems_available'} = 0; + for my $key (keys %vars) { + ++$vars{'n_systems_available'} if ($key=~/^binary/); } } - my $TMF; - if (!$vars{'from_dvd'}) { - $TMF = ">$vars{'TEXDIR'}/texmf.cnf"; - open(TMF, $TMF) || die "open($TMF) failed: $!"; - print TMF <<EOF; -% This texmf.cnf file should contain only your personal changes from the -% main texmf.cnf. -% -% Do NOT change values in the main file (which is in -% .../texlive/YYYY/texmf/web2c/texmf.cnf), as YOUR CHANGES WILL BE LOST -% by later updates. -% -% If you need to make changes to texmf.cnf, put your custom settings in -% this file instead, which is YYYY/texmf.cnf. And insert *only* your -% changed values. -% -EOF -; - foreach (@changedtmf) { print TMF; } - } else { - $TMF = ">$vars{'TEXMFSYSVAR'}/web2c/texmf.cnf"; - open (TMF, $TMF) || die "open($TMF) failed: $!\n"; - foreach (@newtmf) { print TMF; } - } - close(TMF) || warn "close($TMF) failed: $!"; } # do everything to select a scheme @@ -1285,6 +1394,8 @@ sub select_scheme { my $s = shift; # set the selected scheme to $s $vars{'selected_scheme'} = $s; + # 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-.*)/) { |