diff options
author | Karl Berry <karl@freefriends.org> | 2023-07-06 17:08:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-07-06 17:08:26 +0000 |
commit | 6f3c809fb1e80ef07621dce44818ed7163da8dca (patch) | |
tree | 641c7ec0560048000faf76684b464cd956d93739 /Build/extra | |
parent | 7b1a7638ba9742cd490b7becf50be4ec8c06563c (diff) |
(check_prog_exists): new fn; call it to test that $kpsewhich and $GS exist
git-svn-id: svn://tug.org/texlive/trunk@67561 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/extra')
-rw-r--r-- | Build/extra/epstopdf/Makefile | 11 | ||||
-rwxr-xr-x | Build/extra/epstopdf/epstopdf.pl | 41 |
2 files changed, 48 insertions, 4 deletions
diff --git a/Build/extra/epstopdf/Makefile b/Build/extra/epstopdf/Makefile index 421cca79f77..1d965fac5f5 100644 --- a/Build/extra/epstopdf/Makefile +++ b/Build/extra/epstopdf/Makefile @@ -31,6 +31,7 @@ check: check-help check-version check-help-r check-usage \ check-restricted-safe-in check-restricted-safe-out \ check-simple \ check-tn5002 \ + check-which \ check-write-error \ check-help: @@ -88,9 +89,6 @@ check-gray: $(e2p) --gray test-tiger.eps pdfinfo test-tiger.pdf | grep "Page size:" -check-write-error: - ! $(e2p) test-simple.eps --outfile=/dev/full - check-gscmd: ! $(e2p) --gscmd=false test-simple.eps ! $(e2p) --gscmd='foo bar' test-simple.eps @@ -157,6 +155,13 @@ check-tn5002: $(MAKE) file=test-tn5002-crlf check1 $(MAKE) file=test-tn5002-lf check1 +# can't override kpsewhich, so just test gs cmd lookup. +check-which: + ! $(e2p) --gscmd=/nonesuch test-simple.eps + +check-write-error: + ! $(e2p) test-simple.eps --outfile=/dev/full + # complicated, from http://www.vectorfloral.com/floral-swirly-flowers-with-butterflies-vector-graphic-174.html # another, even bigger, is at http://www.backgroundvector.com/abstract-colorful-background-vector-image-94.html # both are CC-BY 3.0. diff --git a/Build/extra/epstopdf/epstopdf.pl b/Build/extra/epstopdf/epstopdf.pl index 542931998fa..6ab36788d16 100755 --- a/Build/extra/epstopdf/epstopdf.pl +++ b/Build/extra/epstopdf/epstopdf.pl @@ -35,7 +35,10 @@ # # emacs-page # -my $ver = "2.31"; +my $ver = "2.32"; +# 2023/07/qqq 2.32 (Karl Berry) +# * check that kpsewhich and gs are in PATH. +# * correct TL path for kpsewhich to bin/windows. # 2023/03/06 v2.31 (Karl Berry) # * disallow --nosafer in restricted mode. # * disallow output to pipes in restricted mode. @@ -493,6 +496,7 @@ sub errorUsage { die "$program: Error: @_ (try --help for more information)\n"; sub warnerr { $restricted ? error(@_) : warning(@_); } ### debug messages +debug "on_windows=$on_windows, on_windows_or_cygwin=$on_windows_or_cygwin"; debug "Restricted mode activated" if $restricted; ### safer external commands for Windows in restricted mode @@ -508,6 +512,39 @@ if ($restricted && $on_windows) { } debug "kpsewhich command: $kpsewhich"; +### check that PROG is in PATH and executable, abort if not. +# it'd be better to actually try running the program, but then we'd have +# to either replicate Perl's logic for finding the command interpreter +# (trivial on Unix, complicated on Windows), or do a fork/exec and close +# the file descriptors ourselves, which seems too painful. Instead we'll +# just look along PATH for the program, which is good enough in +# practice for us, since the only goal here is to give a better error +# message if the program isn't available. +sub check_prog_exists { + my ($prog) = @_; + debug " Checking if $prog is in PATH"; + if ($prog =~ m,^(/|\./|\.\./),) { + return 1 if -x $prog; # absolute or explicitly relative + error "Required program $prog not found, given explicit directory"; + } + for my $dir (split ($on_windows_or_cygwin ? ";" : ":", $ENV{"PATH"})) { + $dir = "." if $dir eq ""; # empty path element + debug " Checking dir $dir"; + if (-x "$dir/$prog") { + return 1; + } elsif ($on_windows_or_cygwin) { + for my $ext ("exe", "com", "bat") { + if (-x "$dir/$prog.$ext") { + return 1; + } + } + } + } + # if made it through the whole loop, not found, so quit. + error "Required program $prog not found in PATH ($ENV{PATH})"; +} +check_prog_exists ($kpsewhich); + ### check if a name is "safe" according to kpse's open(in|out)_any # return true if name is ok, false otherwise sub safe_name { @@ -574,6 +611,8 @@ if ($::opt_gscmd) { $GS = $::opt_gscmd; } } +debug "GS command: $GS"; +check_prog_exists ($GS); ### option (no)safer my $gs_opt_safer = "-dSAFER"; |