Bug 502550 - GS_EXECUTABLES=gs in ghostscript's wrapper scripts should be GS_EXECUTABLES=$gs ?
GS_EXECUTABLES=gs in ghostscript's wrapper scripts should be GS_EXECUTABLES=$...
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: ghostscript (Show other bugs)
12
All Linux
low Severity low
: ---
: ---
Assigned To: Tim Waugh
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: 628972 628973
  Show dependency treegraph
 
Reported: 2009-05-26 01:38 EDT by Tsutomu Hiroshima
Modified: 2010-10-14 19:01 EDT (History)
2 users (show)

See Also:
Fixed In Version: ghostscript-8.71-16.fc12
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 628972 (view as bug list)
Environment:
Last Closed: 2010-10-11 15:25:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tsutomu Hiroshima 2009-05-26 01:38:45 EDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; ja; rv:1.9.0.10) Gecko/2009042708 Fedora/3.0.10-1.fc10 Firefox/3.0.10

/usr/bin/ps2pdfwr reads:

#!/bin/sh
# ... a few lines omitted ...
GS_EXECUTABLE=gs
gs="`dirname $0`/$GS_EXECUTABLE"
if test ! -x "$gs"; then
        gs="$GS_EXECUTABLE"
fi
GS_EXECUTABLE=gs
# ... a little more lines omitted ...
exec "$GS_EXECUTABLE" # ... arguments are omitted ...

I think the second GS_EXECUTABLE=gs should be GS_EXECUTABLE=$gs.
If not, the codes above the line is meaningless,
whose purpose seems to pick up the executable "gs" in the same directory of the invoked /usr/bin/ps2pdfwr.

"exec"ed $GS_EXECUTABLE in the last line is evaluated to "gs".

Wrappers ps2epsi, ps2ps (and more ...) also handle GS_EXECUTABLE similarly.

Please compare this to the wrapper /usr/bin/ps2pdf.

#!/bin/sh
# ... a few lines omitted ...
version=14

ps2pdf="`dirname $0`/ps2pdf$version"
if test ! -x "$ps2pdf"; then
        ps2pdf="ps2pdf$version"
fi
exec "$ps2pdf" "$@"

"exec"ed $ps2pdf is usually evaluated to /usr/bin/ps2pdf14.

The actual problem arises, if other gs, say, for experiment, is installed into /usr/local/bin.
Fedora's /usr/bin/ps2pdfwr invokes experimental /usr/local/bin/gs in that case.


Reproducible: Always

Steps to Reproduce:
1. Just see the wrappers.
Comment 1 Tim Waugh 2009-06-10 13:00:23 EDT
Fixed in 8.63-8.fc10.
Comment 2 Tomas Hoger 2010-07-13 10:08:33 EDT
I believe the patch that got applied here is not quite correct and may actually be redundant now.  I don't know which ghostscript version this bug was reported against, I'll refer to ghostscript-8.63-6.fc10 that is the last f10 version in koji that does not have this patch.

That version does indeed contain this snipped in bunch of scripts:

  GS_EXECUTABLE=gs
  gs="`dirname $0`/$GS_EXECUTABLE"
  if test ! -x "$gs"; then
          gs="$GS_EXECUTABLE"
  fi
  GS_EXECUTABLE=gs

However, that's not what you can see in upstream source tarball:

  GS_EXECUTABLE=gs
  gs="`dirname $0`/$GS_EXECUTABLE"
  if test ! -x "$gs"; then
          gs="$GS_EXECUTABLE"
  fi
  GS_EXECUTABLE="$gs"

The original last line indeed contains GS_EXECUTABLE="$gs" and not GS_EXECUTABLE=gs as was suggested by reporter.

Checking build.log, I see:

/bin/sh -c 'for f in \
gsbj gsdj gsdj500 gslj gslp gsnd \
bdftops dumphint dvipdf eps2eps font2c \
pdf2dsc pdf2ps pdfopt pf2afm pfbtopfa printafm \
ps2ascii ps2epsi ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr ps2ps ps2ps2 \
wftopfa fixmswrd.pl lprsetup.sh pj-gs.sh pv.sh sysvlp.sh unix-lpr.sh ;\
	do if ( test -f ./lib/$f ); then \
	  (cat ./lib/$f | sed -e "s/GS_EXECUTABLE=[^ \t]*/GS_EXECUTABLE=gs/" > ./obj/$f); \
	  ./src/instcopy -c -m 755 ./obj/$f /builddir/build/BUILDROOT/ghostscript-8.63-6.fc10.i386/usr/bin/$f; \
	fi;\
	done'

