texlive[67561] Build/extra/epstopdf: (check_prog_exists): new fn;
commits+karl at tug.org
commits+karl at tug.org
Thu Jul 6 19:08:27 CEST 2023
Revision: 67561
http://tug.org/svn/texlive?view=revision&revision=67561
Author: karl
Date: 2023-07-06 19:08:26 +0200 (Thu, 06 Jul 2023)
Log Message:
-----------
(check_prog_exists): new fn; call it to test that $kpsewhich and $GS exist
Modified Paths:
--------------
trunk/Build/extra/epstopdf/Makefile
trunk/Build/extra/epstopdf/epstopdf.pl
Modified: trunk/Build/extra/epstopdf/Makefile
===================================================================
--- trunk/Build/extra/epstopdf/Makefile 2023-07-05 23:43:07 UTC (rev 67560)
+++ trunk/Build/extra/epstopdf/Makefile 2023-07-06 17:08:26 UTC (rev 67561)
@@ -31,6 +31,7 @@
check-restricted-safe-in check-restricted-safe-out \
check-simple \
check-tn5002 \
+ check-which \
check-write-error \
check-help:
@@ -88,9 +89,6 @@
$(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 @@
$(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.
Modified: trunk/Build/extra/epstopdf/epstopdf.pl
===================================================================
--- trunk/Build/extra/epstopdf/epstopdf.pl 2023-07-05 23:43:07 UTC (rev 67560)
+++ trunk/Build/extra/epstopdf/epstopdf.pl 2023-07-06 17:08:26 UTC (rev 67561)
@@ -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 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 @@
}
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 @@
$GS = $::opt_gscmd;
}
}
+debug "GS command: $GS";
+check_prog_exists ($GS);
### option (no)safer
my $gs_opt_safer = "-dSAFER";
More information about the tex-live-commits
mailing list.