Bug 248167

Summary: www/node 14.4.0 does not build in poudriere with FreeBSD 11.4
Product: Ports & Packages Reporter: Miroslav Lachman <000.fbsd>
Component: Individual Port(s)Assignee: Bradley T. Hughes <bhughes>
Status: Closed FIXED    
Severity: Affects Only Me CC: james, johan
Priority: --- Flags: bhughes: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
poudriere build log failure
none
Patch against 14.6.0 (Main) & 14.4.0 (Quarterly)
none
Poudriere Build Log 14.6.0 & Python 3.7
none
Patch against 14.6.0 (Main branch) & 14.4.0 (Quarterly)
none
Poudriere Build Log 14.4.0, Python 3.6
none
Poudriere Build Log 14.6.0, Python 3.7 none

Description Miroslav Lachman 2020-07-22 08:13:09 UTC
I tried to build www/node from quaterly branch but it ends up with the following python error:

LD_LIBRARY_PATH=/wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/lib.host:/wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/obj/gen; tools/genv8constants.py "/wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/obj/gen/v8constants.h" "/wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a"
Traceback (most recent call last):
  File "tools/genv8constants.py", line 23, in <module>
    bufsize=-1, stdout=subprocess.PIPE, text=True).stdout
TypeError: __init__() got an unexpected keyword argument 'text'
gmake[2]: *** [node_dtrace_ustack.target.mk:13: /wrkdirs/usr/ports/www/node/work/node-v14.4.0/out/Release/obj/gen/v8constants.h] Error 1
rm ed36ab92458644e121416e8697a6b64c051c72b0.intermediate ad3fd4c76aef3b4797bbb2572833f9000cee0294.intermediate ea2d89ddb30e54c8a8d75f33fc84b228111d7c67.intermediate
gmake[1]: *** [Makefile:101: node] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/www/node/work/node-v14.4.0'
*** Error code 1
Comment 1 Miroslav Lachman 2020-07-22 08:14:38 UTC
Created attachment 216652 [details]
poudriere build log failure
Comment 2 Miroslav Lachman 2020-07-22 20:35:51 UTC
Probably caused by setting default version of Python to 2.7 which causes shebeng line /usr/local/bin/python27 in tools/genv8constants.py but the code in it is not compatible with Python 2.7.
This should be markerd as "BROKEN with Python 2.7" or something like this.
Building with Python 3.7 right now...
Comment 3 Johan Ström 2020-08-20 11:01:55 UTC
I have a similar problem, but with DEFAULT_VERSIONS=python=3.6.

The change introduced in https://svnweb.freebsd.org/ports?view=revision&revision=535334 only specifies python, but the patch introduces the 'text' argument to subprocess.Popen, which is only available from python 3.7:

"Changed in version 3.7: Added the text parameter, as a more understandable alias of universal_newlines. Added the capture_output parameter."

As 'text' is an alias to 'universal_newlines', a simple (tested & working) change is to just use that instead, to make it compatible with 3.6 as well.
Comment 4 James French 2020-08-20 14:39:21 UTC
Created attachment 217379 [details]
Patch against 14.6.0 (Main) & 14.4.0 (Quarterly)

Can you please test the attached patch.

The issue is caused by a patch shipped with the port, I've moved it to EXTRA_PATCHES if the python version is 3.7 or higher.

This is against 14.6.0, but it should also apply cleanly against 14.4.0. If it works, It will need to be applied against both the quarterly & main ports trees as both are affected by this issue.

Build logs to follow.
Comment 5 James French 2020-08-20 15:02:41 UTC
Created attachment 217380 [details]
Poudriere Build Log 14.6.0 & Python 3.7
Comment 6 James French 2020-08-20 15:36:40 UTC
Created attachment 217385 [details]
Patch against 14.6.0 (Main branch) & 14.4.0 (Quarterly)

My previous patch just re-uncovered the build issue with Python 3 that the included patch was trying to fix in the first place.

Johan hit the nail on the head in Comment 3, the attached patch addresses things all the way back to Python 2.7. I was a bit reluctant to apply the patch if it wasn't needed, but apparently it is for all but Python 2.

Poudriere build log for Python 3.7 @ 14.6.0 to follow, but I have had successful runs against Python 2.7, Python 3.6 and the various combinations thereof with 14.4.0
Comment 7 James French 2020-08-20 15:51:46 UTC
Created attachment 217388 [details]
Poudriere Build Log 14.4.0, Python 3.6
Comment 8 James French 2020-08-20 15:53:19 UTC
Created attachment 217389 [details]
Poudriere Build Log 14.6.0, Python 3.7
Comment 9 commit-hook freebsd_committer freebsd_triage 2020-08-20 21:28:09 UTC
A commit references this bug:

Author: bhughes
Date: Thu Aug 20 21:27:51 UTC 2020
New revision: 545565
URL: https://svnweb.freebsd.org/changeset/ports/545565

Log:
  www/node: build with python < 3.7

  r535334 introduced a patch for tools/genv8constants.py that only worked
  with Python >= 3.7. The "text" argument added to Python's
  subprocess.Popen() is an alias for "universal_newlines", which works on
  all versions of Python, including 2.7.

  PR:		248167
  Submitted by:	James French <james@french.id.au>
  Reported by:	Miroslav Lachman <000.fbsd@quip.cz>
  MFH:		2020Q3
  Sponsored by:	Miles AS

Changes:
  head/www/node/files/patch-tools_genv8constants.py
Comment 10 commit-hook freebsd_committer freebsd_triage 2020-08-20 21:37:12 UTC
A commit references this bug:

Author: bhughes
Date: Thu Aug 20 21:37:05 UTC 2020
New revision: 545566
URL: https://svnweb.freebsd.org/changeset/ports/545566

Log:
  MFH: r545565

  www/node: build with python < 3.7

  r535334 introduced a patch for tools/genv8constants.py that only worked
  with Python >= 3.7. The "text" argument added to Python's
  subprocess.Popen() is an alias for "universal_newlines", which works on
  all versions of Python, including 2.7.

  PR:		248167
  Submitted by:	James French <james@french.id.au>
  Reported by:	Miroslav Lachman <000.fbsd@quip.cz>
  Sponsored by:	Miles AS

  Approved by:	ports-secteam (joneum)

Changes:
_U  branches/2020Q3/
  branches/2020Q3/www/node/files/patch-tools_genv8constants.py
Comment 11 Bradley T. Hughes freebsd_committer freebsd_triage 2020-08-20 21:38:31 UTC
Committed to head and quarterly, thanks for the patch! :)