diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2008-02-25 15:53:19 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2008-02-25 15:53:19 +0000 |
commit | 783675c0cb64a4e6e625b7a4e37c320eaf17fb8d (patch) | |
tree | 201360ff7d83762855e41647eb386ec4632f9a16 /Master/tlpkg/doc | |
parent | 506efaea286d392d8c49a0c4cff49f06a791171b (diff) |
TLWinGoo: better support for an uninstaller.
Added function update_assocs to notify the system of changed file
associations.
Updates to wingoo-demo
git-svn-id: svn://tug.org/texlive/trunk@6752 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/doc')
-rwxr-xr-x | Master/tlpkg/doc/wingoo-demo.bat | 21 | ||||
-rw-r--r-- | Master/tlpkg/doc/wingoo-demo.pl | 259 |
2 files changed, 211 insertions, 69 deletions
diff --git a/Master/tlpkg/doc/wingoo-demo.bat b/Master/tlpkg/doc/wingoo-demo.bat index a3589ba8d20..b3129d46771 100755 --- a/Master/tlpkg/doc/wingoo-demo.bat +++ b/Master/tlpkg/doc/wingoo-demo.bat @@ -1,31 +1,20 @@ @echo off
-rem TeX Live Root; ends with backslash
+rem Directory of this script; ends with backslash
rem This should also work with UNC names
-set tlroot=%~dp0
+set tldoc=%~dp0
set tldrive=%~d0
%tldrive%
-cd %tlroot%
+cd %tldoc%
-rem we need wget in the path, so add tlpkg\bin to the path
-set pathsave=%path%
-path %path%;%tlroot%tlpkg\bin
-
-rem use provided Perl
-
-set PERL5SAVE=%PERL5LIB%
-
-set PERL5LIB=%tlroot%tlpkg\lib\Perl5_lib-TL_inst
-"%tlroot%tlpkg\bin\perl" "%tlroot%wingoo-demo.pl"
+"%tldoc%..\tlperl\bin\perl" "%tldoc%wingoo-demo.pl"
pause Done
rem cleanup in case of start from command-line
-set PERL5LIB=%PERL5SAVE%
-set PERL5SAVE=
path %pathsave%
set pathsave=
set tldrive=
-set tlroot=
+set tldoc=
diff --git a/Master/tlpkg/doc/wingoo-demo.pl b/Master/tlpkg/doc/wingoo-demo.pl index 8e7359e0041..bcf4759d25d 100644 --- a/Master/tlpkg/doc/wingoo-demo.pl +++ b/Master/tlpkg/doc/wingoo-demo.pl @@ -1,8 +1,9 @@ #!/usr/bin/env perl -# For testing, edit $ro_dir and $wr_dir as needed. +# For testing, edit $ro_dir and $luaprog as needed; +# $ro_dir should be a read-only directory and +# $luaprog should be a working lua executable but not texlua. -# $ro_dir should be read-only. -# $wr_dir should be writable. +# Under Unix/Linux, just test whether loading of win32 modules is skipped. #!/usr/bin/env perl @@ -14,29 +15,59 @@ BEGIN { $me=~s!\\!/!g if $^O=~/^MSWin(32|64)$/i; if ($me=~m!/!) { - ($::installerdir=$me)=~s!(.*)/.*$!$1!; + # wingoo-demo now in a subsubdirectory: + ($::installerdir=$me)=~s!(.*)\/tlpkg\/doc\/.*$!$1!; } else { # This shouldn't occur if called from batchfile - $::installerdir='.'; + $::installerdir='./../..'; } + @INC = ("$::installerdir/tlpkg/installer/perllib") if ($^O=~/^MSWin(32|64)$/i); unshift (@INC, "$::installerdir/tlpkg"); - # unshift (@INC, "$::installerdir/bin/win32") if $^O=~/^MSWin(32|64)$/i; } -use TeXLive::TLWinGoo; # safe under Unix/Linux! +use TeXLive::TLUtils qw( get_system_tmpdir ); +use TeXLive::TLWinGooTry qw( + &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_texbindir_from_path + ®ister_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"; + +$::LOGLEVELTERMINAL=$::LOG_DDDEBUG; +$::LOGLEVELFILE=$::LOG_ZERO; sub maybenot { my $bool = shift; return $bool ? " is " : " is not "; } +# two uses: +# - is the parent directory writable? +# - is the script interpreted by lua or by texlua? + sub create_file { my $name = shift; return if -e $name; open DUMMY, ">".$name; - print DUMMY "Hello"; + print DUMMY "print(tostring(0.0000001))"; # lua: 1e-7; texlua: 0 close DUMMY; } @@ -45,28 +76,98 @@ sub print_search_paths { print "User path: ".get_user_path()."\n"; } -print ((join "\n", @INC)."\n"); +sub print_lua_out { + my $luatest = expand_string( $ENV{'TEMP'} ) . "/testlua"; + create_file( $luatest . ".texlua" ); + my $cmd = 'set PATHEXT=%PATHEXT%;.TEXLUA & "'.$luatest.'"'; + $cmd =~ s/\//\\/g; + print "Lua[tex] result: ".`$cmd`."\n"; + unlink $luatest.".texlua"; +} + +sub print_assoc_cmd { + my $ext = shift; + my $cmdout = `assoc $ext`; + chomp $cmdout if $cmdout; + if (!$cmdout) { print "Extension unknown\n"; return; } + my $ftype = $cmdout; + $ftype =~ s/.*=//; + if (!$ftype) { print "Extension unknown\n"; return; } + $cmdout = `ftype $ftype`; + if (!$cmdout) { print "Filetype unknown\n"; return; } + $cmdout =~ s/.*=//; + print( $ext.' command is: '.$cmdout."\n" ); +} + +sub print_config { + # system- and user settings for path, pathext + # and [HKCU|HKLM]\software\classes settings for e.g .rb + my $key; + my $val; + + print_search_paths(); + + foreach $key (get_system_env(), get_user_env()) { + print ("Path: ".($key ->{'/path'})."\n"); + print ("Expanded path: ".expand_string($key ->{'/path'})."\n"); + print ("Pathext: ".($key->{'pathext'})."\n"); + } + + print_lua_out(); + + foreach $key ("LMachine/software/classes", "CUser/software/classes", + "Classes") { + print "Key: " . $key . "\n"; + + # system: lua; user: texlua + $val = $Win32::TieRegistry::Registry -> {$key."/.texlua//"}; + print "Texlua filetype: ".$val."\n"; + print "TeXlua open command: " . + $Win32::TieRegistry::Registry -> {$key."/".$val."/Shell/Open/Command/"} . + "\n"; + } +} + +sub pause { + my $mess = shift; + print( $mess."\nType any key..." ); + read STDIN,my $dummy, 1; +} + +### end of subs ### + +my $real_admin = admin(); +my $userpath_orig; +my $systempath_orig; +my $userpathext_orig; +my $systempathext_orig; +print( "\nGENERAL; ALSO UNIX\n" ); + +print ( "\nINC\n" . (join "\n", @INC) . "\n\n"); + # admin if (admin()) { - print "Admin or not on Windows\n"; + print "Admin or not_on_Windows\n"; } else { print "Not admin\n"; } -# country - -print "Country: " . reg_country() . "\n"; - # global_tmpdir -print "Global tempdir: " . global_tmpdir()."\n"; +print "\nGlobal tempdir: " . global_tmpdir()."\n"; if ($^O !~ /^MSWin(32|64)$/i) { print "Not Windows; bailing out...\n"; exit; } +### end of non-windows + +# country + +print "Country: " . reg_country() . "\n"; + # dir_writable my $wr_dir = $ENV{'USERPROFILE'}; @@ -77,50 +178,102 @@ print $ro_dir . maybenot(dir_writable($ro_dir)) . "writable\n"; # expand_string +print( "\nExpansion\n" ); print expand_string("pre\\%systemROOT%\\post")."\n"; # win_which_dir -print "cmd.exe found in " . TeXLive::TLWinGoo::win_which_dir("cmd.exe") . "\n"; - -# adding and removing texbindir - -my $wr_dir1 = $wr_dir . "/tex1"; -mkdir $wr_dir1 unless -e $wr_dir1; -create_file( $wr_dir1."/tex.exe" ); -add_texbindir_to_path($wr_dir1); -print_search_paths(); -print "tex.exe found in " . - TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; - -my $wr_dir2 = $wr_dir . "/tex2"; -mkdir $wr_dir2 unless -e $wr_dir2; -create_file( $wr_dir2."/tex.exe" ); -add_texbindir_to_path($wr_dir2); -print_search_paths(); -print "tex.exe found in " . - TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; - -# the problem case: no admin, but TeX on system path - -my $admin_save = $TeXLive::TLWinGoo::is_admin; -$TeXLive::TLWinGoo::is_admin = 0; -my $fn = expand_string("%windir%")."/TEX.EXE"; -$fn =~ s/\\/\//g; -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_search_paths(); -print "tex.exe found in " . TeXLive::TLWinGoo::win_which_dir("tex.exe") . "\n"; -unlink $fn; +print( "\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" ); + +while (1) { # running this first as admin (if possible) and then as non-admin + + print ((admin() ? "Is" : "Not") . " an admin\n"); + + # adding and removing texbindir + + print( "\ntexbindir on searchpath\n" ); + my $wr_dir1 = $wr_dir . "/tex1"; + mkdir $wr_dir1 unless -e $wr_dir1; + create_file( $wr_dir1."/tex.exe" ); + add_texbindir_to_path($wr_dir1); + print( "Take 1\n" ); + print_search_paths(); + print "tex.exe found in " . win_which_dir("tex.exe") . "\n"; + + my $wr_dir2 = $wr_dir . "/tex2"; + mkdir $wr_dir2 unless -e $wr_dir2; + create_file( $wr_dir2."/tex.exe" ); + add_texbindir_to_path($wr_dir2); + print( "Take 2\n" ); + print_search_paths(); + print "tex.exe found in " . win_which_dir("tex.exe") . "\n"; + + remove_texbindir_from_path( $wr_dir2 ); + print( "Mopping up...\n" ); + print_search_paths(); + + # adding a filetype + + print( "\nRegistering and unregistering filetypes\n" ); + my $testlua = admin() ? $luaprog : $::installerdir."/bin/win32/texlua.exe"; + update_assocs(); # just to be sure + print_assoc_cmd( '.texlua' ); + print_lua_out(); + register_script_type(".texlua", $testlua ); + update_assocs(); + print_assoc_cmd( '.texlua' ); + print_lua_out(); + print( "Now 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 ); + update_assocs(); + + # broadcast environment changes + + broadcast_env(); + pause( "Check environment in new dosbox\n\n" ); + + if (admin()) { + non_admin(); + next; + } -# adding a filetype + # the problem case: no admin, but TeX on system path -register_script_type(".rb","x:/ruby/bin/ruby.exe"); + print( "\nNon-admin path problem\n" ); + my $fn = expand_string("%windir%")."/TEX.EXE"; + $fn =~ s/\\/\//g; + 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 "tex.exe found in " . win_which_dir("tex.exe") . "\n"; + unlink $fn; + remove_texbindir_from_path( $wr_dir2 ); + + # broadcast environment changes -# broadcast environment changes + broadcast_env(); + pause( "Check environment in new dosbox" ); + if (!admin()) { last; } +} +admin_again(); +unregister_script_type(".texlua"); +update_assocs(); broadcast_env(); +print_assoc_cmd( '.texlua' ); + |