diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2014-12-21 13:32:35 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2014-12-21 13:32:35 +0000 |
commit | 8a2b59742549acec7e742c937f4647bec2724995 (patch) | |
tree | 53aecbaf8fa251be665f3df3cd3367e2d1aa7946 | |
parent | 2a1d49d7b372b8305e846a3ba719be7da49fd1f7 (diff) |
Fixes to Windows uninstaller
git-svn-id: svn://tug.org/texlive/trunk@35876 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/scripts/texlive/uninstall-win32.pl | 4 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLWinGoo.pm | 104 |
2 files changed, 69 insertions, 39 deletions
diff --git a/Master/texmf-dist/scripts/texlive/uninstall-win32.pl b/Master/texmf-dist/scripts/texlive/uninstall-win32.pl index 7cc60f5223b..523313a5737 100644 --- a/Master/texmf-dist/scripts/texlive/uninstall-win32.pl +++ b/Master/texmf-dist/scripts/texlive/uninstall-win32.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl # $Id$ -# Copyright 2008, 2010, 2011, 2012 Norbert Preining +# Copyright 2008, 2010, 2011, 2012, 2014 Norbert Preining # # GUI for tlmgr @@ -66,7 +66,7 @@ sub doit { } my $menupath = &TeXLive::TLWinGoo::menu_path(); $menupath =~ s!/!\\!g; - `rmdir /q "$menupath\\$TeXLive::TLConfig::WindowsMainMenuName" 2>nul`; + `rmdir /s /q "$menupath\\$TeXLive::TLConfig::WindowsMainMenuName" 2>nul`; # remove bindir from PATH settings TeXLive::TLUtils::w32_remove_from_path("$Master/bin/win32", diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm index acb12500d58..e5a48e867ed 100644 --- a/Master/tlpkg/TeXLive/TLWinGoo.pm +++ b/Master/tlpkg/TeXLive/TLWinGoo.pm @@ -195,8 +195,12 @@ sub is_vista { return $windows_version >= 6; } my $is_admin = 1; +sub KEY_FULL_ACCESS() { + return KEY_WRITE() | KEY_READ(); +} + sub sys_access_permissions { - $is_admin ? KEY_ALL_ACCESS() : KEY_READ() | KEY_ENUMERATE_SUB_KEYS(); + return $is_admin ? KEY_FULL_ACCESS() : KEY_READ(); } sub get_system_env { @@ -217,7 +221,7 @@ if ($is_win) { } sub get_user_env { - return $Registry -> Open("CUser/Environment", {Access => KEY_ALL_ACCESS()}); + return $Registry -> Open("CUser/Environment", {Access => KEY_FULL_ACCESS()}); } =pod @@ -229,6 +233,8 @@ to the system environment. =cut +# during processing of this source, $is_admin will get its correct value + sub admin { return $is_admin; } =pod @@ -603,7 +609,7 @@ sub reg_delete_recurse { ddebug("Deleting $parentpath$childname\n"); my $child; if ($childname !~ '^/') { # subkey - $child = $parent->Open ($childname, {Access => KEY_ALL_ACCESS()}); + $child = $parent->Open ($childname, {Access => KEY_FULL_ACCESS()}); reg_debug ("at open $childname for all access\n"); return 1 unless defined($child); foreach my $v (keys %$child) { @@ -629,7 +635,7 @@ sub reg_delete_recurse { sub cu_root { my $k = $Registry -> Open("CUser", { - Access => KEY_ALL_ACCESS(), Delimiter => '/' + Access => KEY_FULL_ACCESS(), Delimiter => '/' }); reg_debug ("at open HKCU for all access\n"); die "Cannot open HKCU for writing" unless $k; @@ -638,7 +644,7 @@ sub cu_root { sub lm_root { my $k = $Registry -> Open("LMachine", { - Access => ($is_admin ? KEY_ALL_ACCESS() : KEY_READ()), + Access => ($is_admin ? KEY_FULL_ACCESS() : KEY_READ()), Delimiter => '/' }); reg_debug ("at open HKLM\n"); @@ -1145,7 +1151,8 @@ sub add_menu_shortcut { $shpath = '/'.$shpath unless $shpath =~ m!^/!; $shpath = menu_path().$shpath; if ((-e $shpath) and not (-d $shpath)) { - next; # fail silently and don't worry about it + tlwarn("Failed to create shortcut for $name\n"); + next; # continue regardless } elsif (not (-d $shpath)) { mkdirhier($shpath); return unless -d $shpath; @@ -1200,8 +1207,9 @@ the job. =cut sub create_uninstaller { + # TEXDIR + &log("Creating uninstaller\n"); my $td_fw = shift; - # TEXDIR, TEXMFSYSVAR, TEXMFSYSCONFIG $td_fw =~ s![\\/]$!!; my $td = $td_fw; $td =~ s!/!\\!g; @@ -1209,19 +1217,14 @@ sub create_uninstaller { my $tdmain = `$td\\bin\\win32\\kpsewhich -var-value=TEXMFMAIN`; chomp $tdmain; - my $uninst_key = $Registry -> Open((admin() ? "LMachine" : "CUser") . - "/software/microsoft/windows/currentversion/", - {Access => KEY_ALL_ACCESS()}); - my $k = $uninst_key->CreateKey( - "uninstall/TeXLive$::TeXLive::TLConfig::ReleaseYear/"); - $k->{"/DisplayName"} = "TeX Live $::TeXLive::TLConfig::ReleaseYear"; - $k->{"/UninstallString"} = "\"$td\\tlpkg\\installer\\uninst.bat\""; - $k->{'/DisplayVersion'} = $::TeXLive::TLConfig::ReleaseYear; - $k->{'/URLInfoAbout'} = "http://www.tug.org/texlive"; - - mkdirhier("$td_fw/tlpkg/installer"); # wasn't this done yet? - if (open UNINST, ">$td_fw/tlpkg/installer/uninst.bat") { - print UNINST <<UNEND; + my $uninst_fw = "$td_fw/tlpkg/installer"; + my $uninst_dir = TeXLive::TLUtils::conv_to_w32_path($uninst_fw); + mkdirhier("$uninst_fw"); # wasn't this done yet? + if (! (open UNINST, ">", "$uninst_fw/uninst.bat")) { + tlwarn("Failed to create uninstaller\n"); + return 0; + } + print UNINST <<UNEND; \@echo off setlocal path $td\\tlpkg\\tlperl\\bin;$td\\bin\\win32;%path% @@ -1250,20 +1253,20 @@ if errorlevel 1 goto :eof rem test for taskkill and try to stop exit tray menu taskkill /? >nul 2>&1 if not errorlevel 1 1>nul 2>&1 taskkill /IM tl-tray-menu.exe /f -copy \"$td\\tlpkg\\installer\\uninst2.bat\" \"\%TEMP\%\" +copy \"$uninst_dir\\uninst2.bat\" \"\%TEMP\%\" rem pause \"\%TEMP\%\\uninst2.bat\" UNEND ; close UNINST; - } else { - warn "Cannot open $td_fw/tlpkg/installer/uninst.bat for append"; - } # We could simply delete everything under the root at one go, # but this might be catastrophic if TL doesn't have its own root. - if (open UNINST2, ">$td_fw/tlpkg/installer/uninst2.bat") { - print UNINST2 <<UNEND2; + if (! (open UNINST2, ">$uninst_fw/uninst2.bat")) { + tlwarn("Failed to complete creating uninstaller\n"); + return 0; + } + print UNINST2 <<UNEND2; rmdir /s /q \"$td\\bin\" rmdir /s /q \"$td\\readme-html.dir\" rmdir /s /q \"$td\\readme-txt.dir\" @@ -1282,13 +1285,13 @@ rem del /q \"$td\\texlive.profile\" del /q \"$td\\release-texlive.txt\" UNEND2 ; - for my $d ('TEXMFSYSVAR', 'TEXMFSYSCONFIG') { - my $kd = `$td\\bin\\win32\\kpsewhich -var-value=$d`; - chomp $kd; - print UNINST2 "rmdir /s /q \"", $kd, "\"\r\n"; - } - if ($td !~ /^.:$/) { - print UNINST2 <<UNEND3; + for my $d ('TEXMFSYSVAR', 'TEXMFSYSCONFIG') { + my $kd = `$td\\bin\\win32\\kpsewhich -var-value=$d`; + chomp $kd; + print UNINST2 "rmdir /s /q \"", $kd, "\"\r\n"; + } + if ($td !~ /^.:$/) { # not root of drive; remove directory if empty + print UNINST2 <<UNEND3; for \%\%f in (\"$td\\*\") do goto :done for /d \%\%f in (\"$td\\*\") do goto :done rd \"$td\" @@ -1298,10 +1301,37 @@ rd \"$td\" del \"%0\" UNEND3 ; + } + close UNINST2; + # user install: create uninstaller shortcut + # admin install: no shortcut because it would be visible to + # users who are not authorized to run it + if (!admin()) { + &log("Creating shortcut for uninstaller\n"); + TeXLive::TLWinGoo::add_menu_shortcut( + $TeXLive::TLConfig::WindowsMainMenuName, "Uninstall TeX Live", "", + "$uninst_dir\\uninst.bat", "", 0); + } + # register uninstaller + &log("Registering uninstaller\n"); + my $k; + my $uninst_key = $Registry -> Open((admin() ? "LMachine" : "CUser") . + "/software/microsoft/windows/currentversion/", + {Access => KEY_FULL_ACCESS()}); + if ($uninst_key) { + $k = $uninst_key->CreateKey( + "uninstall/TeXLive$::TeXLive::TLConfig::ReleaseYear/"); + if ($k) { + $k->{"/DisplayName"} = "TeX Live $::TeXLive::TLConfig::ReleaseYear"; + $k->{"/UninstallString"} = "\"$td\\tlpkg\\installer\\uninst.bat\""; + $k->{'/DisplayVersion'} = $::TeXLive::TLConfig::ReleaseYear; + $k->{'/URLInfoAbout'} = "http://www.tug.org/texlive"; } - close UNINST2; - } else { - warn "Cannot open $td_fw/tlpkg/installer/uninst2.bat for writing"; + } + if (!$k and admin()) { + tlwarn("Failed to register uninstaller\n". + "You can still run $td\\tlpkg\\installer\\uninst.bat manually.\n"); + return 0; } } @@ -1318,7 +1348,7 @@ sub unregister_uninstaller { my $regkey_uninst_path = ($w32_multi_user ? "LMachine" : "CUser") . "/software/microsoft/windows/currentversion/uninstall/"; my $regkey_uninst = $Registry->Open($regkey_uninst_path, - {Access => KEY_ALL_ACCESS()}); + {Access => KEY_FULL_ACCESS()}); reg_delete_recurse( $regkey_uninst, "TeXLive$::TeXLive::TLConfig::ReleaseYear/") if $regkey_uninst; |