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