nodejs: upgraded package to upstream

Upgraded net-libs/nodejs to version 12.16.1 on amd64, arm

BUG=b:154521931
TEST=update_chroot

Change-Id: Ib6a8724d9f4a906788588c71bca7b2413e3fef51
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2195805
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Yilin Yang (kerker) <kerker@chromium.org>
Commit-Queue: Yilin Yang (kerker) <kerker@chromium.org>
diff --git a/metadata/md5-cache/net-libs/nodejs-12.16.1 b/metadata/md5-cache/net-libs/nodejs-12.16.1
new file mode 100644
index 0000000..87ce612
--- /dev/null
+++ b/metadata/md5-cache/net-libs/nodejs-12.16.1
@@ -0,0 +1,16 @@
+BDEPEND=|| ( dev-lang/python:3.7[threads(+)] dev-lang/python:3.6[threads(+)] ) systemtap? ( dev-util/systemtap ) test? ( net-misc/curl )
+DEFINED_PHASES=compile configure install postinst prepare pretend setup test
+DEPEND=>=dev-libs/libuv-1.34.0:= >=net-dns/c-ares-1.15.0 >=net-libs/http-parser-2.9.3:= >=net-libs/nghttp2-1.40.0 sys-libs/zlib icu? ( >=dev-libs/icu-64.2:= ) system-ssl? ( >=dev-libs/openssl-1.1.1:0= )
+DESCRIPTION=A JavaScript runtime built on Chrome's V8 JavaScript engine
+EAPI=7
+HOMEPAGE=https://nodejs.org/
+IUSE=cpu_flags_x86_sse2 debug doc icu inspector +npm +snapshot +ssl +system-ssl systemtap test
+KEYWORDS=*
+LICENSE=Apache-1.1 Apache-2.0 BSD BSD-2 MIT
+RDEPEND=>=dev-libs/libuv-1.34.0:= >=net-dns/c-ares-1.15.0 >=net-libs/http-parser-2.9.3:= >=net-libs/nghttp2-1.40.0 sys-libs/zlib icu? ( >=dev-libs/icu-64.2:= ) system-ssl? ( >=dev-libs/openssl-1.1.1:0= )
+REQUIRED_USE=inspector? ( icu ssl ) npm? ( ssl ) system-ssl? ( ssl )
+RESTRICT=test
+SLOT=0
+SRC_URI=https://nodejs.org/dist/v12.16.1/node-v12.16.1.tar.xz
+_eclasses_=bash-completion-r1	47a7402d95930413ce25ba8d857339bb	eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	multilib	b2f01ad412baf81650c23fcf0975fa33	pax-utils	3551398d6ede2b572568832730cc2a45	python-any-r1	4900ae970f827a22d33d41bd8b8f9ace	python-utils-r1	931c328767d245c08a16a3f87be9ce9c	toolchain-funcs	209edad4a5c4812e7b2f8021650974f0	xdg-utils	ff2ff954e6b17929574eee4efc5152ba
+_md5_=1cc86e3b6207a5a9118e59990ab713b1
diff --git a/metadata/md5-cache/net-libs/nodejs-8.12.0 b/metadata/md5-cache/net-libs/nodejs-8.12.0
deleted file mode 100644
index b68c7de..0000000
--- a/metadata/md5-cache/net-libs/nodejs-8.12.0
+++ /dev/null
@@ -1,15 +0,0 @@
-DEFINED_PHASES=compile configure install postinst prepare pretend setup test
-DEPEND=>=dev-libs/libuv-1.19.2:= >=net-libs/http-parser-2.8.0:= >=net-libs/nghttp2-1.32.0 sys-libs/zlib icu? ( >=dev-libs/icu-60.1:= ) ssl? ( >=dev-libs/openssl-1.0.2n:0=[-bindist] ) python_targets_python2_7? ( >=dev-lang/python-2.7.5-r2:2.7[threads] ) >=dev-lang/python-exec-2:=[python_targets_python2_7(-)?,-python_single_target_pypy3(-),-python_single_target_python3_6(-),-python_single_target_python3_7(-),-python_single_target_python3_8(-),python_single_target_python2_7(+)] systemtap? ( dev-util/systemtap ) test? ( net-misc/curl )
-DESCRIPTION=A JavaScript runtime built on Chrome's V8 JavaScript engine
-EAPI=6
-HOMEPAGE=https://nodejs.org/
-IUSE=cpu_flags_x86_sse2 debug doc icu inspector +npm +snapshot +ssl systemtap test python_targets_python2_7
-KEYWORDS=*
-LICENSE=Apache-1.1 Apache-2.0 BSD BSD-2 MIT
-RDEPEND=>=dev-libs/libuv-1.19.2:= >=net-libs/http-parser-2.8.0:= >=net-libs/nghttp2-1.32.0 sys-libs/zlib icu? ( >=dev-libs/icu-60.1:= ) ssl? ( >=dev-libs/openssl-1.0.2n:0=[-bindist] )
-REQUIRED_USE=python_targets_python2_7 inspector? ( icu ssl ) npm? ( ssl )
-RESTRICT=test
-SLOT=0
-SRC_URI=https://nodejs.org/dist/v8.12.0/node-v8.12.0.tar.xz
-_eclasses_=bash-completion-r1	47a7402d95930413ce25ba8d857339bb	eutils	06133990e861be0fe60c2b428fd025d9	flag-o-matic	5d5921a298e95441da2f85be419894c0	multilib	b2f01ad412baf81650c23fcf0975fa33	pax-utils	3551398d6ede2b572568832730cc2a45	python-single-r1	3a0fc81f484bfdbd9c2b7448015a36e4	python-utils-r1	931c328767d245c08a16a3f87be9ce9c	toolchain-funcs	209edad4a5c4812e7b2f8021650974f0
-_md5_=e78ea19fc42b6b18659162936f6543b7
diff --git a/net-libs/nodejs/Manifest b/net-libs/nodejs/Manifest
index 56c5b5d..bb58a5d 100644
--- a/net-libs/nodejs/Manifest
+++ b/net-libs/nodejs/Manifest
@@ -1 +1 @@
-DIST node-v8.12.0.tar.xz 18310452 BLAKE2B 79634fc57cd76a97e72bab4be37da91d5eff4d13cdaa2b48e83f013885fa3590ba4a28378baf036ed26b7304bf234753d1d4014f72571496f5bb6cd5b221e5f0 SHA512 665d2dba287d78bcd723d7b4d00a6897fb996f4aa69a541e010a3dfeb2614257892117fcce7123966b1ecaddc9269a6667e0e262df693baea1f476c96de55c42
+DIST node-v12.16.1.tar.xz 23481768 BLAKE2B 29371b952c14907778c064269108f1da5e3818c32773e73090c61edcd07190c418189db6a505987ca71f99bb868880e297de5d2181b9a880774eaaf515985f26 SHA512 fe1e9fabb6fe52e3bc4275b33e6c5e4a761550b04964c0ae7dbef7172f5d415207bb2985751d068e357ce45a0ba414b07c0abd1531ef839b9463e98eeae8f9a4
diff --git a/net-libs/nodejs/files/nodejs-99999999-llhttp.patch b/net-libs/nodejs/files/nodejs-99999999-llhttp.patch
new file mode 100644
index 0000000..1b6eb9f
--- /dev/null
+++ b/net-libs/nodejs/files/nodejs-99999999-llhttp.patch
@@ -0,0 +1,20 @@
+--- a/node.gypi
++++ b/node.gypi
+@@ -169,11 +169,15 @@
+ 
+     [ 'node_shared_http_parser=="false"', {
+       'dependencies': [
+-        'deps/http_parser/http_parser.gyp:http_parser',
+-        'deps/llhttp/llhttp.gyp:llhttp'
++        'deps/http_parser/http_parser.gyp:http_parser'
+       ],
+     } ],
+ 
++    [ '"true"', { 'dependencies': [
++        'deps/llhttp/llhttp.gyp:llhttp'
++      ],
++    }],
++
+     [ 'node_shared_cares=="false"', {
+       'dependencies': [ 'deps/cares/cares.gyp:cares' ],
+     }],
diff --git a/net-libs/nodejs/metadata.xml b/net-libs/nodejs/metadata.xml
index aaaba18..3e9bb1d 100644
--- a/net-libs/nodejs/metadata.xml
+++ b/net-libs/nodejs/metadata.xml
@@ -7,7 +7,9 @@
 	<use>
 		<flag name="inspector">Enable V8 inspector</flag>
 		<flag name="npm">Enable NPM package manager</flag>
