diff options
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 68 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLWinGoo.pm | 63 |
2 files changed, 96 insertions, 35 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index e4ada1c3b65..4f0362f163a 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -1515,6 +1515,9 @@ sub do_postaction { } elsif ($pa =~ m/\s*fileassoc\s+(.*)\s*$/) { $ret &&= _do_postaction_fileassoc($how, $do_fileassocs, $tlpobj, $1); next; + } elsif ($pa =~ m/\s*appreg\s+(.*)\s*$/) { + next unless $do_fileassocs; + $ret &&= _do_postaction_application($how, $tlpobj, $1); } elsif ($pa =~ m/\s*script\s+(.*)\s*$/) { next unless $do_script; $ret &&= _do_postaction_script($how, $tlpobj, $1); @@ -1564,6 +1567,7 @@ sub _do_postaction_fileassoc { } return 1; } + sub _do_postaction_filetype { my ($how, $tlpobj, $pa) = @_; return 1 unless win32(); @@ -1607,6 +1611,70 @@ sub _do_postaction_filetype { return 1; } +sub _do_postaction_application { + my ($how, $tlpobj, $pa) = @_; + return 1 unless win32(); + my ($errors, %keyval) = + parse_into_keywords($pa, qw/prog cmd exts/); + + if ($errors) { + tlwarn("parsing the postaction line >>$pa<< did not succeed!\n"); + return 0; + } + + # prog + if (!defined($keyval{'prog'})) { + tlwarn("prog of appreg postaction not given\n"); + return 0; + } + my $prog = $keyval{'prog'}; + + if (!defined($keyval{'cmd'})) { + tlwarn("cmd of appreg postaction not given\n"); + return 0; + } + my $cmd = $keyval{'cmd'}; + + my $exts_arr = []; + my $e; + my $exts = ''; + if (!defined($keyval{'exts'})) { + tlwarn("exts of appreg postaction not given\n"); + } else { + $exts = $keyval{'exts'}; + foreach $e (split /\|/, $exts) { + if ($e =~ /^\./) { + push @$exts_arr, $e; + } else { + tlwarn("Invalid extension $e for $prog ignored\n"); + } + } + } + + my $texdir = `kpsewhich -var-value=SELFAUTOPARENT`; + chomp($texdir); + my $texdir_bsl = conv_to_w32_path($texdir); + $cmd =~ s!^("?)TEXDIR/!$1$texdir/!g; + + &log("postaction $how appreg for " . $tlpobj->name . + ": $prog, $cmd, $exts\n"); + if ($how eq "install") { + TeXLive::TLWinGoo::register_application($prog, $cmd, $exts_arr); + foreach $e (@$exts_arr) { + TeXLive::TLWinGoo::add_to_openwithlist($e, $prog); + } + } elsif ($how eq "remove") { + TeXLive::TLWinGoo::unregister_application($prog); + foreach $e (@$exts_arr) { + TeXLive::TLWinGoo::remove_from_openwithlist($e, $prog); + } + } else { + tlwarn("Unknown mode $how\n"); + return 0; + } + return 1; +} + sub _do_postaction_script { my ($how, $tlpobj, $pa) = @_; my ($errors, %keyval) = diff --git a/Master/tlpkg/TeXLive/TLWinGoo.pm b/Master/tlpkg/TeXLive/TLWinGoo.pm index 26fdaf42d56..8a4cc591f96 100644 --- a/Master/tlpkg/TeXLive/TLWinGoo.pm +++ b/Master/tlpkg/TeXLive/TLWinGoo.pm @@ -53,7 +53,7 @@ C<TeXLive::TLWinGoo> -- Additional utilities for Windows TeXLive::TLWinGoo::unregister_extension($mode, $extension); TeXLive::TLWinGoo::register_file_type($file_type, $command); TeXLive::TLWinGoo::unregister_file_type($file_type); - TeXLive::TLWinGoo::register_application($prog, $path, $exts); + TeXLive::TLWinGoo::register_application($prog, $cmd, $exts); TeXLive::TLWinGoo::unregister_application($prog); TeXLive::TLWinGoo::add_to_openwithlist($ext, $prog); TeXLive::TLWinGoo::remove_from_openwithlist($ext, $prog); @@ -559,9 +559,9 @@ sub adjust_reg_path_for_texlive { sub getans { my $prompt = shift; my $ans; - print STDERR "$prompt\n"; + print STDERR "$prompt "; $ans = <STDIN>; - if ($ans =~ /^y/i) {return 1;} + if ($ans =~ /^y/i) {print STDERR "\n"; return 1;} die "Aborting as requested"; } @@ -736,8 +736,8 @@ sub do_remove_regkey { } if (!$parentkey) { $do_remove = 0; - tlwarn "Unable to open $roothive/$parentpath for writing\n"; - return 0; + debug "$hivename/$parentpath not present or not writable so not removed\n"; + return 1; } if ($mode == 1) { $k = $parentkey->{$keyname}; @@ -759,7 +759,7 @@ sub do_remove_regkey { #getans("Deleting $parentpath$keyname regkey? "); reg_delete_recurse($parentkey, $keyname); if ($parentkey->{$keyname}) { - tlwarn "Failure to delete $roothive/$keypath\n"; + tlwarn "Failure to delete $hivename/$keypath\n"; return 0; } if ($is_admin and $cu_key->{$parentpath}) { @@ -862,7 +862,7 @@ sub unregister_file_type { =pod -=item C<register_application($prog, $path, $exts)> +=item C<register_application($prog, $cmd, $exts)> Add registry entry to set full path of $prog to $path and optionally specify which extensions it handles @@ -870,14 +870,14 @@ specify which extensions it handles =cut sub register_application { - my $prog = shift; # redundant, but more natural than just $path - my $path = shift; + my $prog = shift; + my $cmd = shift; my $exts = shift; my $hsh; foreach my $e (@$exts) {$hsh->{"/$e"} = "";} #my $prog = TeXLive::TLUtils::basename($path); - $cmd = "\"$path\" \"%1\""; + # $cmd = "\"$path\" \"%1\""; # done by caller $cmd =~ s!/!\\!g; my $keyhash = { "shell/" => { @@ -902,7 +902,7 @@ Reversal of register_application sub unregister_application { my $prog = shift; - do_remove_regkey(2, "Software/Classes/Applications/$prog/"); + do_remove_regkey(2, "Software/Classes/Applications/$prog"); } =pod @@ -1204,41 +1204,34 @@ UNEND warn "Cannot open $tdfw/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, ">$tdfw/tlpkg/installer/uninst2.bat") { print UNINST2 <<UNEND2; -rmdir /s /q \"$td\\texmf-dist\" -rmdir /s /q \"$td\\texmf-doc\" -rmdir /s /q \"$td\\texmf\" +rmdir /s /q \"$td\\bin\" rmdir /s /q \"$td\\readme-html.dir\" rmdir /s /q \"$td\\readme-txt.dir\" -rmdir /s /q \"$td\\bin\" +rem rmdir /s /q \"$td\\temp\" +rmdir /s /q \"$td\\texmf\" +rmdir /s /q \"$td\\texmf-dist\" rmdir /s /q \"$td\\tlpkg\" +rmdir /s /q \"$tdsc\" +rmdir /s /q \"$tdsv\" del /q \"$td\\README.*\" del /q \"$td\\LICENSE.*\" -del /q \"$td\\doc.html\" -del \"$td\\index.html\" -del \"$td\\texmf.cnf\" -del \"$td\\install-tl\" -del \"$td\\tl-portable\" -del \"$td\\tl-portable.bat\" -del \"$td\\install-tl.bat\" -del \"$td\\install-tl-advanced.bat\" -UNEND2 -; - print UNINST2 <<UNEND2; -rmdir /s /q \"$tdsv\" -rmdir /s /q \"$tdsc\" -rmdir /s /q \"$td\\temp\" -rmdir /s /q \"$td\\tlpkg\" -del \"$td\\install-tl.log\" -del \"$td\\texlive.profile\" 2>nul -del \"$td\\release-texlive.txt\" +rem del /q \"$td\\doc.html\" +del /q \"$td\\index.html\" +del /q \"$td\\texmf.cnf\" +del /q \"$td\\install-tl*.*\" +del /q \"$td\\tl-portable.*\" +rem del /q \"$td\\texlive.profile\" +del /q \"$td\\release-texlive.txt\" set test= for \%\%f in (\"$td\\*.*\") do \@set test=nonempty if x\%test\%==x rd \"$td\" \@echo Done uninstalling TeXLive. -rem \@pause -del %0 +\@pause +del \"%0\" UNEND2 ; close UNINST2; |