Gentoo Archives: gentoo-commits

From: Jeroen Roovers <jer@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-libs/nodejs/
Date: Wed, 25 Oct 2017 06:58:29
Message-Id: 1508914699.e5e446a06931f74c6d44a0ed69b096e321650254.jer@gentoo
1 commit: e5e446a06931f74c6d44a0ed69b096e321650254
2 Author: Jeroen Roovers <jer <AT> gentoo <DOT> org>
3 AuthorDate: Wed Oct 25 06:56:37 2017 +0000
4 Commit: Jeroen Roovers <jer <AT> gentoo <DOT> org>
5 CommitDate: Wed Oct 25 06:58:19 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5e446a0
7
8 net-libs/nodejs: Version bump.
9
10 Package-Manager: Portage-2.3.12, Repoman-2.3.3
11
12 net-libs/nodejs/Manifest | 3 +
13 net-libs/nodejs/nodejs-4.8.5.ebuild | 143 +++++++++++++++++++++++++
14 net-libs/nodejs/nodejs-6.11.5.ebuild | 193 ++++++++++++++++++++++++++++++++++
15 net-libs/nodejs/nodejs-8.8.0.ebuild | 196 +++++++++++++++++++++++++++++++++++
16 4 files changed, 535 insertions(+)
17
18 diff --git a/net-libs/nodejs/Manifest b/net-libs/nodejs/Manifest
19 index 450b49817f7..f68e0668b3f 100644
20 --- a/net-libs/nodejs/Manifest
21 +++ b/net-libs/nodejs/Manifest
22 @@ -1,6 +1,9 @@
23 DIST node-v0.12.17.tar.gz 19938029 SHA256 ddea5e253812f167608fbdda6ff29ffc30dc6f669cf2f6e4249938d28b9cd44d SHA512 86c22b17f57018083b07096beeca10e6dfa7569b3d1a25a3b12dd82796db3c9536e6136e0dd0ff62b4de116413f3722b36ce396faa46d8640f80ab09ccfcbca7 WHIRLPOOL 5fba1f95de0a7dbda7e7649bc0f8553cd8595eb87cd27062efbdc59a54673e7e1e6f80191abede683a686043a81d82b76e141aa765b98e3dc39e015aca98e41f
24 DIST node-v4.6.1.tar.xz 13295568 SHA256 fe2a85df8758001878abb5bbaf17a6b6cdc12b3e465b1d3bace83b37fdf0345a SHA512 4eb2acbe13ee2373922420e3238be63d2108dacba640438bddbdea12ec2de9c655f33db611e4c0654b66bf4fdb844a7b6554a823aac73171b17599096856abdb WHIRLPOOL a6d21cce7ab8c430528682f78a6e6492f753c87949b7b1bdc15dc02911559cd89deb45329c2ba32da57b776dd4feaabec8a3e7a59a78094cfb079261b6475c76
25 +DIST node-v4.8.5.tar.xz 13316060 SHA256 a48aeefc2b4fae0ea6410a8045ca106af244223012eab003bd5cb00aa3b50d53 SHA512 64d936ca14648b5648dedb41f2ee8d39466788762d335fbfc9ce4cb7484d05b6c24ad912fb4b1579a08f466be50b129a96be700fd89cbca5e1de84baa63ddd12 WHIRLPOOL 8d74323f38b4f55bf2e95a628005cbb65c0f4ea0e5dd55699408e26b724ff65fd0a7f674399ed92ac3a56592064133daffcbb37d7076b8da33d28b4d17d61410
26 DIST node-v6.11.4.tar.xz 15699188 SHA256 4c2f0435e3088136ac4bc75236a7717f189d590a13f490065e7b3b8e5aacd450 SHA512 e495db0e1fe44a50c445424df6e9ea2e28245db485361e9ac928e4e6abbe0866f75b7948f70732f23218d4e93cf1b793613eba9d2551466fa56ac97c6c97de5e WHIRLPOOL dbb0cbeb6fe69da815e408dbbd16f40eb40f88b3493a9bad0d004294da738dbc1c0cde538cfddd10616ff1dc27f59dbd39f2818636575cb5cac2414de1d7ebe1
27 +DIST node-v6.11.5.tar.xz 15699404 SHA256 1c6de415216799fbaeca82304b3fef87accc7101ebf2ead7d5c545e0779e8aaf SHA512 62490725ef7957294c1bddf21ef0626c7472876791210168116501255ecee58457e9de9b044e10033706243299bbfd1495efeca169596fbf26f5eeba6d8fa4c9 WHIRLPOOL 6e572e34d473544624734a54243dc41101e91d045f2b9cedc0c1a65c90584deb163efb422a0c992689ef9878cc5b882758795ae4d902c1c5b20468d8fa2151da
28 DIST node-v6.9.4.tar.xz 15519264 SHA256 c51d7c61db40455d57428abcadc7eb0f0a08a8878cb1d8ea3c1e211c54532c35 SHA512 86d3e2889031c2b50c021bd3fd63194c2c22c44291d51dff1b5e1652b01853c09d2880c2f58fdad062e3e2a3f637a3f0d78dac66b835b676790cf272e64f8dce WHIRLPOOL d1bcf488ed1aae7959303b988c9467fc5d0930166c7bfe0e441392763e19f788496971c07560a9f62586bbb2be7ce741ece8346140d665d29593b9b8f649b002
29 DIST node-v8.5.0.tar.xz 18326412 SHA256 e1cde5d8e5049e7e1b61aef128f26162059d885dc8cab5014bf5cbf693f75c3c SHA512 7ef83a6da7ba9d61c19df0530dfee7b769c0bc7ab066fc29fdb54c9b09085a3536699c7c92889cea8fbf3d6241cc66c383cd351451da8019fea4e0d25d043f3d WHIRLPOOL 63576159748e9423a0b1df7d032d4f5edc23d33f22fd76d3dc0f0b4804606abf57011097dcf4fd2d3707b22babe69bcd976133b7450558925b5d679872abd382
30 DIST node-v8.7.0.tar.xz 18186384 SHA256 5a17d08c68ee7c1e748fd32534edda766cb57c13ed98e693f3075bc9d9a0b59a SHA512 5ce41d2d7f1c07330c4d9acc8129840d03fb820dac2f87be3f277a372ed6d84d6e1516e1d804e2277d500f32f9838d4307122b26962029d4f811904523f72530 WHIRLPOOL f4541efef681204684d491c9a2539560602c017087fa895e41b3ee9616ce6860a22634179bb904e816eee45b5f5ebc06bada5bb55be05e6e1418cac45cc55966
31 +DIST node-v8.8.0.tar.xz 18209392 SHA256 854f32d27cd62895a13a6af43b87e0542f512f40af960244d15cf16da0914ecf SHA512 7089d0040e4c669f4923770894ec6d11ada3653dfbfe550480056401b1e095226f7d3edf7fee036ce81d8f379cc9fe41f8ac243f714bf3f8f12bd8c13e0a4d1b WHIRLPOOL 5191611f2d8582cc8dec75a955afac4366189e55de20662513ade7077d949aacee2ed93e670348523b4f8136b6ad7ea4aef44b26c7746a096fdcf34decd5f46d
32
33 diff --git a/net-libs/nodejs/nodejs-4.8.5.ebuild b/net-libs/nodejs/nodejs-4.8.5.ebuild
34 new file mode 100644
35 index 00000000000..9de641b4dac
36 --- /dev/null
37 +++ b/net-libs/nodejs/nodejs-4.8.5.ebuild
38 @@ -0,0 +1,143 @@
39 +# Copyright 1999-2017 Gentoo Foundation
40 +# Distributed under the terms of the GNU General Public License v2
41 +
42 +EAPI=5
43 +
44 +PYTHON_COMPAT=( python2_7 )
45 +PYTHON_REQ_USE="threads"
46 +
47 +inherit flag-o-matic pax-utils python-single-r1 toolchain-funcs
48 +
49 +DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
50 +HOMEPAGE="https://nodejs.org/"
51 +SRC_URI="https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz"
52 +
53 +LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
54 +SLOT="0"
55 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86 ~x64-macos"
56 +IUSE="cpu_flags_x86_sse2 debug icu +npm snapshot +ssl test"
57 +
58 +RDEPEND="icu? ( >=dev-libs/icu-55:= )
59 + npm? ( ${PYTHON_DEPS} )
60 + >=net-libs/http-parser-2.5.2:=
61 + >=dev-libs/libuv-1.8.0:=
62 + >=dev-libs/openssl-1.0.2g:0=[-bindist]
63 + sys-libs/zlib"
64 +DEPEND="${RDEPEND}
65 + ${PYTHON_DEPS}
66 + test? ( net-misc/curl )"
67 +
68 +S="${WORKDIR}/node-v${PV}"
69 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
70 +
71 +pkg_pretend() {
72 + (use x86 && ! use cpu_flags_x86_sse2) && \
73 + die "Your CPU doesn't support the required SSE2 instruction."
74 +
75 + ( [[ ${MERGE_TYPE} != "binary" ]] && ! test-flag-CXX -std=c++11 ) && \
76 + die "Your compiler doesn't support C++11. Use GCC 4.8, Clang 3.3 or newer."
77 +}
78 +
79 +src_prepare() {
80 + tc-export CC CXX PKG_CONFIG
81 + export V=1 # Verbose build
82 + export BUILDTYPE=Release
83 +
84 + # fix compilation on Darwin
85 + # https://code.google.com/p/gyp/issues/detail?id=260
86 + sed -i -e "/append('-arch/d" tools/gyp/pylib/gyp/xcode_emulation.py || die
87 +
88 + # make sure we use python2.* while using gyp
89 + sed -i -e "s/python/${EPYTHON}/" deps/npm/node_modules/node-gyp/gyp/gyp || die
90 + sed -i -e "s/|| 'python'/|| '${EPYTHON}'/" deps/npm/node_modules/node-gyp/lib/configure.js || die
91 +
92 + # less verbose install output (stating the same as portage, basically)
93 + sed -i -e "/print/d" tools/install.py || die
94 +
95 + # proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
96 + local LIBDIR=$(get_libdir)
97 + sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
98 + sed -i -e "s/'lib'/'${LIBDIR}'/" lib/module.js || die
99 + sed -i -e "s|\"lib\"|\"${LIBDIR}\"|" deps/npm/lib/npm.js || die
100 +
101 + # Avoid a test that I've only been able to reproduce from emerge. It doesnt
102 + # seem sandbox related either (invoking it from a sandbox works fine).
103 + # The issue is that no stdin handle is openened when asked for one.
104 + # It doesn't really belong upstream , so it'll just be removed until someone
105 + # with more gentoo-knowledge than me (jbergstroem) figures it out.
106 + rm test/parallel/test-stdout-close-unref.js || die
107 +
108 + # debug builds. change install path, remove optimisations and override buildtype
109 + if use debug; then
110 + sed -i -e "s|out/Release/|out/Debug/|g" tools/install.py || die
111 + BUILDTYPE=Debug
112 + fi
113 +
114 + epatch_user
115 +}
116 +
117 +src_configure() {
118 + local myarch=""
119 + local myconf+=( --shared-openssl --shared-libuv --shared-http-parser --shared-zlib )
120 + use npm || myconf+=( --without-npm )
121 + use icu && myconf+=( --with-intl=system-icu )
122 + use snapshot && myconf+=( --with-snapshot )
123 + use ssl || myconf+=( --without-ssl )
124 + use debug && myconf+=( --debug )
125 +
126 + case ${ABI} in
127 + amd64) myarch="x64";;
128 + arm) myarch="arm";;
129 + arm64) myarch="arm64";;
130 + ppc64) myarch="ppc64";;
131 + x32) myarch="x32";;
132 + x86) myarch="ia32";;
133 + *) die "Unrecognized ARCH ${ARCH}";;
134 + esac
135 +
136 + GYP_DEFINES="linux_use_gold_flags=0
137 + linux_use_bundled_binutils=0
138 + linux_use_bundled_gold=0" \
139 + "${PYTHON}" configure \
140 + --prefix="${EPREFIX}"/usr \
141 + --dest-cpu=${myarch} \
142 + --without-dtrace \
143 + "${myconf[@]}" || die
144 +}
145 +
146 +src_compile() {
147 + emake -C out mksnapshot
148 + pax-mark m "out/${BUILDTYPE}/mksnapshot"
149 + emake -C out
150 +}
151 +
152 +src_install() {
153 + local LIBDIR="${ED}/usr/$(get_libdir)"
154 + emake install DESTDIR="${ED}" PREFIX=/usr
155 + if use npm; then
156 + dodoc -r "${LIBDIR}"/node_modules/npm/html
157 + rm -rf "${LIBDIR}"/node_modules/npm/{doc,html} || die
158 + find "${LIBDIR}"/node_modules -type f -name "LICENSE*" -or -name "LICENCE*" -delete || die
159 + fi
160 +
161 + # set up a symlink structure that npm expects..
162 + dodir /usr/include/node/deps/{v8,uv}
163 + dosym . /usr/include/node/src
164 + for var in deps/{uv,v8}/include; do
165 + dosym ../.. /usr/include/node/${var}
166 + done
167 +
168 + pax-mark -m "${ED}"/usr/bin/node
169 +}
170 +
171 +src_test() {
172 + out/${BUILDTYPE}/cctest || die
173 + "${PYTHON}" tools/test.py --mode=${BUILDTYPE,,} -J message parallel sequential || die
174 +}
175 +
176 +pkg_postinst() {
177 + einfo "When using node-gyp to install native modules, you can avoid"
178 + einfo "having to download the full tarball by doing the following:"
179 + einfo ""
180 + einfo "node-gyp --nodedir /usr/include/node <command>"
181 +}
182
183 diff --git a/net-libs/nodejs/nodejs-6.11.5.ebuild b/net-libs/nodejs/nodejs-6.11.5.ebuild
184 new file mode 100644
185 index 00000000000..67c45191733
186 --- /dev/null
187 +++ b/net-libs/nodejs/nodejs-6.11.5.ebuild
188 @@ -0,0 +1,193 @@
189 +# Copyright 1999-2017 Gentoo Foundation
190 +# Distributed under the terms of the GNU General Public License v2
191 +
192 +EAPI=6
193 +RESTRICT="test"
194 +
195 +PYTHON_COMPAT=( python2_7 )
196 +PYTHON_REQ_USE="threads"
197 +
198 +inherit bash-completion-r1 eutils flag-o-matic pax-utils python-single-r1 toolchain-funcs
199 +
200 +DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
201 +HOMEPAGE="https://nodejs.org/"
202 +SRC_URI="https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz"
203 +
204 +LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
205 +SLOT="0"
206 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x64-macos"
207 +IUSE="cpu_flags_x86_sse2 debug doc icu +npm +snapshot +ssl test"
208 +
209 +RDEPEND="icu? ( >=dev-libs/icu-56:= )
210 + npm? ( ${PYTHON_DEPS} )
211 + >=net-libs/http-parser-2.6.2:=
212 + >=dev-libs/libuv-1.9.0:=
213 + >=dev-libs/openssl-1.0.2g:0=[-bindist]
214 + sys-libs/zlib"
215 +DEPEND="${RDEPEND}
216 + ${PYTHON_DEPS}
217 + test? ( net-misc/curl )"
218 +
219 +S="${WORKDIR}/node-v${PV}"
220 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
221 +
222 +PATCHES=(
223 + "${FILESDIR}"/gentoo-global-npm-config.patch
224 +)
225 +
226 +pkg_pretend() {
227 + (use x86 && ! use cpu_flags_x86_sse2) && \
228 + die "Your CPU doesn't support the required SSE2 instruction."
229 +
230 + ( [[ ${MERGE_TYPE} != "binary" ]] && ! test-flag-CXX -std=c++11 ) && \
231 + die "Your compiler doesn't support C++11. Use GCC 4.8, Clang 3.3 or newer."
232 +}
233 +
234 +src_prepare() {
235 + tc-export CC CXX PKG_CONFIG
236 + export V=1
237 + export BUILDTYPE=Release
238 +
239 + # fix compilation on Darwin
240 + # https://code.google.com/p/gyp/issues/detail?id=260
241 + sed -i -e "/append('-arch/d" tools/gyp/pylib/gyp/xcode_emulation.py || die
242 +
243 + # make sure we use python2.* while using gyp
244 + sed -i -e "s/python/${EPYTHON}/" deps/npm/node_modules/node-gyp/gyp/gyp || die
245 + sed -i -e "s/|| 'python'/|| '${EPYTHON}'/" deps/npm/node_modules/node-gyp/lib/configure.js || die
246 +
247 + # less verbose install output (stating the same as portage, basically)
248 + sed -i -e "/print/d" tools/install.py || die
249 +
250 + # proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
251 + local LIBDIR=$(get_libdir)
252 + sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
253 + sed -i -e "s/'lib'/'${LIBDIR}'/" lib/module.js || die
254 + sed -i -e "s|\"lib\"|\"${LIBDIR}\"|" deps/npm/lib/npm.js || die
255 +
256 + # Avoid writing a depfile, not useful
257 + sed -i -e "/DEPFLAGS =/d" tools/gyp/pylib/gyp/generator/make.py || die
258 +
259 + # Avoid a test that I've only been able to reproduce from emerge. It doesnt
260 + # seem sandbox related either (invoking it from a sandbox works fine).
261 + # The issue is that no stdin handle is openened when asked for one.
262 + # It doesn't really belong upstream , so it'll just be removed until someone
263 + # with more gentoo-knowledge than me (jbergstroem) figures it out.
264 + rm test/parallel/test-stdout-close-unref.js || die
265 +
266 + # debug builds. change install path, remove optimisations and override buildtype
267 + if use debug; then
268 + sed -i -e "s|out/Release/|out/Debug/|g" tools/install.py || die
269 + BUILDTYPE=Debug
270 + fi
271 +
272 + default
273 +}
274 +
275 +src_configure() {
276 + local myarch=""
277 + local myconf=( --shared-openssl --shared-libuv --shared-http-parser --shared-zlib )
278 + use npm || myconf+=( --without-npm )
279 + use icu && myconf+=( --with-intl=system-icu )
280 + use snapshot && myconf+=( --with-snapshot )
281 + use ssl || myconf+=( --without-ssl )
282 + use debug && myconf+=( --debug )
283 +
284 + case ${ABI} in
285 + amd64) myarch="x64";;
286 + arm) myarch="arm";;
287 + arm64) myarch="arm64";;
288 + ppc64) myarch="ppc64";;
289 + x32) myarch="x32";;
290 + x86) myarch="ia32";;
291 + *) myarch="${ABI}";;
292 + esac
293 +
294 + GYP_DEFINES="linux_use_gold_flags=0
295 + linux_use_bundled_binutils=0
296 + linux_use_bundled_gold=0" \
297 + "${PYTHON}" configure \
298 + --prefix="${EPREFIX}"/usr \
299 + --dest-cpu=${myarch} \
300 + --without-dtrace \
301 + "${myconf[@]}" || die
302 +}
303 +
304 +src_compile() {
305 + emake -C out mksnapshot
306 + pax-mark m "out/${BUILDTYPE}/mksnapshot"
307 + emake -C out
308 +}
309 +
310 +src_install() {
311 + local LIBDIR="${ED}/usr/$(get_libdir)"
312 + emake install DESTDIR="${D}"
313 + pax-mark -m "${ED}"usr/bin/node
314 +
315 + # set up a symlink structure that node-gyp expects..
316 + dodir /usr/include/node/deps/{v8,uv}
317 + dosym . /usr/include/node/src
318 + for var in deps/{uv,v8}/include; do
319 + dosym ../.. /usr/include/node/${var}
320 + done
321 +
322 + if use doc; then
323 + # Patch docs to make them offline readable
324 + for i in `grep -rl 'fonts.googleapis.com' "${S}"/out/doc/api/*`; do
325 + sed -i '/fonts.googleapis.com/ d' $i;
326 + done
327 + # Install docs!
328 + dohtml -r "${S}"/doc/*
329 + fi
330 +
331 + if use npm; then
332 + dodir /etc/npm
333 +
334 + # Install bash completion for `npm`
335 + # We need to temporarily replace default config path since
336 + # npm otherwise tries to write outside of the sandbox
337 + local npm_config="usr/$(get_libdir)/node_modules/npm/lib/config/core.js"
338 + sed -i -e "s|'/etc'|'${ED}/etc'|g" "${ED}/${npm_config}" || die
339 + local tmp_npm_completion_file="$(emktemp)"
340 + "${ED}/usr/bin/npm" completion > "${tmp_npm_completion_file}"
341 + newbashcomp "${tmp_npm_completion_file}" npm
342 + sed -i -e "s|'${ED}/etc'|'/etc'|g" "${ED}/${npm_config}" || die
343 +
344 + # Move man pages
345 + doman "${LIBDIR}"/node_modules/npm/man/man{1,5,7}/*
346 +
347 + # Clean up
348 + rm "${LIBDIR}"/node_modules/npm/{.mailmap,.npmignore,Makefile} || die
349 + rm -rf "${LIBDIR}"/node_modules/npm/{doc,html,man} || die
350 +
351 + local find_exp="-or -name"
352 + local find_name=()
353 + for match in "AUTHORS*" "CHANGELOG*" "CONTRIBUT*" "README*" \
354 + ".travis.yml" ".eslint*" ".wercker.yml" ".npmignore" \
355 + "*.md" "*.markdown" "*.bat" "*.cmd"; do
356 + find_name+=( ${find_exp} "${match}" )
357 + done
358 +
359 + # Remove various development and/or inappropriate files and
360 + # useless docs of dependend packages.
361 + find "${LIBDIR}"/node_modules \
362 + \( -type d -name examples \) -or \( -type f \( \
363 + -iname "LICEN?E*" \
364 + "${find_name[@]}" \
365 + \) \) -exec rm -rf "{}" \;
366 + fi
367 +}
368 +
369 +src_test() {
370 + out/${BUILDTYPE}/cctest || die
371 + "${PYTHON}" tools/test.py --mode=${BUILDTYPE,,} -J message parallel sequential || die
372 +}
373 +
374 +pkg_postinst() {
375 + einfo "The global npm config lives in /etc/npm. This deviates slightly"
376 + einfo "from upstream which otherwise would have it live in /usr/etc/."
377 + einfo ""
378 + einfo "Protip: When using node-gyp to install native modules, you can"
379 + einfo "avoid having to download extras by doing the following:"
380 + einfo "$ node-gyp --nodedir /usr/include/node <command>"
381 +}
382
383 diff --git a/net-libs/nodejs/nodejs-8.8.0.ebuild b/net-libs/nodejs/nodejs-8.8.0.ebuild
384 new file mode 100644
385 index 00000000000..2739d2a8cd9
386 --- /dev/null
387 +++ b/net-libs/nodejs/nodejs-8.8.0.ebuild
388 @@ -0,0 +1,196 @@
389 +# Copyright 1999-2017 Gentoo Foundation
390 +# Distributed under the terms of the GNU General Public License v2
391 +
392 +EAPI=6
393 +RESTRICT="test"
394 +
395 +PYTHON_COMPAT=( python2_7 )
396 +PYTHON_REQ_USE="threads"
397 +
398 +inherit bash-completion-r1 eutils flag-o-matic pax-utils python-single-r1 toolchain-funcs
399 +
400 +DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
401 +HOMEPAGE="https://nodejs.org/"
402 +SRC_URI="https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz"
403 +
404 +LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
405 +SLOT="0"
406 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x64-macos"
407 +IUSE="cpu_flags_x86_sse2 debug doc icu +npm +snapshot +ssl systemtap test"
408 +
409 +RDEPEND="icu? ( >=dev-libs/icu-56:= )
410 + npm? ( ${PYTHON_DEPS} )
411 + >=net-libs/http-parser-2.7.0:=
412 + >=dev-libs/libuv-1.15.0:=
413 + >=net-libs/nghttp2-1.25.0
414 + >=dev-libs/openssl-1.0.2g:0=[-bindist]
415 + sys-libs/zlib"
416 +DEPEND="${RDEPEND}
417 + ${PYTHON_DEPS}
418 + systemtap? ( dev-util/systemtap )
419 + test? ( net-misc/curl )"
420 +
421 +S="${WORKDIR}/node-v${PV}"
422 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
423 +
424 +PATCHES=(
425 + "${FILESDIR}"/gentoo-global-npm-config.patch
426 + "${FILESDIR}"/nodejs-8.7.0-shared-nghttp2.patch
427 +)
428 +
429 +pkg_pretend() {
430 + (use x86 && ! use cpu_flags_x86_sse2) && \
431 + die "Your CPU doesn't support the required SSE2 instruction."
432 +
433 + ( [[ ${MERGE_TYPE} != "binary" ]] && ! test-flag-CXX -std=c++11 ) && \
434 + die "Your compiler doesn't support C++11. Use GCC 4.8, Clang 3.3 or newer."
435 +}
436 +
437 +src_prepare() {
438 + tc-export CC CXX PKG_CONFIG
439 + export V=1
440 + export BUILDTYPE=Release
441 +
442 + # fix compilation on Darwin
443 + # https://code.google.com/p/gyp/issues/detail?id=260
444 + sed -i -e "/append('-arch/d" tools/gyp/pylib/gyp/xcode_emulation.py || die
445 +
446 + # make sure we use python2.* while using gyp
447 + sed -i -e "s/python/${EPYTHON}/" deps/npm/node_modules/node-gyp/gyp/gyp || die
448 + sed -i -e "s/|| 'python'/|| '${EPYTHON}'/" deps/npm/node_modules/node-gyp/lib/configure.js || die
449 +
450 + # less verbose install output (stating the same as portage, basically)
451 + sed -i -e "/print/d" tools/install.py || die
452 +
453 + # proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
454 + local LIBDIR=$(get_libdir)
455 + sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
456 + sed -i -e "s/'lib'/'${LIBDIR}'/" lib/module.js || die
457 + sed -i -e "s|\"lib\"|\"${LIBDIR}\"|" deps/npm/lib/npm.js || die
458 +
459 + # Avoid writing a depfile, not useful
460 + sed -i -e "/DEPFLAGS =/d" tools/gyp/pylib/gyp/generator/make.py || die
461 +
462 + # Avoid a test that I've only been able to reproduce from emerge. It doesnt
463 + # seem sandbox related either (invoking it from a sandbox works fine).
464 + # The issue is that no stdin handle is openened when asked for one.
465 + # It doesn't really belong upstream , so it'll just be removed until someone
466 + # with more gentoo-knowledge than me (jbergstroem) figures it out.
467 + rm test/parallel/test-stdout-close-unref.js || die
468 +
469 + # debug builds. change install path, remove optimisations and override buildtype
470 + if use debug; then
471 + sed -i -e "s|out/Release/|out/Debug/|g" tools/install.py || die
472 + BUILDTYPE=Debug
473 + fi
474 +
475 + default
476 +}
477 +
478 +src_configure() {
479 + local myarch=""
480 + local myconf=( --shared-http-parser --shared-libuv --shared-nghttp2 --shared-openssl --shared-zlib )
481 + use npm || myconf+=( --without-npm )
482 + use icu && myconf+=( --with-intl=system-icu )
483 + use snapshot && myconf+=( --with-snapshot )
484 + use ssl || myconf+=( --without-ssl )
485 + use debug && myconf+=( --debug )
486 +
487 + case ${ABI} in
488 + amd64) myarch="x64";;
489 + arm) myarch="arm";;
490 + arm64) myarch="arm64";;
491 + ppc64) myarch="ppc64";;
492 + x32) myarch="x32";;
493 + x86) myarch="ia32";;
494 + *) myarch="${ABI}";;
495 + esac
496 +
497 + GYP_DEFINES="linux_use_gold_flags=0
498 + linux_use_bundled_binutils=0
499 + linux_use_bundled_gold=0" \
500 + "${PYTHON}" configure \
501 + --prefix="${EPREFIX}"/usr \
502 + --dest-cpu=${myarch} \
503 + $(use_with systemtap dtrace) \
504 + "${myconf[@]}" || die
505 +}
506 +
507 +src_compile() {
508 + emake -C out mksnapshot
509 + pax-mark m "out/${BUILDTYPE}/mksnapshot"
510 + emake -C out
511 +}
512 +
513 +src_install() {
514 + local LIBDIR="${ED}/usr/$(get_libdir)"
515 + emake install DESTDIR="${D}"
516 + pax-mark -m "${ED}"usr/bin/node
517 +
518 + # set up a symlink structure that node-gyp expects..
519 + dodir /usr/include/node/deps/{v8,uv}
520 + dosym . /usr/include/node/src
521 + for var in deps/{uv,v8}/include; do
522 + dosym ../.. /usr/include/node/${var}
523 + done
524 +
525 + if use doc; then
526 + # Patch docs to make them offline readable
527 + for i in `grep -rl 'fonts.googleapis.com' "${S}"/out/doc/api/*`; do
528 + sed -i '/fonts.googleapis.com/ d' $i;
529 + done
530 + # Install docs!
531 + dohtml -r "${S}"/doc/*
532 + fi
533 +
534 + if use npm; then
535 + dodir /etc/npm
536 +
537 + # Install bash completion for `npm`
538 + # We need to temporarily replace default config path since
539 + # npm otherwise tries to write outside of the sandbox
540 + local npm_config="usr/$(get_libdir)/node_modules/npm/lib/config/core.js"
541 + sed -i -e "s|'/etc'|'${ED}/etc'|g" "${ED}/${npm_config}" || die
542 + local tmp_npm_completion_file="$(emktemp)"
543 + "${ED}/usr/bin/npm" completion > "${tmp_npm_completion_file}"
544 + newbashcomp "${tmp_npm_completion_file}" npm
545 + sed -i -e "s|'${ED}/etc'|'/etc'|g" "${ED}/${npm_config}" || die
546 +
547 + # Move man pages
548 + doman "${LIBDIR}"/node_modules/npm/man/man{1,5,7}/*
549 +
550 + # Clean up
551 + rm "${LIBDIR}"/node_modules/npm/{.mailmap,.npmignore,Makefile} || die
552 + rm -rf "${LIBDIR}"/node_modules/npm/{doc,html,man} || die
553 +
554 + local find_exp="-or -name"
555 + local find_name=()
556 + for match in "AUTHORS*" "CHANGELOG*" "CONTRIBUT*" "README*" \
557 + ".travis.yml" ".eslint*" ".wercker.yml" ".npmignore" \
558 + "*.md" "*.markdown" "*.bat" "*.cmd"; do
559 + find_name+=( ${find_exp} "${match}" )
560 + done
561 +
562 + # Remove various development and/or inappropriate files and
563 + # useless docs of dependend packages.
564 + find "${LIBDIR}"/node_modules \
565 + \( -type d -name examples \) -or \( -type f \( \
566 + -iname "LICEN?E*" \
567 + "${find_name[@]}" \
568 + \) \) -exec rm -rf "{}" \;
569 + fi
570 +}
571 +
572 +src_test() {
573 + out/${BUILDTYPE}/cctest || die
574 + "${PYTHON}" tools/test.py --mode=${BUILDTYPE,,} -J message parallel sequential || die
575 +}
576 +
577 +pkg_postinst() {
578 + einfo "The global npm config lives in /etc/npm. This deviates slightly"
579 + einfo "from upstream which otherwise would have it live in /usr/etc/."
580 + einfo ""
581 + einfo "Protip: When using node-gyp to install native modules, you can"
582 + einfo "avoid having to download extras by doing the following:"
583 + einfo "$ node-gyp --nodedir /usr/include/node <command>"
584 +}