From c261f817156842528b8326c5dbaeae8796786e27 Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Thu, 20 Mar 2008 09:31:09 +0000 Subject: Portable shell script, also affects install-tl.pl. git-svn-id: svn://tug.org/texlive/trunk@7041 c570f23f-e606-0410-a88d-b1316a301751 --- Master/install-tl.pl | 74 +++++++++++++++++++++++++++++++++++----- Master/tl-portable.sh | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 9 deletions(-) create mode 100755 Master/tl-portable.sh diff --git a/Master/install-tl.pl b/Master/install-tl.pl index 678f30531a5..09c6bd89fe6 100755 --- a/Master/install-tl.pl +++ b/Master/install-tl.pl @@ -25,6 +25,8 @@ BEGIN { if ($me=~m!/!) { ($::installerdir=$me)=~s!(.*)/.*$!$1!; + # we have to chdir to the Master ... + chdir($::installerdir); } else { $::installerdir='.'; } @@ -143,6 +145,7 @@ my $opt_dddebug = 0; my $opt_quiet = 0; my $opt_qquiet = 0; my $opt_arch = 0; +my $opt_portable = 0; $::netarchive = "tlpkg"; $::diskarchive = "archive"; @@ -158,6 +161,7 @@ GetOptions("media=s" => \$opt_media, "diskarchive=s" => \$::diskarchive, "lang=s" => \$::lang, "print-arch" => \$opt_arch, + "portable" => \$opt_portable, "d" => \$opt_debug, "dd" => \$opt_ddebug, "ddd" => \$opt_dddebug, @@ -220,6 +224,49 @@ my $system_tmpdir=get_system_tmpdir(); if ($opt_arch) { print platform; exit 0; +} elsif ($opt_portable) { + $::LOGLEVELTERMINAL = $::LOG_ZERO; + # initialize_installer: + $::_media_ = "DVD"; + $::_platform_ = platform(); + $vars{'TEXDIR'} = getenv('TEXDIR'); + if (not -d $vars{'TEXDIR'}.'/bin/'.$::_platform_) { # shouldn't happen + print "Platform ".$::_platform_." not supported\n"; + exit 1; + } + # set_platforms_supported(); + # set_texlive_default_dirs(); + $vars{'TEXMFSYSVAR'} = getenv('TEXMFSYSVAR'); + $vars{'TEXMFSYSCONFIG'} = getenv('TEXMFSYSCONFIG'); + $vars{'TEXMFLOCAL'} = getenv('TEXMFLOCAL'); + $vars{'TEXMFHOME'} = getenv('TEXMFHOME'); + $vars{'TEXMFVAR'} = getenv('TEXMFVAR'); + $vars{'TEXMFCONFIG'} = getenv('TEXMFCONFIG'); + # initialize_collections(); + # set_install_platform(); + $vars{'this_platform'} = platform(); + # do_installation(); + # prepare_installation(); + if (win32()) { + non_admin(); + my $winpath = "$vars{'TEXDIR'}/bin/win32"; + register_script_type(".texlua", $winpath."/texlua.exe"); + update_assocs(); + } + mkdirhier "$vars{'TEXMFCONFIG'}"; + if (not -d "$vars{'TEXMFSYSVAR'}" ) { + print "About to generate some files... Press "; + ; + load_tlpdb(); + $localtlpdb = $tlpdb; + $texlive_release = $tlpdb->config_release; + make_var_skeleton "$vars{'TEXMFSYSVAR'}"; + #$localtlpdb=new TeXLive::TLPDB; + #$localtlpdb->root("$vars{'TEXDIR'}"); + do_postinst_stuff(); + } + close($::LOGFILE) if defined($::LOGFILE); + exit 0; } tllog($::LOG_NORMAL, "Platform: ", platform, " => \'", platform_desc(platform), "\'\n"); @@ -348,8 +395,6 @@ exit(0); sub do_installation { # do the actual installation - # we have to chdir to the Master ... - chdir($::installerdir); foreach my $h (@::start_install_hook) { &$h(); } @@ -779,7 +824,7 @@ sub do_postinst_stuff { # 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(); + do_texmf_cnf() unless $opt_portable; # final program execution @@ -790,14 +835,23 @@ sub do_postinst_stuff { # - run the programs # Step 1: Clean the environment - my @TMFVARS=qw(VARTEXFONTS TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR - TEXMFSYSCONFIG TEXMFHOME TEXMFVAR TEXMFCONFIG TEXMF SYSTEXMF VARTEXFONTS + #my @TMFVARS=qw(VARTEXFONTS TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR + # TEXMFSYSCONFIG TEXMFHOME TEXMFVAR TEXMFCONFIG TEXMF SYSTEXMF VARTEXFONTS + # TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL + # PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF); + my @TMFVARS0=qw(VARTEXFONTS + TEXMF SYSTEXMF VARTEXFONTS TEXMFDBS WEB2C TEXINPUTS TEXFORMATS MFBASES MPMEMS TEXPOOL MFPOOL MPPOOL PSHEADERS TEXFONTMAPS TEXPSHEADERS TEXCONFIG TEXMFCNF); + my @TMFVARS1=qw(TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG + TEXMFHOME TEXMFVAR TEXMFCONFIG); - foreach my $tmv (@TMFVARS) { - $ENV{$tmv}=undef if (defined($ENV{$tmv})); + foreach my $tmv (@TMFVARS0) { + delete $ENV{$tmv} if (defined($ENV{$tmv})); } + if (!$opt_portable) { foreach my $tmv (@TMFVARS1) { + delete $ENV{$tmv} if (defined($ENV{$tmv})); + }} # Step 2: Setup the PATH, PATHEXT, switch to the new Perl @@ -829,8 +883,10 @@ sub do_postinst_stuff { # Step 4: run the programs - tllog($::LOG_NORMAL, "running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); - system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf"); + if (!$opt_portable) { + tllog($::LOG_NORMAL, "running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); + system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf"); + } # we have to generate the various config file. That could be done with # texconfig generate * but Win32 does not have texconfig. But we have diff --git a/Master/tl-portable.sh b/Master/tl-portable.sh new file mode 100755 index 00000000000..c9402d42e00 --- /dev/null +++ b/Master/tl-portable.sh @@ -0,0 +1,93 @@ +#! /bin/sh + +#calculate TeXLive root +#it appears that dirname isn't always available +TEXDIR=$0 +TEXDIR=${TEXDIR%/*} + +dirsave=`pwd` +cd $TEXDIR +TEXDIR=`pwd` +export TEXDIR +cd $dirsave + +# test whether the TeXLive directory is writable. + +if test -w $TEXDIR; then + tlwrite=$TEXDIR +else + tlwrite=$HOME/.texlive2008 +fi + +# Use $TEXMFHOME for private data, +# $TEXMFLOCAL for department- or workgroup data. +# It is allright if $TEXMFLOCAL does not exist. + +TEXMFSYSVAR=$tlwrite/texmf-var +if test -d $TEXDIR/texmf-var; then + TEXMFSYSVAR=$TEXDIR/texmf-var +fi +export TEXMFSYSVAR +TEXMFSYSCONFIG=$tlwrite/texmf-config +if test -f $TEXDIR/texmf-config; then + TEXMFSYSCONFIG=$TEXDIR/texmf-config +fi +export TEXMFSYSCONFIG +TEXMFMAIN=$TEXDIR/texmf +export TEXMFMAIN +TEXMFDIST=$TEXDIR/texmf-dist +export TEXMFDISTMAIN +TEXMFLOCAL=$TEXDIR/texmf-local +export TEXMFLOCAL +TEXMFHOME=$tlwrite/texmf-home +export TEXMFHOME +TEXMFVAR=$tlwrite/texmf-var +export TEXMFVAR +TEXMFCONFIG=$tlwrite/texmf-config +export TEXMFCONFIG + +platform=`$TEXDIR/install-try.pl --print-arch` + +if test "$platform" = ""; then + echo 'Platform unsupported' + exit 1 +elif test ! -d $TEXDIR/bin/$platform; then + echo 'Platform unsupported' + exit 1 +fi + +$TEXDIR/install-try.pl --portable + +#; try to block initialization scripts and +# set custom prompt for secondary shell +# but I know of no good way to do this for the C shell. + +if test "$SHELL" = /bin/bash; then + TLARGS=--norc + PS1='TL $PWD\$ ' +elif test "$SHELL" = /bin/zsh; then + TLARGS=-f + PS1='TL %d%% ' +elif test "$SHELL" = /bin/csh; then + TLARGS=-f +elif test "$SHELL" = /bin/tcsh; then + TLARGS=-f +else + TLARGS="" + PS1='TL $PWD\$ ' +fi +ENV=/dev/null +export ENV + +PATH=$TEXDIR/bin/$platform:$PATH \ +TEXMFSYSVAR=$TEXMFSYSVAR \ +TEXMFSYSCONFIG=$TEXMFSYSCONFIG \ +TEXMFMAIN=$TEXMFMAIN \ +TEXMFDIST=$TEXMFDIST \ +TEXMFLOCAL=$TEXMFLOCAL \ +TEXMFHOME=$TEXMFHOME \ +TEXMFVAR=$TEXMFVAR \ +TEXMFCONFIG=$TEXMFCONFIG \ +ENV=$ENV \ +PS1=$PS1 \ +$SHELL $TLARGS -i -- cgit v1.2.3