+		<flag name="pax_kernel">Enable building under a PaX enabled kernel</flag>
 		<flag name="snapshot">Enable snapshot creation for faster startup</flag>
+		<flag name="system-ssl">Use system OpenSSL instead of the bundled one</flag>
 		<flag name="systemtap">Enable SystemTAP/DTrace tracing</flag>
 	</use>
 </pkgmetadata>
diff --git a/net-libs/nodejs/nodejs-8.12.0.ebuild b/net-libs/nodejs/nodejs-12.16.1.ebuild
similarity index 72%
rename from net-libs/nodejs/nodejs-8.12.0.ebuild
rename to net-libs/nodejs/nodejs-12.16.1.ebuild
index 27db9f7..a0968b5 100644
--- a/net-libs/nodejs/nodejs-8.12.0.ebuild
+++ b/net-libs/nodejs/nodejs-12.16.1.ebuild
@@ -1,46 +1,50 @@
-# Copyright 1999-2018 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI=6
-RESTRICT="test"
-
-PYTHON_COMPAT=( python2_7 )
-PYTHON_REQ_USE="threads"
-
-inherit bash-completion-r1 eutils flag-o-matic pax-utils python-single-r1 toolchain-funcs
+EAPI=7
+PYTHON_COMPAT=( python3_{6,7} )
+PYTHON_REQ_USE="threads(+)"
+inherit bash-completion-r1 eutils flag-o-matic pax-utils python-any-r1 toolchain-funcs xdg-utils
 
 DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
 HOMEPAGE="https://nodejs.org/"
