summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLWinGoo.pm
diff options
context:
space:
mode:
authorSiep Kroonenberg <siepo@cybercomm.nl>2014-12-21 13:32:35 +0000
committerSiep Kroonenberg <siepo@cybercomm.nl>2014-12-21 13:32:35 +0000
commit8a2b59742549acec7e742c937f4647bec2724995 (patch)
tree53aecbaf8fa251be665f3df3cd3367e2d1aa7946 /Master/tlpkg/TeXLive/TLWinGoo.pm
parent2a1d49d7b372b8305e846a3ba719be7da49fd1f7 (diff)
Fixes to Windows uninstaller
git-svn-id: svn://tug.org/texlive/trunk@35876 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLWinGoo.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLWinGoo.pm104
1 files changed, 67 insertions, 37 deletions
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;