diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2011-05-06 20:27:58 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2011-05-06 20:27:58 +0000 |
commit | 2392ed0b12abd476b55ca01e30ce3d5062b51740 (patch) | |
tree | 519e5ff1c397e44e76e91cfec3f6b7957dc9635d /Master | |
parent | 9924fed3b516a9a2a2f742a40bf65fe679f439b0 (diff) |
Postaction appreg
git-svn-id: svn://tug.org/texlive/trunk@22331 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 68 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLWinGoo.pm | 63 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/dviout.win32.tlpsrc | 2 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/texworks.tlpsrc | 4 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/tlpsv.win32.tlpsrc | 3 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/wintools.win32.tlpsrc | 4 |
6 files changed, 106 insertions, 38 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; diff --git a/Master/tlpkg/tlpsrc/dviout.win32.tlpsrc b/Master/tlpkg/tlpsrc/dviout.win32.tlpsrc index 18b63bf8a4b..9a8658c0bdf 100644 --- a/Master/tlpkg/tlpsrc/dviout.win32.tlpsrc +++ b/Master/tlpkg/tlpsrc/dviout.win32.tlpsrc @@ -4,3 +4,5 @@ binpattern f/win32 bin/win32/dviout postaction shortcut type=menu name="DVIOUT DVI viewer" cmd=TEXDIR/bin/win32/dviout.exe postaction filetype name=TL.DVIOUT.view cmd='"TEXDIR/bin/win32/dviout.exe" "%1"' postaction fileassoc extension=.dvi filetype=TL.DVIOUT.view +postaction appreg prog="dviout.exe" \ + cmd='"TEXDIR/bin/win32/dviout.exe" "%1"' exts='.dvi' diff --git a/Master/tlpkg/tlpsrc/texworks.tlpsrc b/Master/tlpkg/tlpsrc/texworks.tlpsrc index bdfec446400..5b1852df760 100644 --- a/Master/tlpkg/tlpsrc/texworks.tlpsrc +++ b/Master/tlpkg/tlpsrc/texworks.tlpsrc @@ -5,13 +5,13 @@ longdesc TeX Live includes executables only for Windows. postaction shortcut type=menu name="TeXworks editor" \ cmd=TEXDIR/bin/win32/texworks.exe -postaction shortcut type=desktop name="TeXworks editor" \ - cmd=TEXDIR/bin/win32/texworks.exe postaction filetype name=TL.TeXworks.edit \ cmd='"TEXDIR/bin/win32/texworks.exe" "%1"' postaction fileassoc extension=.tex filetype=TL.TeXworks.edit postaction fileassoc extension=.sty filetype=TL.TeXworks.edit postaction fileassoc extension=.cls filetype=TL.TeXworks.edit +postaction appreg prog="texworks.exe" \ + cmd='"TEXDIR/bin/win32/texworks.exe" "%1"' exts='.tex|.sty|.cls' binpattern f/win32 bin/${ARCH}/texworks binpattern f/win32 tlpkg/texworks/texworks.exe binpattern f/win32 tlpkg/texworks/python27.dll diff --git a/Master/tlpkg/tlpsrc/tlpsv.win32.tlpsrc b/Master/tlpkg/tlpsrc/tlpsv.win32.tlpsrc index a2b1953599b..05565357b25 100644 --- a/Master/tlpkg/tlpsrc/tlpsv.win32.tlpsrc +++ b/Master/tlpkg/tlpsrc/tlpsv.win32.tlpsrc @@ -8,8 +8,9 @@ longdesc TeX Live includes executables only for Windows. binpattern f/win32 bin/win32/psv runpattern d tlpkg/tlpsv postaction shortcut type=menu name="PS_View" cmd=TEXDIR/bin/win32/psv.exe -postaction shortcut type=desktop name="PS_View" cmd=TEXDIR/bin/win32/psv.exe postaction filetype name=TL.PSView.view cmd='"TEXDIR/bin/win32/psv.exe" "%1"' postaction fileassoc extension=.eps filetype=TL.PSView.view postaction fileassoc extension=.ps filetype=TL.PSView.view postaction fileassoc extension=.pdf filetype=TL.PSView.view +postaction appreg prog="psv.exe" cmd='"TEXDIR/bin/win32/psv.exe" "%1"' \ + exts='.eps|.epi|.epsi|.ps|.prn|.pdf' diff --git a/Master/tlpkg/tlpsrc/wintools.win32.tlpsrc b/Master/tlpkg/tlpsrc/wintools.win32.tlpsrc index 320a14bdd79..4ad63960e3f 100644 --- a/Master/tlpkg/tlpsrc/wintools.win32.tlpsrc +++ b/Master/tlpkg/tlpsrc/wintools.win32.tlpsrc @@ -33,5 +33,9 @@ binpattern f/win32 tlpkg/sam2p/sam2p.exe docpattern d texmf/doc/gzip # # bitmap2eps is from Siep. +# binpattern f/win32 bin/win32/bitmap2eps.exe runpattern f texmf/scripts/bitmap2eps/bitmap2eps.vbs +postaction appreg prog="bitmap2eps.exe" \ + cmd='"TEXDIR/bin/win32/bitmap2eps.exe" "%1"' \ + exts='.bmp|.png|.gif|.jpe|.jpg|.jpeg|.tif|.tiff' |