-SRC_URI="https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz"
+SRC_URI="
+	https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz
+"
 
 LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
 SLOT="0"
 KEYWORDS="*"
-IUSE="cpu_flags_x86_sse2 debug doc icu inspector +npm +snapshot +ssl systemtap test"
+IUSE="cpu_flags_x86_sse2 debug doc icu inspector +npm +snapshot +ssl +system-ssl systemtap test"
 REQUIRED_USE="
-	${PYTHON_REQUIRED_USE}
 	inspector? ( icu ssl )
 	npm? ( ssl )
+	system-ssl? ( ssl )
 "
 
 RDEPEND="
-	>=dev-libs/libuv-1.19.2:=
-	>=net-libs/http-parser-2.8.0:=
-	>=net-libs/nghttp2-1.32.0
+	>=dev-libs/libuv-1.34.0:=
+	>=net-dns/c-ares-1.15.0
+	>=net-libs/http-parser-2.9.3:=
+	>=net-libs/nghttp2-1.40.0
 	sys-libs/zlib
-	icu? ( >=dev-libs/icu-60.1:= )
-	ssl? ( >=dev-libs/openssl-1.0.2n:0=[-bindist] )
+	icu? ( >=dev-libs/icu-64.2:= )
+	system-ssl? ( >=dev-libs/openssl-1.1.1:0= )
 "
-DEPEND="${RDEPEND}
+BDEPEND="
 	${PYTHON_DEPS}
 	systemtap? ( dev-util/systemtap )
-	test? ( net-misc/curl )"
-
-S="${WORKDIR}/node-v${PV}"
-
+	test? ( net-misc/curl )
+"
+DEPEND="
+	${RDEPEND}
+"
 PATCHES=(
-	"${FILESDIR}"/nodejs-10.3.0-global-npm-config.patch
+	"${FILESDIR}"/${PN}-10.3.0-global-npm-config.patch
+	"${FILESDIR}"/${PN}-99999999-llhttp.patch
 )
