diff options
Diffstat (limited to 'Master')
-rwxr-xr-x | Master/install-tl.bat | 3 | ||||
-rwxr-xr-x | Master/install-tl.pl | 26 | ||||
-rwxr-xr-x | Master/tl-portable.bat | 2 | ||||
-rwxr-xr-x | Master/tl-portable.sh | 29 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLWinGoo.pm | 283 | ||||
-rw-r--r-- | Master/tlpkg/doc/wingoo-demo.pl | 242 |
6 files changed, 407 insertions, 178 deletions
diff --git a/Master/install-tl.bat b/Master/install-tl.bat index d540c9d9cc5..cec4dfe80af 100755 --- a/Master/install-tl.bat +++ b/Master/install-tl.bat @@ -17,7 +17,8 @@ rem use provided Perl set PERL5SAVE=%PERL5LIB%
set PERL5LIB=%tlroot%tlpkg\installer\perllib
-"%tlroot%tlpkg\installer\perl" "%tlroot%install-tl.pl" %*
+rem "%tlroot%tlpkg\installer\perl" "%tlroot%install-tl.pl" %*
+"%tlroot%tlpkg\installer\perl" "%~dpn0.pl" %*
rem pause Done
rem cleanup in case of start from command-line
diff --git a/Master/install-tl.pl b/Master/install-tl.pl index 2bf329ea0d7..7a951a67e1b 100755 --- a/Master/install-tl.pl +++ b/Master/install-tl.pl @@ -57,6 +57,8 @@ if (win32) { require TeXLive::TLWinGoo; TeXLive::TLWinGoo->import( qw( &wg_error + &win_version + &is_vista &admin &non_admin ®_country @@ -65,6 +67,8 @@ if (win32) { &global_tmpdir &get_system_path &get_user_path + &setenv_reg + &unsetenv_reg &add_texbindir_to_path &remove_texbindirs_from_path ®ister_script_type @@ -137,6 +141,7 @@ my $opt_ddebug = 0; my $opt_dddebug = 0; my $opt_quiet = 0; my $opt_qquiet = 0; +my $opt_nonadmin = 0; my $opt_arch = 0; my $opt_portable = 0; my $opt_help = 0; @@ -211,6 +216,8 @@ if ("$opt_profile" ne "") { } } +if ($opt_nonadmin and win32()) { non_admin(); } + if ("$opt_url" ne "") { $TeXLiveURL = "$opt_url"; } @@ -259,7 +266,7 @@ if ($opt_arch) { if (win32()) { non_admin(); my $winpath = "$vars{'TEXDIR'}/bin/win32"; - register_script_type(".texlua", $winpath."/texlua.exe"); + register_script_type(".texlua", "%TEXBINDIR%/texlua.exe"); update_assocs(); } mkdirhier "$vars{'TEXMFCONFIG'}"; @@ -887,6 +894,8 @@ sub do_postinst_stuff { if (win32) { $ENV{'PATHEXT'}=".texlua;" . "$ENV{'PATHEXT'}"; + $ENV{'TEXBINDIR'}=$TEXDIR . "\\bin\\win32"; + $ENV{'TEXBINDIR'} =~ s!/!\\!g; $ENV{'PERL5LIB'}="$perl_libdir"; } @@ -1041,10 +1050,11 @@ sub do_texmf_cnf { # 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"); + my $texbindir = $vars{'TEXDIR'}."\\bin\\win32"; + $texbindir =~ s!/!\\!g; + add_texbindir_to_path($texbindir); + setenv_reg('TEXBINDIR', $texbindir); + register_script_type(".texlua", "%TEXBINDIR%/texlua.exe"); broadcast_env(); update_assocs(); } @@ -1117,7 +1127,7 @@ install-tl.pl - the TeX Live Cross Platform Installer =head1 SYNOPSIS -install-tl.pl [OPTION] ... +install-tl.pl [OPTION] ... install-tl.bat [OPTION] ... @@ -1127,7 +1137,7 @@ install-tl.bat [OPTION] ... =item B<-gui> -Tries to load the GUI installer using Perl/Tk. If Perl/Tk is not +Tries to load the GUI installer using Perl/Tk. If Perl/Tk is not available continue with the text mode installer. =item B<-lang> I<2-letter lang code> @@ -1159,7 +1169,7 @@ Overrides the default settings for diskarchive. Should be used with care. =item B<-no-cls> -(only for text mode installer) do not clear the screen when entering +(only for text mode installer) do not clear the screen when entering a new menu. For debugging purposes. =item B<-print-arch> diff --git a/Master/tl-portable.bat b/Master/tl-portable.bat index 39a631d781d..86459c050c9 100755 --- a/Master/tl-portable.bat +++ b/Master/tl-portable.bat @@ -37,7 +37,7 @@ set TEXMFLOCAL=%TEXDIR%texmf-local set TEXMFHOME=%tlwrite%texmf-home set TEXMFVAR=%tlwrite%texmf-var set TEXMFCONFIG=%tlwrite%texmf-config - +set TEXBINDIR=%TEXDIR%bin\win32 set platform=win32 rem use provided Perl diff --git a/Master/tl-portable.sh b/Master/tl-portable.sh index 678a4d6df6e..a1a41ec54f9 100755 --- a/Master/tl-portable.sh +++ b/Master/tl-portable.sh @@ -4,8 +4,12 @@ #calculate TeXLive root #it appears that dirname isn't always available -TEXDIR=$0 -TEXDIR=${TEXDIR%/*} +TEXDIR0=$0 +TEXDIR=${TEXDIR0%/*} +if test "$TEXDIR" = "$TEXDIR0"; then + TEXDIR="." +fi +unset TEXDIR0 dirsave=`pwd` cd $TEXDIR @@ -13,13 +17,27 @@ TEXDIR=`pwd` export TEXDIR cd $dirsave -# test whether the TeXLive directory is writable. +# Test whether the TeXLive directory is writable. We need an actual +# write test, because network drives aren't always identified +# correctly. We accept negatives at face value. if test -w $TEXDIR; then - tlwrite=$TEXDIR +# make sure $TEXDIR is really writable +$testfile=1 + while test -e $TEXDIR/$testfile + do testfile=`expr $testfile + 1` + done + echo Hello >$TEXDIR/testfile 2>/dev/null + if test -e $TEXDIR/$testfile; then + rm $TEXDIR/$testfile + tlwrite=$TEXDIR + else + tlwrite=$HOME/.texlive2008 + fi else tlwrite=$HOME/.texlive2008 fi +export tlwrite # Use $TEXMFHOME for private data, # $TEXMFLOCAL for department- or workgroup data. @@ -63,9 +81,6 @@ if $TEXDIR/install-tl.pl --portable; then :; else exit 1 fi -# Set custom prompt for secondary shell, but -# I know of no good way to do this for the C shell. - # Try to block initialization scripts. # Set custom prompt for secondary shell, but # I know of no good way to do this for the C shell. diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm index 4f4d974a217..8e4c79a5303 100644 --- a/Master/tlpkg/TeXLive/TLWinGoo.pm +++ b/Master/tlpkg/TeXLive/TLWinGoo.pm @@ -22,18 +22,34 @@ C<TeXLive::TLWinGoo> -- Additional utilities for Windows use TeXLive::TLWinGoo; +=head2 ERROR HANDLING + TeXLive::TLWinGoo::wg_error; + +=head2 DIAGNOSTICS + + TeXLive::TLWinGoo::win_version; + TeXLive::TLWinGoo::is_vista; TeXLive::TLWinGoo::admin; TeXLive::TLWinGoo::non_admin; TeXLive::TLWinGoo::reg_country; TeXLive::TLWinGoo::dir_writable($d); + +=head2 ENVIRONMENT AND REGISTRY + TeXLive::TLWinGoo::expand_string($s); TeXLive::TLWinGoo::global_tmpdir; TeXLive::TLWinGoo::get_system_path; TeXLive::TLWinGoo::get_user_path; + TeXLive::TLWinGoo::setenv_reg($env_var, $env_data); + TeXLive::TLWinGoo::unsetenv_reg($env_var); TeXLive::TLWinGoo::add_texbindir_to_path($texpath); + TeXLive::TLWinGoo::remove_texbindirs_from_path; TeXLive::TLWinGoo::register_script_type($extension, $command); TeXLive::TLWinGoo::unregister_script_type($extension); + +=head2 ACTIVATING CHANGES IMMEDIATELY + TeXLive::TLWinGoo::broadcast_env; TeXLive::TLWinGoo::update_assocs; @@ -51,6 +67,8 @@ BEGIN { @ISA = qw( Exporter ); @EXPORT = qw( &wg_error + &win_version + &is_vista &admin &non_admin ®_country @@ -59,6 +77,8 @@ BEGIN { &global_tmpdir &get_system_path &get_user_path + &setenv_reg + &unsetenv_reg &add_texbindir_to_path &remove_texbindirs_from_path ®ister_script_type @@ -75,6 +95,8 @@ BEGIN { &global_tmpdir ); if ($^O=~/^MSWin(32|64)$/i) { + #require Win32; + #Win32->import( qw( GetOSVersion ) ); require Win32::API; require Win32::TieRegistry; Win32::TieRegistry->import( qw( $Registry @@ -88,24 +110,71 @@ BEGIN { use TeXLive::TLUtils; -######################################### -# Variables storing status information. +my $is_win = $^O=~/^MSWin(32|64)$/i; -# error status stored in wg_errno and wg_errmess +=pod + +=back + +=head2 ERROR HANDLING + +=over 6 + +=item C<wg_error> + +Returns WinGoo error status, in the shape of an array (number, +message) and clears the error status. No error <=> error number 0 + +=cut my $wg_error = 0; my $wg_error_message = ""; -my $is_win = $^O=~/^MSWin(32|64)$/i; +sub wg_error { + my @retval = ($wg_error, $wg_error_message); + $wg_error = 0; + $wg_error_message = ""; + return @retval; +} -# Under Windows, the variables below are calculated while loading this module. -# The functions &admin and &global_tmpdir simply return these variables. +=pod -my $is_admin = 1; -my $global_tmp = "/tmp"; +=back + +=head2 DIAGNOSTICS + +=over 6 + +=item C<win_version> + +C<win_version> returns the Windows version number as stored in the +registry: 5.0 for Windows 2000, 5.1 for Windows XP and 6.0 for Vista. + +=cut + +my $windows_version = 0; + +if ($is_win) { + my $tempkey = $Registry->Open( + "LMachine/software/Microsoft/Windows NT/CurrentVersion/", + {Access => KEY_READ() }); + $windows_version = $tempkey -> { "/CurrentVersion" }; +} + +sub win_version { return $windows_version; } + +=item C<is_vista> + +C<is_vista> returns 1 if win_version is >= 6.0, otherwise 0. + +=cut + +sub is_vista { return $windows_version >= 6; } # permissions with which we try to access the system environment +my $is_admin = 1; + sub sys_access_permissions { $is_admin ? KEY_ALL_ACCESS() : KEY_READ() | KEY_ENUMERATE_SUB_KEYS(); } @@ -129,24 +198,6 @@ sub get_user_env { return $Registry -> Open("CUser/Environment", {Access => KEY_ALL_ACCESS()}); } -# error handling - -=pod - -=item C<wg_error> - -Returns WinGoo error status, in the shape of an array (number, -message) and clears the error status. No error <=> error number 0 - -=cut - -sub wg_error { - my @retval = ($wg_error, $wg_error_message); - $wg_error = 0; - $wg_error_message = ""; - return @retval; -} - =pod =item C<admin> @@ -162,8 +213,8 @@ sub admin { return $is_admin; } =item C<non_admin> -Renounce admin privileges, to enforce a user- rather than a system -install. +Pretend not to have admin privileges, to enforce a user- rather than +a system install. Currently only used for testing. @@ -195,7 +246,7 @@ sub reg_country { =pod -=item C<dir_writable> +=item C<dir_writable($d)> Tests whether its argument is writable by trying to write to it. This function is necessary because the built-in C<-w> test @@ -221,7 +272,28 @@ sub dir_writable { =pod -=item C<expand_string> +=back + +=head2 ENVIRONMENT AND REGISTRY + +=over 6 + +Most settings can be made for a user and for the system. User +settings override system settings. + +For admin users, the functions below affect both user- and system +settings. For non-admin users, only user settings are changed. + +An exception is the search path: the effective searchpath consists +of the system searchpath in front concatenated with the user +searchpath at the back. + +Note that in a roaming profile network setup, users take only user +settings with them to other systems, not system settings. In this +case, with a TeXLive on the network, a nonadmin install makes the +most sense. + +=item C<expand_string($s)> This function replaces substrings C<%env_var%> with their current values as environment variable and returns the result. @@ -255,6 +327,8 @@ if ($is_win) { $global_tmp = expand_string(get_system_env()->{'TEMP'}) if $is_win; } +my $global_tmp = "/tmp"; + sub global_tmpdir { return $global_tmp; } sub is_a_texdir { @@ -328,24 +402,64 @@ sub win_which_dir { return 0; } -#=pod -# -#=item C<add_to_path> -# -#Returns its arguments joined with C<;> as separator, or returns the second -#argument if the first is an empty string. -# -#=cut +=pod + +=item C<setenv_reg($env_var, $env_data[, $mode]);> -sub add_to_path { - my $old_path = shift @_; - my $addition = shift @_; - return ($old_path eq "") ? $addition : $old_path . ";" . $addition; +Set an environment variable $env_var to $env_data. + +$mode="user": set for current user. $mode="system": set for all +users. Default: both if admin, current user otherwise. + +=cut + +sub setenv_reg { + my $env_var = shift; + my $env_data = shift; + my $mode = @_ ? shift : "default"; + die "setenv_reg: Invalid mode" + if ($mode ne "user" and $mode ne "system" and $mode ne "default"); + die "setenv_reg: mode 'system' only available for admin" + if ($mode eq "system" and !$is_admin); + my $env; + if ($mode ne "system") { + my $env = get_user_env(); + $env->ArrayValues(1); + $env->{'/'.$env_var} = + [ $env_data, ($env_data =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; + } + if ($mode ne "user" and $is_admin) { + $env = get_system_env(); + $env->ArrayValues(1); + $env->{'/'.$env_var} = + [ $env_data, ($env_data =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; + } +} + +=pod + +=item C<unsetenv_reg($env_var[, $mode]);> + +Unset an environment variable $env_var + +=cut + +sub unsetenv_reg { + my $env_var = shift; + my $env = get_user_env(); + my $mode = @_ ? shift : "default"; + print "Unsetenv_reg: unset $env_var with mode $mode\n"; + die "unsetenv_reg: Invalid mode" + if ($mode ne "user" and $mode ne "system" and $mode ne "default"); + die "unsetenv_reg: mode 'system' only available for admin" + if ($mode eq "system" and !$is_admin); + delete get_user_env()->{'/'.$env_var} if $mode ne "system"; + delete get_system_env()->{'/'.$env_var} if ($mode ne "user" and $is_admin); } =pod -=item C<add_texbindir_to_path> +=item C<add_texbindir_to_path($texpath)> Remove wrong TeX directories from system path (if possible) and user path. A directory is a TeX directory if it contains tex.exe or @@ -385,8 +499,9 @@ sub add_texbindir_to_path { $found = 1; $newp = join (';', @newpt); $newp =~ s/\//\\/g; - $system_env->ArrayValues(1); # use value_data, value_type pairs - $system_env -> {"/Path"} = [ $newp, REG_EXPAND_SZ ]; + setenv_reg("Path", $newp, "system"); + #$system_env->ArrayValues(1); # use value_data, value_type pairs + #$system_env -> {"/Path"} = [ $newp, REG_EXPAND_SZ ]; } else { # non-admin # system path foreach $d (split (';', get_system_path())) { @@ -422,13 +537,24 @@ sub add_texbindir_to_path { $newp = join ';', @newpt; $newp =~ s/\//\\/g; $user_env->ArrayValues(1); # use value_data, value_type pairs - $user_env -> {"/Path"} = [ $newp, - ($newp =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; + #$user_env -> {"/Path"} = [ $newp, + # ($newp =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; + setenv_reg("Path", $newp, "user"); } else { - delete $user_env -> {'/Path'}; + unsetenv_reg("PAth", "user"); } } +=pod + +=item C<remove_texbindirs_from_path> + +Remove all directories from the searchpath which contain tex.exe or +pdftex.exe. Do this with the user path and if admin also with the +system path. + +=cut + sub remove_texbindirs_from_path { $wg_error = 0; # clear error status @@ -447,8 +573,7 @@ sub remove_texbindirs_from_path { } $newp = join (';', @newpt); $newp =~ s/\//\\/g; - $system_env->ArrayValues(1); # use value_data, value_type pairs - $system_env -> {"/Path"} = [ $newp, REG_EXPAND_SZ ]; + setenv_reg("Path", $newp, "system"); } # user path @@ -462,11 +587,9 @@ sub remove_texbindirs_from_path { if (@newpt) { $newp = join(';', @newpt); $newp =~ s/\//\\/g; - $user_env->ArrayValues(1); # use value_data, value_type pairs - $user_env -> {"/Path"} = [ $newp, - ($newp =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; + setenv_reg("Path", $newp, "user"); } else { - delete $user_env -> {"/Path"}; + unsetenv_reg("Path", "user"); } } @@ -494,7 +617,9 @@ sub reg_delete_recurse { =pod -=item C<register_script_type> +=pod + +=item C<register_script_type($extension, $command)> Add registry entries to associate $extension with $command and make $extension an executable file type. Slashes are flipped where necessary. @@ -510,7 +635,7 @@ sub register_script_type { tllog ($::LOG_DDEBUG, "Linking $extension to $command\n"); my $user_env = get_user_env(); my $system_env = get_system_env(); - my ($pathext, $found, $e, $classes_key); + my ($pathext, $found, $e, $classes_key, $k); # pathext if ($is_admin) { @@ -520,7 +645,7 @@ sub register_script_type { foreach $e (split(/;/,$pathext)) { $found = 1 if (uc($e) eq $extension); } - $system_env -> {'/PATHEXT'} = $pathext.";".$extension unless $found; + setenv_reg("PATHEXT", $pathext.";".$extension, "system") unless $found; # user pathext $pathext = $user_env -> {'/PATHEXT'}; if ($pathext) { @@ -528,7 +653,7 @@ sub register_script_type { foreach $e (split(/;/,$pathext)) { $found = 1 if (uc($e) eq $extension); } - $user_env -> {'/PATHEXT'} = $pathext.";".$extension unless $found; + setenv_reg("PATHEXT", $pathext.";".$extension, "user") unless $found; } } else { # non-admin $pathext = $user_env -> {'/PATHEXT'}; @@ -537,7 +662,7 @@ sub register_script_type { foreach $e (split(/;/,$pathext)) { $found = 1 if (uc($e) eq $extension); } - $user_env -> {"/PATHEXT"} = $pathext.";".$extension unless $found; + setenv_reg("PATHEXT", $pathext.";".$extension, "user") unless $found; } # file type @@ -545,10 +670,13 @@ sub register_script_type { if ($is_admin) { $classes_key = $Registry -> Open("LMachine/Software/Classes/", {Access => KEY_ALL_ACCESS()}) or die "Cannot open classpath"; - $classes_key->ArrayValues(0); - $classes_key->CreateKey($extension)->SetValue("","script".$extension); - $classes_key->CreateKey("script".$extension."/Shell/Open/Command/")-> - SetValue("", '"'.$command.'" "%1" %*'); + $k = $classes_key->CreateKey($extension); + $k -> ArrayValues(0); + $k -> {"/"} = "script".$extension; + $k = $classes_key->CreateKey("script".$extension."/Shell/Open/Command/"); + $k -> ArrayValues(1); + $k -> {"/"} = [ '"'.$command.'" "%1" %*', + ($command =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; # delete possibly conflicting values from HKCU/software $classes_key = $Registry -> Open("CUser/Software/Classes/", {Access => KEY_ALL_ACCESS()}); @@ -557,16 +685,19 @@ sub register_script_type { } else { $classes_key = $Registry -> Open("CUser/Software/Classes/", {Access => KEY_ALL_ACCESS()}); - $classes_key->ArrayValues(0); - $classes_key->CreateKey($extension)->SetValue("","script".$extension); - $classes_key->CreateKey("script".$extension."/Shell/Open/Command/")-> - SetValue("", '"'.$command.'" "%1" %*'); + $k = $classes_key->CreateKey($extension); + $k -> ArrayValues(0); + $k -> {"/"} = "script".$extension; + $k = $classes_key->CreateKey("script".$extension."/Shell/Open/Command/"); + $k -> ArrayValues(1); + $k -> {"/"} = [ '"'.$command.'" "%1" %*', + ($command =~ /%/) ? REG_EXPAND_SZ : REG_SZ ]; } } =pod -=item C<unregister_script_type> +=item C<unregister_script_type($extension)> Reversal of register_script_type. @@ -591,7 +722,7 @@ sub unregister_script_type { push @newpe, $e unless (uc($e) eq $extension); } $newpex = join(";",@newpe); - $system_env -> {"/PATHEXT"} = $newpex; + setenv_reg("PATHEXT", $newpex, "system"); $pathext = $user_env -> {'/PATHEXT'}; if ($pathext) { @@ -601,9 +732,9 @@ sub unregister_script_type { } $newpex = join(";",@newpe); if ($newpex eq ($system_env -> {"/PATHEXT"})) { - delete $user_env->{"/PATHEXT"}; + unsetenv_reg("PATHEXT", "user"); } else { - $user_env -> {"/PATHEXT"} = $newpex; + setenv_reg("PATHEXT", $newpex, "user"); } } } else { @@ -615,9 +746,9 @@ sub unregister_script_type { } $newpex = join(";",@newpe); if ($newpex eq ($system_env -> {"/PATHEXT"})) { - delete $user_env->{"/PATHEXT"}; + unsetenv_reg("PATHEXT", "user"); } else { - $user_env -> {"/PATHEXT"} = $newpex; + setenv_reg("PATHEXT", $newpex, "user"); } } @@ -647,6 +778,12 @@ sub unregister_script_type { =pod +=back + +=head2 ACTIVATING CHANGES IMMEDIATELY + +=over 6 + =item C<broadcast_env> Broadcasts system message that enviroment has changed. This only has diff --git a/Master/tlpkg/doc/wingoo-demo.pl b/Master/tlpkg/doc/wingoo-demo.pl index 84c0a455a77..1e29d201c82 100644 --- a/Master/tlpkg/doc/wingoo-demo.pl +++ b/Master/tlpkg/doc/wingoo-demo.pl @@ -5,8 +5,6 @@ # Under Unix/Linux, just test whether loading of win32 modules is skipped. -#!/usr/bin/env perl - use strict; BEGIN { @@ -26,36 +24,78 @@ BEGIN { } use TeXLive::TLUtils qw( get_system_tmpdir ); -use TeXLive::TLWinGooTry qw( - &win_version - &is_vista - &admin - &non_admin - &admin_again - &dir_writable - ®_country - &get_system_path - &get_user_path - &get_system_env - &get_user_env - &expand_string - &win_which_dir - &global_tmpdir - &add_texbindir_to_path - &remove_texbindirs_from_path - ®ister_script_type - &unregister_script_type - &broadcast_env - &update_assocs - &wg_error +use TeXLive::TLWinGoo qw( + win_version + is_vista + admin + non_admin + admin_again + dir_writable + reg_country + get_system_path + get_user_path + get_system_env + get_user_env + expand_string + win_which_dir + global_tmpdir + add_texbindir_to_path + remove_texbindirs_from_path + setenv_reg + unsetenv_reg + register_script_type + unregister_script_type + broadcast_env + update_assocs + wg_error ); # safe under Unix/Linux! my $ro_dir = "z:/aps"; -my $luaprog = "x:/utils0/lua.exe"; +my $luadir = "x:/utils0"; +my $luaprog; +my $pathsave = $ENV{'PATH'}; +my $pathextsave = $ENV{'PATHEXT'}; $::LOGLEVELTERMINAL=$::LOG_DDDEBUG; $::LOGLEVELFILE=$::LOG_ZERO; +#sub pathnew { +# my $p = expand_string(get_system_path()).';'. +# expand_string(get_user_path()); +# $p =~ s!/!\\!g; +# return $p; +#} +#sub getenvnew { +# # only use this for REG_SZ values! +# my $env_var = shift; +# return TeXLive::TLWinGoo::get_user_env()->{$env_var} or +# TeXLive::TLWinGoo::get_system_env()->{$env_var} or ""; +# #my $env_data = TeXLive::TLWinGoo::get_user_env()->{$env_var}; +# #if (not $env_data) { +# # $env_data = TeXLive::TLWinGoo::get_system_env()->{$env_var}; +# #} +# #if (not $env_data) { $env_data = ""; } +# #return $env_data; +#} + +sub pause { + my $mess = shift; + print( $mess."\nType any key..." ); + read STDIN,my $dummy, 1; +} + + +sub run_and_pause { + my $command = shift; + #my $setenv = "set PATH=".pathnew(). + # " & set TEXBINDIR=".getenvnew('TEXBINDIR'). + # " & set PATHEXT=".getenvnew('PATHEXT'); + #my $cmd_prompt = expand_string ($ENV{'COMSPEC'}); + #system ($cmd_prompt . ' /C "'.$setenv.' & '.$command.' & pause"'); + print "Type $command in a new command prompt\n"; + read STDIN,my $dummy, 1; +} + sub maybenot { my $bool = shift; return $bool ? " is " : " is not "; @@ -69,8 +109,8 @@ sub create_file { my $name = shift; return 1 if -e $name; return 0 unless open DUMMY, ">".$name; - print DUMMY 's = tostring(0.0000001)'; # lua: 1e-7; texlua: 0 - print DUMMY ('print("0.0000001 becomes " .. s)'); + print DUMMY 's = tostring(0.0000001)'."\n"; # lua: 1e-7; texlua: 0 + print DUMMY 'print("0.0000001 becomes " .. s)'."\n"; close DUMMY; return 1; } @@ -85,9 +125,15 @@ sub print_lua_out { my $luatestlua = $luatest . ".texlua"; unlink $luatestlua if -e $luatestlua; create_file( $luatestlua ); - my $cmd = 'set PATHEXT=%PATHEXT%;.TEXLUA & "'.$luatest.'"'; - $cmd =~ s/\//\\/g; - print "Lua[tex] result: ".`$cmd`."\n"; + #$ENV{'PATH'} = expand_string($pathsave) . ";" . $ENV{'TEMP'}; + #my $usersave = get_user_path(); + #$userpath = ($usersave ? "$usersave;" . + #run_and_pause ('testlua'); + $luatest =~ s!/!\\!g; + #run_and_pause ("set PATHEXT=%PATHEXT%;.TEXLUA & set TEXBINDIR=".$luatest); + run_and_pause ($luatest); + #print "Lua[tex] result: ".`testlua`."\n"; + #$ENV{'PATH'} = $pathsave; unlink $luatestlua; } @@ -102,13 +148,7 @@ sub print_assoc_cmd { $cmdout = `ftype $ftype`; if (!$cmdout) { print "Filetype unknown says ftype\n"; return; } $cmdout =~ s/.*=//; - print( $ext.' command is: '.$cmdout."\n" ); -} - -sub pause { - my $mess = shift; - print( $mess."\nType any key..." ); - read STDIN,my $dummy, 1; + print( $ext.' command is: '.$cmdout." says ftype\n" ); } ### end of subs ### @@ -148,34 +188,41 @@ if ($^O !~ /^MSWin(32|64)$/i) { # country -print "Country: " . reg_country() . "\n"; +print "\n***\nCountry: " . reg_country() . "\n"; # dir_writable my $wr_dir = $ENV{'USERPROFILE'}; $wr_dir =~ s/\\/\//g; mkdir $wr_dir unless -e $wr_dir; +print "\n***\nTesting for writability\n"; print $wr_dir . maybenot(dir_writable($wr_dir)) . "writable\n"; print $ro_dir . maybenot(dir_writable($ro_dir)) . "writable\n"; # expand_string -print( "\nExpansion\n" ); +print( "\n***\nExpansion\n" ); print expand_string("pre\\%systemROOT%\\post")."\n"; # win_which_dir -print( "\nFinding an executable\n" ); +print( "\n***\nFinding an executable\n" ); print "cmd.exe found in " . win_which_dir("cmd.exe") . "\n"; my $system_tmpdir=get_system_tmpdir(); -print( "\n\nHKCU and HKLM\n\n" ); +print( "\n***\nPath; admin and user\n\n" ); my ($wr_dir1, $wr_dir2); -while (1) { # running this first as admin (if possible) and then as non-admin - print ((admin() ? "Is" : "Not") . " an admin\n"); +foreach ("admin", "user") { + if ($_ eq "admin") { + next unless $real_admin; + admin_again(); + } else { + non_admin(); + } + print "\n***\n" . ((admin() ? "Is" : "Not") . " an admin\n"); # adding and removing texbindir @@ -200,69 +247,88 @@ while (1) { # running this first as admin (if possible) and then as non-admin remove_texbindirs_from_path(); print_search_paths(); + # broadcast environment changes + + broadcast_env(); + pause( maybenot(admin())." admin; check environment in new dosbox\n\n" ); +} +remove_texbindirs_from_path(); +rmdir $wr_dir1 if unlink $wr_dir1.'/tex.exe'; +rmdir $wr_dir2 if unlink $wr_dir2.'/tex.exe'; +print( "Dummy texs removed from path\n"); + +# the problem case: no admin, but TeX on system path + +print( "\nNon-admin path problem\n" ); +my $fn = expand_string("%windir%")."/TEX.EXE"; +$fn =~ s/\\/\//g; +non_admin(); +if (create_file($fn)) { # a tex.exe on the system path! + add_texbindir_to_path(expand_string($wr_dir2)); + my @wge = wg_error(); + if (@wge) { + print $wge[1]."\n"; + } + print( "Cannot remove tex from system searchpath\n" ); + print_search_paths(); + print "Wrong tex.exe found in " . win_which_dir("tex.exe") . "\n"; + unlink $fn; + remove_texbindirs_from_path(); + broadcast_env(); + pause( "Non-admin: check environment in new dosbox" ); +} else { + print "Cannot test; cannot create $fn\n"; +} + +# texlua filetype: plain lua for user, texlua for admin. +# differentiation: texlua rounds .0000001 to 0, lua doesn't +# The texlua command is REG_EXPAND_SZ, parameterized with %TEXBINDIR%. + +print( "\n***\nRegistering and unregistering filetypes\n\n" ); + +unregister_script_type(".texlua"); +unsetenv_reg('TEXBINDIR'); +update_assocs(); +broadcast_env(); +print_assoc_cmd( '.texlua' ); + +foreach ("admin", "user") { + if ($_ eq "admin") { + next unless $real_admin; + admin_again(); + } else { + non_admin(); + } + print "\n***\n" . ((admin() ? "Is" : "Not") . " an admin\n"); + # adding a filetype - print( "\nRegistering and unregistering filetypes\n" ); - my $testlua = admin() ? $::installerdir."/bin/win32/texlua.exe" : $luaprog; - update_assocs(); # just to be sure - print_assoc_cmd( '.texlua' ); - print_lua_out(); - register_script_type(".texlua", $testlua ); + my $luaprog = admin() ? "texlua.exe" : "lua.exe"; + my $texbindir = admin() ? $::installerdir."/bin/win32" : $luadir; + $texbindir =~ s!/!\\!g; + setenv_reg("TEXBINDIR", $texbindir); + register_script_type(".texlua", "%TEXBINDIR%\\".$luaprog ); + broadcast_env(); update_assocs(); + print "\n***\nAfter registering script type\n"; print_assoc_cmd( '.texlua' ); print_lua_out(); - print( "Now unregister\n" ); + print( "\***\nNow unregister\n" ); unregister_script_type(".texlua"); update_assocs(); print_assoc_cmd( '.texlua' ); print_lua_out(); print( "Now re-register (not shown)\n" ); - register_script_type(".texlua", $testlua ); + register_script_type(".texlua", "%TEXBINDIR%\\".$luaprog ); update_assocs(); # broadcast environment changes broadcast_env(); - pause( maybenot(admin())." admin; check environment in new dosbox\n\n" ); - - if (admin()) { - non_admin(); - next; - } - - # the problem case: no admin, but TeX on system path - - print( "\nNon-admin path problem\n" ); - my $fn = expand_string("%windir%")."/TEX.EXE"; - $fn =~ s/\\/\//g; - if (create_file($fn)) { # a tex.exe on the system path! - add_texbindir_to_path(expand_string($wr_dir2)); - my @wge = wg_error(); - if (@wge) { - print $wge[1]."\n"; - } - print( "Cannot remove tex from system searchpath\n" ); - print_search_paths(); - print "Wrong tex.exe found in " . win_which_dir("tex.exe") . "\n"; - unlink $fn; - remove_texbindirs_from_path(); - broadcast_env(); - pause( "Non-admin: check environment in new dosbox" ); - } else { - print "Cannot test; cannot create $fn\n"; - } - - # broadcast environment changes - - if (!admin()) { last; } } -rmdir $wr_dir1 if unlink $wr_dir1.'/tex.exe'; -rmdir $wr_dir2 if unlink $wr_dir2.'/tex.exe'; -print( "Dummy texs removed from path\n"); - -admin_again() if $real_admin; unregister_script_type(".texlua"); +unsetenv_reg('TEXBINDIR'); update_assocs(); broadcast_env(); print_assoc_cmd( '.texlua' ); |