Bug 218924

Summary: print/tex-xetex: build fails due to shebang issue
Product: Ports & Packages Reporter: Kenji Rikitake <kenji>
Component: Individual Port(s)Assignee: Hiroki Sato <hrs>
Status: New ---    
Severity: Affects Many People CC: hrs, jcfyecrayz, miwi, ohartmann, rhurlin, salvadore
Priority: --- Flags: bugzilla: maintainer-feedback? (hrs)
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 239517    
Description Flags
[patch] a shebang fix in case of bug 218979
[patch] [v2] alternate shebang fix
updated Hein's patch
salvadore: maintainer-approval? (hrs)
[patch] fix shebangs [v4] (tex-xetex and telive-docs) jcfyecrayz: maintainer-approval? (hrs)

Description Kenji Rikitake 2017-04-28 04:03:24 UTC
On Ports svn r439591 with FreeBSD amd64 11.0-STABLE r317532:

The following shebangfix errors cannot be fixed simply by adding the USES option, since the files are extracted after the patch phase just before staging.

====> Running Q/A tests (stage-qa)
Error: '/usr/bin/env python' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/doc/xelatex/xepersian/undk-0.6.py'
Error: '/usr/bin/env python' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/doc/xelatex/xepersian/unldk-0.2.py'
Error: '/usr/bin/env python' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/doc/xelatex/xepersian/dkun-0.3.py'
Error: '/usr/bin/env python' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/doc/xelatex/xepersian/dkun-0.4.py'
Error: '/usr/bin/perl' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/source/xelatex/arabxetex/makemaps.pl'
Error: '/usr/bin/perl' is an invalid shebang you need USES=shebangfix for 'share/texmf-dist/scripts/xetex/perl/xdv2pdf_mergemarks'
Error: /usr/local/bin/xetex is linked to /usr/local/lib/libfontconfig.so.1 from x11-fonts/fontconfig but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libfontconfig.so:x11-fonts/fontconfig
Error: /usr/local/bin/xetex is linked to /usr/local/lib/gcc5/libgcc_s.so.1 from lang/gcc but it is not declared as a dependency
*** Error code 1
Comment 1 John Hein 2017-04-30 21:52:51 UTC
This can't be fixed with the current 'fix-shebang' infrastructure since that occurs at patch-time.  The problematic files mentioned in this bug are installed from a distribution tarball at stage-time.

See bug 218979 for a solution.
Comment 2 John Hein 2017-04-30 22:05:27 UTC
Created attachment 182198 [details]
[patch] a shebang fix in case of bug 218979

In case the fix described in bug 218979 is committed, attached is a fix for this port.
Comment 3 Kenji Rikitake 2017-04-30 23:12:05 UTC
(In reply to John Hein from comment #2)
I'll definitely test the new SHEBANG_FILES_INSTALL functionality as soon as it is committed.
Comment 4 John Hein 2017-08-28 20:01:49 UTC
(In reply to Kenji Rikitake from comment #3)
After discussing the changes for bug 218979, it was determined that since only a few ports have this problem (need shebang fix at install time instead of patch time), those few ports could be fixed individually rather than adding to the shebangfix.mk framework.  See https://reviews.freebsd.org/D10554.
Comment 5 John Hein 2017-08-28 20:10:08 UTC
Created attachment 185847 [details]
[patch] [v2] alternate shebang fix

(In reply to John Hein from comment #4)
Here's an alternate fix for the shebang issues.

It adds shebangfix to USES in order to get some variable definitions from shebangfix.mk.  It copies some code from shebangfix.mk

It also adds python to USES in order to get PYTHON_CMD defined (but defines PYTHON_NO_DEPENDS to avoid depending on python - the .py files that get installed are not critical for this port).

Another option is to allow an exception in Mk/Scripts/qa.sh to allow some shebang patterns to exist.  I decided against that in favor of consistency of freebsd ports files.  Personally I like '#!/usr/bin/env python' better for its flexibility, but the ports project decided against that.
Comment 6 Lorenzo Salvadore freebsd_committer 2018-11-08 12:51:27 UTC
Created attachment 199080 [details]
updated Hein's patch

I tested the port with poudriere and the bug is still present in 11.2-RELEASE (amd64). John Hein's patch still works, but is now old because the port has evolved while waiting for this fix.

* Updates Hein's patch so that the diff file now refers to the up to date port.
* Adds gnome USES flags, because use of USE_GNOME without USES= gnome is now deprecated.
* Adds LIB_DEPENDS= libfontconfig.so:x11-fonts/fontconfig, because poudriere found that this dependency was missing.
* Regenerates patchs in files/ directory because portlint complained that there were some files (patch-configure) that did not follow the standard format.
* Changes a pair of spaces into tabs to make portlint happier.

Portlint is still not happy because of a few warnings (missing license, which seems hard to define, and a short pkg-descr). I tested the patch on poudriere with 11.2-RELEASE amd64 and everything seems fine (in case a test is needed for i386, I can do that, but it will take some time and I have other priorities: if someone else manages to do it it would be better).

John: remember to set a maintainer-approval flag to the patchs you would like to see commited: if you forget it, it will be harder for committer to find your work. This is probably the reason why this bug report is still open.
Comment 7 Lorenzo Salvadore freebsd_committer 2018-11-09 13:45:57 UTC
I managed to do the test with poudriere on 11.2-RELEASE i386: everything is fine.
Comment 8 John Hein 2018-12-31 21:31:13 UTC
Lorenzo, maintainer-approval flag is generally useful, I agree.  In this case, I'm not sure hrs@ has been very active, so it may not make a difference.

In any case, your patch to add the post-install target in tex-xetex/Makefile looks good to me.  The review to put "install" time shebang fixing in shebangfix.mk (https://reviews.freebsd.org/D10554) was determined to be not applicable to enough ports.

I have had your post-install patch locally here for a while now.  Also in print/texlive-docs (I'll attach that patch here, too).

One thing: why did you get rid of USES=compiler:c++11-lib?

Maintainer timeout it seems.
Comment 9 Lorenzo Salvadore freebsd_committer 2018-12-31 21:58:11 UTC
I worked on the patch some weeks ago and it is hard for me to remember the reason for removing USES=compiler:c++11-lib, but most probably it was simply that it was not needed and it risked to bring in unnecessary dependencies.
Comment 10 John Hein 2018-12-31 22:01:40 UTC
Comment on attachment 182198 [details]
[patch] a shebang fix in case of bug 218979

obsolete this patch (changes in bug 218979 not applied)
Comment 11 John Hein 2018-12-31 22:02:34 UTC
Comment on attachment 185847 [details]
[patch] [v2] alternate shebang fix

Obsolete this patch - later patches are a bit more up to date.
Comment 12 John Hein 2018-12-31 22:10:24 UTC
Created attachment 200665 [details]
[patch] fix shebangs [v4] (tex-xetex and telive-docs)

Update print/tex-xetex patch to fix shebangs for installed perl/python scripts:

 - post-install target to fix shebangs of listed files
 - include portlint suggested fix (tabs), USES & LIB_DEPENDS updates (see comment 6)

Also include similar shebang fixes for installed scripts by print/texlive-docs (and a portlint whine fix to keep the USES section by itself)
Comment 13 O. Hartmann 2019-07-29 19:43:57 UTC
I have a similar problem with print/texlive-docs on ports revision 507582, running CURRENT (FreeBSD 13.0-CURRENT #206 r350393: Sun Jul 28 22:20:34 CEST 2019 amd64), see Bug 239517 .