+RESTRICT="test"
+S="${WORKDIR}/node-v${PV}"
 
 pkg_pretend() {
 	(use x86 && ! use cpu_flags_x86_sse2) && \
@@ -59,22 +63,18 @@
 	# https://code.google.com/p/gyp/issues/detail?id=260
 	sed -i -e "/append('-arch/d" tools/gyp/pylib/gyp/xcode_emulation.py || die
 
-	# make sure we use python2.* while using gyp
-	sed -i -e "s/python/${EPYTHON}/" deps/npm/node_modules/node-gyp/gyp/gyp || die
-	sed -i -e "s/|| 'python2'/|| '${EPYTHON}'/" deps/npm/node_modules/node-gyp/lib/configure.js || die
-
 	# less verbose install output (stating the same as portage, basically)
 	sed -i -e "/print/d" tools/install.py || die
 
 	# proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
 	local LIBDIR=$(get_libdir)
 	sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
-	sed -i -e "s/'lib'/'${LIBDIR}'/" lib/module.js deps/npm/lib/npm.js || die
+	sed -i -e "s/'lib'/'${LIBDIR}'/" deps/npm/lib/npm.js || die
 
 	# Avoid writing a depfile, not useful
 	sed -i -e "/DEPFLAGS =/d" tools/gyp/pylib/gyp/generator/make.py || die
 
-	sed -i -e "/'-O3'/d" common.gypi deps/v8/gypfiles/toolchain.gypi || die
+	sed -i -e "/'-O3'/d" common.gypi node.gypi || die
 
 	# Avoid a test that I've only been able to reproduce from emerge. It doesnt
 	# seem sandbox related either (invoking it from a sandbox works fine).
@@ -93,13 +93,25 @@
 }
 
 src_configure() {
-	local myconf=( --shared-http-parser --shared-libuv --shared-nghttp2 --shared-zlib )
+	xdg_environment_reset
+
+	local myconf=(
+		--shared-cares
+		--shared-http-parser
+		--shared-libuv
+		--shared-nghttp2
+		--shared-zlib
+	)
 	use debug && myconf+=( --debug )
 	use icu && myconf+=( --with-intl=system-icu ) || myconf+=( --with-intl=none )
 	use inspector || myconf+=( --without-inspector )
 	use npm || myconf+=( --without-npm )
-	use snapshot && myconf+=( --with-snapshot )
-	use ssl && myconf+=( --shared-openssl ) || myconf+=( --without-ssl )
+	use snapshot || myconf+=( --without-node-snapshot )
+	if use ssl; then
+		use system-ssl && myconf+=( --shared-openssl --openssl-use-def-ca-store )
+	else
+		myconf+=( --without-ssl )
+	fi
 
 	local myarch=""
 	case ${ABI} in
@@ -115,7 +127,7 @@
 	GYP_DEFINES="linux_use_gold_flags=0
 		linux_use_bundled_binutils=0
 		linux_use_bundled_gold=0" \
-	"${PYTHON}" configure \
+	"${EPYTHON}" configure.py \
 		--prefix="${EPREFIX}"/usr \
 		--dest-cpu=${myarch} \
 		$(use_with systemtap dtrace) \
@@ -130,8 +142,9 @@
 
 src_install() {
 	local LIBDIR="${ED}/usr/$(get_libdir)"
-	emake install DESTDIR="${D}"
-	pax-mark -m "${ED}"usr/bin/node
+	default
+
+	pax-mark -m "${ED}"/usr/bin/node
 
 	# set up a symlink structure that node-gyp expects..
 	dodir /usr/include/node/deps/{v8,uv}
@@ -141,12 +154,8 @@
 	done
 
 	if use doc; then
-		# Patch docs to make them offline readable
-		for i in `grep -rl 'fonts.googleapis.com' "${S}"/out/doc/api/*`; do
-			sed -i '/fonts.googleapis.com/ d' $i;
-		done
-		# Install docs!
-		dohtml -r "${S}"/doc/*
+		docinto html
+		dodoc -r "${S}"/doc/*
 	fi
 
 	if use npm; then
@@ -185,6 +194,8 @@
 				"${find_name[@]}" \
 			\) \) -exec rm -rf "{}" \;
 	fi
+
+	mv "${ED}"/usr/share/doc/node "${ED}"/usr/share/doc/${PF} || die
 }
 
 src_test() {
@@ -193,10 +204,10 @@
 }
 
 pkg_postinst() {
-	einfo "The global npm config lives in /etc/npm. This deviates slightly"
-	einfo "from upstream which otherwise would have it live in /usr/etc/."
-	einfo ""
-	einfo "Protip: When using node-gyp to install native modules, you can"
-	einfo "avoid having to download extras by doing the following:"
-	einfo "$ node-gyp --nodedir /usr/include/node <command>"
+	elog "The global npm config lives in /etc/npm. This deviates slightly"
+	elog "from upstream which otherwise would have it live in /usr/etc/."
+	elog ""
+	elog "Protip: When using node-gyp to install native modules, you can"
+	elog "avoid having to download extras by doing the following:"
+	elog "$ node-gyp --nodedir /usr/include/node <command>"
 }