Gentoo Archives: gentoo-commits

From: Marek Szuba <marecki@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-libs/nodejs/
Date: Fri, 16 Apr 2021 18:25:10
Message-Id: 1618597461.5e41eaca605e84e0f641f09f1f5c4ac1826e1e28.marecki@gentoo
1 commit: 5e41eaca605e84e0f641f09f1f5c4ac1826e1e28
2 Author: Marek Szuba <marecki <AT> gentoo <DOT> org>
3 AuthorDate: Fri Apr 16 15:51:36 2021 +0000
4 Commit: Marek Szuba <marecki <AT> gentoo <DOT> org>
5 CommitDate: Fri Apr 16 18:24:21 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5e41eaca
7
8 net-libs/nodejs: bump v12 to 12.22.1
9
10 Addresses CVE-2021-3450, CVE-2021-3449 and CVE-2020-7774.
11
12 Bug: https://bugs.gentoo.org/781704
13 Signed-off-by: Marek Szuba <marecki <AT> gentoo.org>
14
15 net-libs/nodejs/Manifest | 1 +
16 net-libs/nodejs/nodejs-12.22.1.ebuild | 220 ++++++++++++++++++++++++++++++++++
17 2 files changed, 221 insertions(+)
18
19 diff --git a/net-libs/nodejs/Manifest b/net-libs/nodejs/Manifest
20 index c3a81d6c795..61cd8df79f0 100644
21 --- a/net-libs/nodejs/Manifest
22 +++ b/net-libs/nodejs/Manifest
23 @@ -1,3 +1,4 @@
24 DIST node-v12.21.0.tar.xz 23650552 BLAKE2B 532eef3e77d78aa1b6f30ebdc1dee88ed95280c86e44db525ce369cb1c2d9707a30a1a4ec2d8e699f7c1a14ada036fc4d62d0f0c7fa017e72768662768bbbf18 SHA512 48df48a12657e3a2366cd80a1a7040365b7a90053676230f1f93f253a1fcdafc5bc1df5b5ec5c13f616277b5feb7e7653cd145ab9c23222bf7702d7cd1fa74eb
25 +DIST node-v12.22.1.tar.xz 23650180 BLAKE2B 90b0a8ab3842483fea0c776e0245e63539a986c18f55abd8c7cd22ec399ccde22fa5b008d3e07c0f07713b5a45a1ee2a0bc370c04408800db2ee59cd92fcb5be SHA512 eaead633611bda04ab9be200aeddf3b4004b8104e9c6af246023b8008003dd3a7103e1508ea690443e59c6591521b04a2d71c7344343f2a20d1c935ef51c66a0
26 DIST node-v14.16.0.tar.xz 33301140 BLAKE2B faf380e8f02ea2e6084601fece1e9d3119aeabcebc844fd22a79c18e27cf54f0cd470971cc5a86277a226e59950f511e1173828565bdda1c1f06c52b144cba6f SHA512 ac6f7408df35e2bae8bcad3f461d8e260a2762c77f78d737b0339a592724ff1a98ba171a95e44366e731accfb3208e7cfd6d3edd0f646ddc26a01cfbdbbb655b
27 DIST node-v15.11.0.tar.xz 33285300 BLAKE2B 50f38e46faa7a7c206bf6f82827643c4f6c06ed3e1bc8a12f06badc024b88e801e749524123134146547e7af3403110db11a5d1717a2a91c0ccd875ef91de457 SHA512 e6c7d6fb2f7008d911a63c120cf7f82fb78eff2b57a934f57e6c8294be3b16f0ab982b828989772f04199e609d2dc0c90067ec517ec1e27991f1275e0ced204a
28
29 diff --git a/net-libs/nodejs/nodejs-12.22.1.ebuild b/net-libs/nodejs/nodejs-12.22.1.ebuild
30 new file mode 100644
31 index 00000000000..bd8f3dcec30
32 --- /dev/null
33 +++ b/net-libs/nodejs/nodejs-12.22.1.ebuild
34 @@ -0,0 +1,220 @@
35 +# Copyright 1999-2021 Gentoo Authors
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +EAPI=7
39 +
40 +PYTHON_COMPAT=( python3_{7..9} )
41 +PYTHON_REQ_USE="threads(+)"
42 +
43 +inherit bash-completion-r1 flag-o-matic pax-utils python-any-r1 toolchain-funcs xdg-utils
44 +
45 +DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
46 +HOMEPAGE="https://nodejs.org/"
47 +SRC_URI="
48 + https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz
49 +"
50 +
51 +LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
52 +SLOT="0/$(ver_cut 1)"
53 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86 ~amd64-linux ~x64-macos"
54 +IUSE="cpu_flags_x86_sse2 debug doc icu inspector +npm +snapshot +ssl +system-ssl systemtap test"
55 +REQUIRED_USE="
56 + inspector? ( icu ssl )
57 + npm? ( ssl )
58 + system-ssl? ( ssl )
59 +"
60 +
61 +RDEPEND="
62 + >=app-arch/brotli-1.0.9
63 + >=dev-libs/libuv-1.39.0:=
64 + >=net-dns/c-ares-1.16.0
65 + >=net-libs/http-parser-2.9.3:=
66 + >=net-libs/nghttp2-1.40.0
67 + sys-libs/zlib
68 + icu? ( >=dev-libs/icu-64.2:= )
69 + system-ssl? ( >=dev-libs/openssl-1.1.1:0= )
70 +"
71 +BDEPEND="
72 + ${PYTHON_DEPS}
73 + sys-apps/coreutils
74 + virtual/pkgconfig
75 + systemtap? ( dev-util/systemtap )
76 + test? ( net-misc/curl )
77 +"
78 +DEPEND="
79 + ${RDEPEND}
80 +"
81 +PATCHES=(
82 + "${FILESDIR}"/${PN}-10.3.0-global-npm-config.patch
83 + "${FILESDIR}"/${PN}-12.20.1-fix_ppc64_crashes.patch
84 + "${FILESDIR}"/${PN}-99999999-llhttp.patch
85 +)
86 +RESTRICT="test"
87 +S="${WORKDIR}/node-v${PV}"
88 +
89 +pkg_pretend() {
90 + (use x86 && ! use cpu_flags_x86_sse2) && \
91 + die "Your CPU doesn't support the required SSE2 instruction."
92 +
93 + ( [[ ${MERGE_TYPE} != "binary" ]] && ! test-flag-CXX -std=c++11 ) && \
94 + die "Your compiler doesn't support C++11. Use GCC 4.8, Clang 3.3 or newer."
95 +}
96 +
97 +src_prepare() {
98 + tc-export CC CXX PKG_CONFIG
99 + export V=1
100 + export BUILDTYPE=Release
101 +
102 + # fix compilation on Darwin
103 + # https://code.google.com/p/gyp/issues/detail?id=260
104 + sed -i -e "/append('-arch/d" tools/gyp/pylib/gyp/xcode_emulation.py || die
105 +
106 + # less verbose install output (stating the same as portage, basically)
107 + sed -i -e "/print/d" tools/install.py || die
108 +
109 + # proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
110 + local LIBDIR=$(get_libdir)
111 + sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
112 + sed -i -e "s/'lib'/'${LIBDIR}'/" deps/npm/lib/npm.js || die
113 +
114 + # Avoid writing a depfile, not useful
115 + sed -i -e "/DEPFLAGS =/d" tools/gyp/pylib/gyp/generator/make.py || die
116 +
117 + sed -i -e "/'-O3'/d" common.gypi node.gypi || die
118 +
119 + # Avoid a test that I've only been able to reproduce from emerge. It doesnt
120 + # seem sandbox related either (invoking it from a sandbox works fine).
121 + # The issue is that no stdin handle is openened when asked for one.
122 + # It doesn't really belong upstream , so it'll just be removed until someone
123 + # with more gentoo-knowledge than me (jbergstroem) figures it out.
124 + rm test/parallel/test-stdout-close-unref.js || die
125 +
126 + # debug builds. change install path, remove optimisations and override buildtype
127 + if use debug; then
128 + sed -i -e "s|out/Release/|out/Debug/|g" tools/install.py || die
129 + BUILDTYPE=Debug
130 + fi
131 +
132 + default
133 +}
134 +
135 +src_configure() {
136 + xdg_environment_reset
137 +
138 + local myconf=(
139 + --shared-brotli
140 + --shared-cares
141 + --shared-http-parser
142 + --shared-libuv
143 + --shared-nghttp2
144 + --shared-zlib
145 + )
146 + use debug && myconf+=( --debug )
147 + use icu && myconf+=( --with-intl=system-icu ) || myconf+=( --with-intl=none )
148 + use inspector || myconf+=( --without-inspector )
149 + use npm || myconf+=( --without-npm )
150 + use snapshot || myconf+=( --without-node-snapshot )
151 + if use ssl; then
152 + use system-ssl && myconf+=( --shared-openssl --openssl-use-def-ca-store )
153 + else
154 + myconf+=( --without-ssl )
155 + fi
156 +
157 + local myarch=""
158 + case ${ABI} in
159 + amd64) myarch="x64";;
160 + arm) myarch="arm";;
161 + arm64) myarch="arm64";;
162 + ppc64) myarch="ppc64";;
163 + x32) myarch="x32";;
164 + x86) myarch="ia32";;
165 + *) myarch="${ABI}";;
166 + esac
167 +
168 + GYP_DEFINES="linux_use_gold_flags=0
169 + linux_use_bundled_binutils=0
170 + linux_use_bundled_gold=0" \
171 + "${EPYTHON}" configure.py \
172 + --prefix="${EPREFIX}"/usr \
173 + --dest-cpu=${myarch} \
174 + $(use_with systemtap dtrace) \
175 + "${myconf[@]}" || die
176 +}
177 +
178 +src_compile() {
179 + emake -C out mksnapshot
180 + pax-mark m "out/${BUILDTYPE}/mksnapshot"
181 + emake -C out
182 +}
183 +
184 +src_install() {
185 + local LIBDIR="${ED}/usr/$(get_libdir)"
186 + default
187 +
188 + pax-mark -m "${ED}"/usr/bin/node
189 +
190 + # set up a symlink structure that node-gyp expects..
191 + dodir /usr/include/node/deps/{v8,uv}
192 + dosym . /usr/include/node/src
193 + for var in deps/{uv,v8}/include; do
194 + dosym ../.. /usr/include/node/${var}
195 + done
196 +
197 + if use doc; then
198 + docinto html
199 + dodoc -r "${S}"/doc/*
200 + fi
201 +
202 + if use npm; then
203 + dodir /etc/npm
204 +
205 + # Install bash completion for `npm`
206 + # We need to temporarily replace default config path since
207 + # npm otherwise tries to write outside of the sandbox
208 + local npm_config="usr/$(get_libdir)/node_modules/npm/lib/config/core.js"
209 + sed -i -e "s|'/etc'|'${ED}/etc'|g" "${ED}/${npm_config}" || die
210 + local tmp_npm_completion_file="$(TMPDIR="${T}" mktemp -t npm.XXXXXXXXXX)"
211 + "${ED}/usr/bin/npm" completion > "${tmp_npm_completion_file}"
212 + newbashcomp "${tmp_npm_completion_file}" npm
213 + sed -i -e "s|'${ED}/etc'|'/etc'|g" "${ED}/${npm_config}" || die
214 +
215 + # Move man pages
216 + doman "${LIBDIR}"/node_modules/npm/man/man{1,5,7}/*
217 +
218 + # Clean up
219 + rm "${LIBDIR}"/node_modules/npm/{.mailmap,.npmignore,Makefile} || die
220 + rm -rf "${LIBDIR}"/node_modules/npm/{doc,html,man} || die
221 +
222 + local find_exp="-or -name"
223 + local find_name=()
224 + for match in "AUTHORS*" "CHANGELOG*" "CONTRIBUT*" "README*" \
225 + ".travis.yml" ".eslint*" ".wercker.yml" ".npmignore" \
226 + "*.md" "*.markdown" "*.bat" "*.cmd"; do
227 + find_name+=( ${find_exp} "${match}" )
228 + done
229 +
230 + # Remove various development and/or inappropriate files and
231 + # useless docs of dependend packages.
232 + find "${LIBDIR}"/node_modules \
233 + \( -type d -name examples \) -or \( -type f \( \
234 + -iname "LICEN?E*" \
235 + "${find_name[@]}" \
236 + \) \) -exec rm -rf "{}" \;
237 + fi
238 +
239 + mv "${ED}"/usr/share/doc/node "${ED}"/usr/share/doc/${PF} || die
240 +}
241 +
242 +src_test() {
243 + out/${BUILDTYPE}/cctest || die
244 + "${PYTHON}" tools/test.py --mode=${BUILDTYPE,,} -J message parallel sequential || die
245 +}
246 +
247 +pkg_postinst() {
248 + elog "The global npm config lives in /etc/npm. This deviates slightly"
249 + elog "from upstream which otherwise would have it live in /usr/etc/."
250 + elog ""
251 + elog "Protip: When using node-gyp to install native modules, you can"
252 + elog "avoid having to download extras by doing the following:"
253 + elog "$ node-gyp --nodedir /usr/include/node <command>"
254 +}