summaryrefslogtreecommitdiff
path: root/Master/tlpkg
diff options
context:
space:
mode:
authorPiotr Strzelczyk <piotr@eps.gda.pl>2009-06-30 19:11:40 +0000
committerPiotr Strzelczyk <piotr@eps.gda.pl>2009-06-30 19:11:40 +0000
commit8240da014fb3e032314d313048b6c9d34a8df665 (patch)
tree720cd57554f26f04a9aede13d0d5dae6d356112b /Master/tlpkg
parent8a8b0da40cbac456c5142aa02d85f4fe3f761de7 (diff)
changed win32 path adjustment; set up perl for uninstaller
git-svn-id: svn://tug.org/texlive/trunk@14029 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r--Master/tlpkg/TeXLive/TLWinGoo.pm182
1 files changed, 63 insertions, 119 deletions
diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm
index 0a7b3f548cd..580df89c8e9 100644
--- a/Master/tlpkg/TeXLive/TLWinGoo.pm
+++ b/Master/tlpkg/TeXLive/TLWinGoo.pm
@@ -39,8 +39,7 @@ C<TeXLive::TLWinGoo> -- Additional utilities for Windows
TeXLive::TLWinGoo::win_which_dir($prog);
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::adjust_reg_path_for_texlive($action, $texbindir, $mode);
TeXLive::TLWinGoo::register_extension($extension, $file_type);
TeXLive::TLWinGoo::unregister_extension($extension);
TeXLive::TLWinGoo::register_file_type($file_type, $command);
@@ -90,8 +89,7 @@ BEGIN {
&get_user_path
&setenv_reg
&unsetenv_reg
- &add_texbindir_to_path
- &remove_texbindirs_from_path
+ &adjust_reg_path_for_texlive
&register_extension
&unregister_extension
&register_file_type
@@ -114,6 +112,7 @@ BEGIN {
&win_which_dir
&global_tmpdir
&is_a_texdir
+ &tex_dirs_on_path
);
if ($^O=~/^MSWin(32|64)$/i) {
require Win32::API;
@@ -234,7 +233,7 @@ sub reg_country {
my $value = $Registry -> {"CUser/Control Panel/International//Locale"};
return 0 unless $value;
# there might be trailing nulls on Vista
- chop($value) while ($value =~ /\0$/);
+ $value =~ s/\x00*$//;
$value = substr $value, -4;
return 0 unless $value;
my $lmkey = $Registry -> Open("HKEY_CLASSES_ROOT/MIME/Database/Rfc1766/",
@@ -319,9 +318,10 @@ sub is_a_texdir {
$sr =~ s/\\/\//g;
$sr = $sr . '/' unless $sr =~ m!/$!;
return 0 if index($d, $sr)==0;
- return (((-e $d.'mktexlsr.exe') or (-e $d.'dvips.exe')) and
- ((-e $d.'tex.exe') or (-e $d.'pdftex.exe') or (-e $d.'xetex.exe')
- or (-e $d.'luatex.exe')));
+ foreach $p qw(luatex.exe mktexlsr.exe pdftex.exe tex.exe xetex.exe) {
+ return 1 if (-e $d.$p);
+ }
+ return 0;
}
=pod
@@ -442,133 +442,76 @@ sub unsetenv_reg {
=pod
-=item C<add_texbindir_to_path($texpath)>
+=item C<tex_dirs_on_path($path)>
-Remove wrong TeX directories from system path (if possible) and user
-path. A directory is a TeX directory if it contains tex.exe or
-pdftex.exe and if it is not under %systemroot%. Then if necessary
-add desired TeX directory; to system path if admin, otherwise to
-user path.
+Returns tex directories found on the search path.
+A directory is a TeX directory if it contains tex.exe or
+pdftex.exe.
=cut
-sub add_texbindir_to_path {
- my $texbindir = shift;
-
- my $system_env = get_system_env();
- my $user_env = get_user_env();
- my $d;
- my $d_exp;
- my $found = 0;
- my @newpt;
- my $newp;
-
- # system path
- if ($is_admin) {
- @newpt = ();
- foreach $d (split (';', get_system_path())) {
- $d_exp = expand_string($d);
- $d_exp =~ s/\\/\//g;
- $d_exp =~ s/\/$//;
- if (uc($d_exp) eq uc($texbindir)) {
- push @newpt, $d unless $found;
- $found = 1;
- } elsif (!is_a_texdir($d_exp)) {
- push @newpt, $d;
- }
- }
- push @newpt, $texbindir unless $found;
- $found = 1;
- $newp = join (';', @newpt);
- $newp =~ s/\//\\/g;
- 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())) {
- $d_exp = expand_string($d);
- $d_exp =~ s/\\/\//g;
- $d_exp =~ s/\/$//;
- if (uc($d_exp) eq uc($texbindir)) {
- $found = 1;
- } elsif (is_a_texdir($d_exp)) {
- debug("Warning: possibly conflicting [pdf]TeX program found at $d_exp\n");
- }
- }
- }
-
- # user path
- @newpt = ();
- foreach $d (split (';', get_user_path())) {
+sub tex_dirs_on_path {
+ my ($path) = @_;
+ my ($d, $d_exp);
+ my @texdirs = ();
+ foreach $d (split (';', $path)) {
$d_exp = expand_string($d);
- $d_exp =~ s/\\/\//g;
- $d_exp =~ s/\/$//;
- if (uc($d_exp) eq uc($texbindir)) {
- push @newpt, $d unless $found; # admin case: always $found
- $found = 1;
- } elsif (!is_a_texdir($d_exp)) {
- push @newpt, $d;
- }
- }
- push @newpt, $texbindir unless $found;
- 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 {
- unsetenv_reg("PAth", "user");
+ if (is_a_texdir($d_exp)) {
+ # tlwarn("Possibly conflicting [pdf]TeX program found at $d_exp\n");
+ push(@texdirs, $d_exp);
+ };
}
+ return @texdirs;
}
=pod
-=item C<remove_texbindirs_from_path>
+=item C<adjust_reg_path_for_texlive($action, $tlbindir, $mode)>
-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.
+Edit system or user PATH variable in the registry.
+Adds or removes (depending on $action) $tlbindir directory
+to system or user PATH variable in the registry (depending on $mode).
=cut
-sub remove_texbindirs_from_path {
-
- my $system_env = get_system_env();
- my $user_env = get_user_env();
- my ($d, $d_exp, @newpt, $newp);
-
- # system path
- if ($is_admin) {
- @newpt = ();
- foreach $d (split (';', get_system_path())) {
- $d_exp = expand_string($d);
- $d_exp =~ s/\\/\//g;
- $d_exp =~ s/\/$//;
- push @newpt, $d unless is_a_texdir($d_exp);
+sub adjust_reg_path_for_texlive {
+ my ($action, $tlbindir, $mode) = @_;
+ die("Unknown path action: $action\n")
+ if ($action ne 'add') and ($action ne 'remove');
+ die("Unknown path mode: $mode\n")
+ if ($mode ne 'system') and ($mode ne 'user');
+ debug("Warning: [pdf]tex program not found in $tlbindir\n")
+ if (!is_a_texdir($tlbindir));
+ my $path = ($mode eq 'system') ? get_system_path() : get_user_path();
+ $tlbindir =~ s!/!\\!g;
+ my $tlbindir_short = uc(short_name($tlbindir));
+ my ($d, $d_short, @newpath);
+ my $tex_dir_conflict = 0;
+ foreach $d (split (';', $path)) {
+ $d_short = uc(short_name(expand_string($d)));
+ if ($d_short ne $tlbindir_short) {
+ push(@newpath, $d);
+ $tex_dir_conflict += is_a_texdir($d);
}
- $newp = join (';', @newpt);
- $newp =~ s/\//\\/g;
- setenv_reg("Path", $newp, "system");
}
-
- # user path
- @newpt = ();
- foreach $d (split (';', get_user_path())) {
- $d_exp = expand_string($d);
- $d_exp =~ s/\\/\//g;
- $d_exp =~ s/\/$//;
- push @newpt, $d unless is_a_texdir($d_exp);
+ if ($action eq 'add') {
+ if ($tex_dir_conflict) {
+ debug("Warning: conflicting [pdf]tex found on the $mode path in $d; appending texlive bin dir to the front.");
+ unshift(@newpath, $tlbindir);
+ } else {
+ push(@newpath, $tlbindir);
+ }
}
- if (@newpt) {
- $newp = join(';', @newpt);
- $newp =~ s/\//\\/g;
- setenv_reg("Path", $newp, "user");
+ if (@newpath) {
+ setenv_reg("Path", join(';', @newpath), $mode);
} else {
- unsetenv_reg("Path", "user");
+ unsetenv_reg("Path", $mode);
+ }
+ if (($action eq 'add') and ($mode eq 'user') and tex_dirs_on_path(get_system_path())) {
+ debug("Warning: conflicting [pdf]tex found on the system path in $d; not fixable in user mode.");
+ return 1;
}
+ return 0;
}
# delete a registry key recursively.
@@ -992,9 +935,9 @@ sub create_uninstaller {
print UNINST <<UNEND;
\@echo off
rem This should not be necessary, but sometimes it is:
-path $td\\bin\\win32;%path%
-set PERL5LIB=
-\"$td\\tlpkg\\tlperl\\bin\\perl.exe\" \"$td\\texmf\\scripts\\texlive\\uninstall-win32.pl\"
+path $td\\tlpkg\\tlperl\\bin;$td\\bin\\win32;%path%
+set PERL5LIB=$td\\tlpkg\\tlperl\\lib
+perl.exe \"$td\\texmf\\scripts\\texlive\\uninstall-win32.pl\"
if errorlevel 1 exit
copy \"$tdw\\tlpkg\\installer\\uninst2.bat\" \"\%TEMP\%\"
rem pause
@@ -1009,6 +952,7 @@ UNEND
if (open UNINST2, ">$tdwfw/tlpkg/installer/uninst2.bat") {
print UNINST2 <<UNEND2 if ($td eq $tdw);
rmdir /s /q \"$td\\texmf-dist\"
+rmdir /s /q \"$td\\texmf-doc\"
rmdir /s /q \"$td\\texmf\"
rmdir /s /q \"$td\\readme-html.dir\"
rmdir /s /q \"$td\\readme-txt.dir\"