This is where $gs was incorrectly replaced by gs.

Current ghostscript packages contain:

  GS_EXECUTABLE=gs
  gs="`dirname $0`/$GS_EXECUTABLE"
  if test ! -x "$gs"; then
          gs="$gs"
  fi

The whole test is pointless, $gs will have the same value regardless of the test result.  If you copy wrapper to directory that does not contain gs interpreter, it will not try to execute gs without path specified and fail.

Given that all wrapper scripts are installed to /usr/bin with gs, we probably don't care from RPM packaging pov, but we may wish to adjust patch to drop whole test completely, or drop the patch it it's not needed.  Recent build.logs contain:

/bin/sh -c 'for f in \
gsbj gsdj gsdj500 gslj gslp gsnd \
bdftops dumphint dvipdf eps2eps font2c \
pdf2dsc pdf2ps pdfopt pf2afm pfbtopfa printafm \
ps2ascii ps2epsi ps2pdf ps2pdf12 ps2pdf13 ps2pdf14 ps2pdfwr ps2ps ps2ps2 \
wftopfa fixmswrd.pl lprsetup.sh pj-gs.sh pv.sh sysvlp.sh unix-lpr.sh ;\
	do if ( test -f ./lib/$f ); then \
	  (cat ./lib/$f | sed -e "s/GS_EXECUTABLE=gs/GS_EXECUTABLE=gs/" > ./obj/$f); \
	  ./base/instcopy -c -m 755 ./obj/$f /builddir/build/BUILDROOT/ghostscript-8.71-6.fc12.i386/usr/bin/$f; \
	fi;\
	done'

"s/GS_EXECUTABLE=gs/GS_EXECUTABLE=gs/" does not seem to make sense, but it's probably needed to support alternative interpreter names.
Comment 3 Tomas Hoger 2010-07-13 10:12:08 EDT
Sigh, too much time wasted on longish comment while all is explained in upstream BZ/SVN:

http://bugs.ghostscript.com/show_bug.cgi?id=686863#c3
http://svn.ghostscript.com/viewvc?view=rev&revision=10349
Comment 4 Bug Zapper 2010-07-30 06:40:24 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 14 development cycle.
Changing version to '14'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 5 Tomas Hoger 2010-08-25 05:49:32 EDT
Has anyone got to review my comments above?
Comment 6 Tim Waugh 2010-08-25 06:17:16 EDT
Tomas, sorry hadn't got to it.  Just had a look, yes, that patch looks redundant now.  Thanks for analysis.
Comment 7 Fedora Update System 2010-08-26 11:31:31 EDT
ghostscript-8.71-11.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/ghostscript-8.71-11.fc12
Comment 8 Fedora Update System 2010-08-26 11:32:24 EDT
ghostscript-8.71-14.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/ghostscript-8.71-14.fc13
Comment 9 Fedora Update System 2010-08-26 11:33:13 EDT
ghostscript-8.71-14.fc14 has been submitted as an update for Fedora 14.
http://admin.fedoraproject.org/updates/ghostscript-8.71-14.fc14
Comment 10 Fedora Update System 2010-08-26 14:36:29 EDT
ghostscript-8.71-14.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update ghostscript'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/ghostscript-8.71-14.fc14
Comment 11 Fedora Update System 2010-09-13 12:51:55 EDT
ghostscript-8.71-16.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/ghostscript-8.71-16.fc14
Comment 12 Fedora Update System 2010-09-13 12:54:58 EDT
ghostscript-8.71-16.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/ghostscript-8.71-16.fc13
Comment 13 Fedora Update System 2010-09-13 12:56:33 EDT
ghostscript-8.71-16.fc12 has been submitted as an update for Fedora 12.
https://admin.fedoraproject.org/updates/ghostscript-8.71-16.fc12
Comment 14 Fedora Update System 2010-10-11 15:25:00 EDT
ghostscript-8.71-16.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 15 Fedora Update System 2010-10-11 23:12:52 EDT
ghostscript-8.71-16.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 16 Fedora Update System 2010-10-14 19:00:59 EDT
ghostscript-8.71-16.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.