From 02f6b96882b822406cb12a54d7a5ee6daff17630 Mon Sep 17 00:00:00 2001 From: Siep Kroonenberg Date: Fri, 4 Apr 2008 08:18:08 +0000 Subject: Win32: .texlua command now uses %TEXBINDIR%; [un]setenv_reg tl-portable.sh: bugfix TEXDIR; write test for $TEXDIR git-svn-id: svn://tug.org/texlive/trunk@7313 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLWinGoo.pm | 283 +++++++++++++++++++++++++++++---------- Master/tlpkg/doc/wingoo-demo.pl | 242 +++++++++++++++++++++------------ 2 files changed, 364 insertions(+), 161 deletions(-) (limited to 'Master/tlpkg') 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 -- 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 + +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 + +C 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 + +C 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 - -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 @@ -162,8 +213,8 @@ sub admin { return $is_admin; } =item C -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 +=item C 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 +=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 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 -# -#Returns its arguments joined with C<;> as separator, or returns the second -#argument if the first is an empty string. -# -#=cut +=pod + +=item C -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 + +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 +=item C 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 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 +=pod + +=item C 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 +=item C 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 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' ); -- cgit v1.2.3