summaryrefslogtreecommitdiff
path: root/net-libs
diff options
context:
space:
mode:
Diffstat (limited to 'net-libs')
-rw-r--r--net-libs/nodejs/Manifest1
-rw-r--r--net-libs/nodejs/nodejs-18.20.7.ebuild257
2 files changed, 258 insertions, 0 deletions
diff --git a/net-libs/nodejs/Manifest b/net-libs/nodejs/Manifest
new file mode 100644
index 0000000..6174a17
--- /dev/null
+++ b/net-libs/nodejs/Manifest
@@ -0,0 +1 @@
DIST node-v18.20.7.tar.xz 40631764 BLAKE2B 480577e2b749f9c00eb381ba1bc0a9584a9850f75ef3c9b9c3a18cbbaeafb03c588ead443afb31b28be077a43539d3a577e37735af2e314dba003f9f9c94ef5b SHA512 13eda85918e4c92079c0bcbae6b4daa100a224d521940772ffd2d10b4fc1d90c98b3bb625435a3e257058e76b061a4958d3481241a218115f6cf2b10d939125c
diff --git a/net-libs/nodejs/nodejs-18.20.7.ebuild b/net-libs/nodejs/nodejs-18.20.7.ebuild
new file mode 100644
index 0000000..f29784b
--- /dev/null
+++ b/net-libs/nodejs/nodejs-18.20.7.ebuild
@@ -0,0 +1,257 @@
1# Copyright 1999-2025 Gentoo Authors
2# Distributed under the terms of the GNU General Public License v2
3
4EAPI=8
5
6CONFIG_CHECK="~ADVISE_SYSCALLS"
7PYTHON_COMPAT=( python3_{10..13} )
8PYTHON_REQ_USE="threads(+)"
9
10inherit bash-completion-r1 check-reqs flag-o-matic linux-info pax-utils python-any-r1 toolchain-funcs xdg-utils
11
12DESCRIPTION="A JavaScript runtime built on Chrome's V8 JavaScript engine"
13HOMEPAGE="https://nodejs.org/"
14LICENSE="Apache-1.1 Apache-2.0 BSD BSD-2 MIT"
15
16if [[ ${PV} == *9999 ]]; then
17 inherit git-r3
18 EGIT_REPO_URI="https://github.com/nodejs/node"
19 SLOT="0"
20else
21 SRC_URI="https://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz"
22 SLOT="0/$(ver_cut 1)"
23 KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86 ~amd64-linux ~x64-macos"
24 S="${WORKDIR}/node-v${PV}"
25fi
26
27IUSE="corepack cpu_flags_x86_sse2 debug doc +icu inspector lto npm pax-kernel +snapshot +ssl +system-icu +system-ssl systemtap test"
28REQUIRED_USE="inspector? ( icu ssl )
29 npm? ( ssl )
30 system-icu? ( icu )
31 system-ssl? ( ssl )"
32
33RESTRICT="!test? ( test )"
34
35RDEPEND=">=app-arch/brotli-1.0.9:=
36 >=dev-libs/libuv-1.44.0:=
37 >=net-dns/c-ares-1.18.1:=
38 >=net-libs/nghttp2-1.41.0:=
39 sys-libs/zlib
40 corepack? ( !sys-apps/yarn )
41 system-icu? ( >=dev-libs/icu-73:= )
42 system-ssl? ( >=dev-libs/openssl-1.1.1:0= )
43 sys-devel/gcc:*"
44BDEPEND="${PYTHON_DEPS}
45 sys-apps/coreutils
46 virtual/pkgconfig
47 systemtap? ( dev-debug/systemtap )
48 test? ( net-misc/curl )
49 pax-kernel? ( sys-apps/elfix )"
50DEPEND="${RDEPEND}"
51
52# These are measured on a loong machine with -ggdb on, and only checked
53# if debugging flags are present in CFLAGS.
54#
55# The final link consumed a little more than 7GiB alone, so 8GiB is the lower
56# limit for memory usage. Disk usage was 19.1GiB for the build directory and
57# 1.2GiB for the installed image, so we leave some room for architectures with
58# fatter binaries and set the disk requirement to 22GiB.
59CHECKREQS_MEMORY="8G"
60CHECKREQS_DISK_BUILD="22G"
61
62pkg_pretend() {
63 (use x86 && ! use cpu_flags_x86_sse2) && \
64 die "Your CPU doesn't support the required SSE2 instruction."
65
66 if [[ ${MERGE_TYPE} != "binary" ]]; then
67 if is-flagq "-g*" && ! is-flagq "-g*0" ; then
68 einfo "Checking for sufficient disk space and memory to build ${PN} with debugging CFLAGS"
69 check-reqs_pkg_pretend
70 fi
71 fi
72}
73
74pkg_setup() {
75 python-any-r1_pkg_setup
76 linux-info_pkg_setup
77}
78
79src_prepare() {
80 tc-export AR CC CXX PKG_CONFIG
81 export V=1
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 # proper libdir, hat tip @ryanpcmcquen https://github.com/iojs/io.js/issues/504
89 local LIBDIR=$(get_libdir)
90 sed -i -e "s|lib/|${LIBDIR}/|g" tools/install.py || die
91 sed -i -e "s/'lib'/'${LIBDIR}'/" deps/npm/lib/npm.js || die
92
93 # Avoid writing a depfile, not useful
94 sed -i -e "/DEPFLAGS =/d" tools/gyp/pylib/gyp/generator/make.py || die
95
96 sed -i -e "/'-O3'/d" common.gypi node.gypi || die
97
98 # debug builds. change install path, remove optimisations and override buildtype
99 if use debug; then
100 sed -i -e "s|out/Release/|out/Debug/|g" tools/install.py || die
101 BUILDTYPE=Debug
102 fi
103
104 # We need to disable mprotect on two files when it builds Bug 694100.
105 use pax-kernel && PATCHES+=( "${FILESDIR}"/${PN}-18.16.0-paxmarking.patch )
106
107 default
108}
109
110src_configure() {
111 xdg_environment_reset
112
113 # LTO compiler flags are handled by configure.py itself
114 filter-lto
115 # nodejs unconditionally links to libatomic #869992
116 # specifically it requires __atomic_is_lock_free which
117 # is not yet implemented by llvm-runtimes/compiler-rt (see
118 # https://reviews.llvm.org/D85044?id=287068), therefore
119 # we depend on gcc and force using libgcc as the support lib
120 tc-is-clang && append-ldflags "--rtlib=libgcc --unwindlib=libgcc"
121
122 local myconf=(
123 --shared-brotli
124 --shared-cares
125 --shared-libuv
126 --shared-nghttp2
127 --shared-zlib
128 )
129 use debug && myconf+=( --debug )
130 use lto && myconf+=( --enable-lto )
131 if use system-icu; then
132 myconf+=( --with-intl=system-icu )
133 elif use icu; then
134 myconf+=( --with-intl=full-icu )
135 else
136 myconf+=( --with-intl=none )
137 fi
138 use corepack || myconf+=( --without-corepack )
139 use inspector || myconf+=( --without-inspector )
140 use npm || myconf+=( --without-npm )
141 use snapshot || myconf+=( --without-node-snapshot )
142 if use ssl; then
143 use system-ssl && myconf+=( --shared-openssl --openssl-use-def-ca-store )
144 else
145 myconf+=( --without-ssl )
146 fi
147
148 local myarch=""
149 case "${ARCH}:${ABI}" in
150 *:amd64) myarch="x64";;
151 *:arm) myarch="arm";;
152 *:arm64) myarch="arm64";;
153 loong:lp64*) myarch="loong64";;
154 riscv:lp64*) myarch="riscv64";;
155 *:ppc64) myarch="ppc64";;
156 *:x32) myarch="x32";;
157 *:x86) myarch="ia32";;
158 *) myarch="${ABI}";;
159 esac
160
161 GYP_DEFINES="linux_use_gold_flags=0
162 linux_use_bundled_binutils=0
163 linux_use_bundled_gold=0" \
164 "${EPYTHON}" configure.py \
165 --prefix="${EPREFIX}"/usr \
166 --dest-cpu=${myarch} \
167 $(use_with systemtap dtrace) \
168 "${myconf[@]}" || die
169}
170
171src_compile() {
172 emake -C out -Onone
173}
174
175src_install() {
176 local LIBDIR="${ED}/usr/$(get_libdir)"
177 default
178
179 pax-mark -m "${ED}"/usr/bin/node
180
181 # set up a symlink structure that node-gyp expects..
182 dodir /usr/include/node/deps/{v8,uv}
183 dosym . /usr/include/node/src
184 for var in deps/{uv,v8}/include; do
185 dosym ../.. /usr/include/node/${var}
186 done
187
188 if use doc; then
189 docinto html
190 dodoc -r "${S}"/doc/*
191 fi
192
193 if use npm; then
194 keepdir /etc/npm
195 echo "NPM_CONFIG_GLOBALCONFIG=${EPREFIX}/etc/npm/npmrc" > "${T}"/50npm
196 doenvd "${T}"/50npm
197
198 # Install bash completion for `npm`
199 local tmp_npm_completion_file="$(TMPDIR="${T}" mktemp -t npm.XXXXXXXXXX)"
200 "${ED}/usr/bin/npm" completion > "${tmp_npm_completion_file}"
201 newbashcomp "${tmp_npm_completion_file}" npm
202
203 # Move man pages
204 doman "${LIBDIR}"/node_modules/npm/man/man{1,5,7}/*
205
206 # Clean up
207 rm -f "${LIBDIR}"/node_modules/npm/{.mailmap,.npmignore,Makefile}
208 rm -rf "${LIBDIR}"/node_modules/npm/{doc,html,man}
209
210 local find_exp="-or -name"
211 local find_name=()
212 for match in "AUTHORS*" "CHANGELOG*" "CONTRIBUT*" "README*" \
213 ".travis.yml" ".eslint*" ".wercker.yml" ".npmignore" \
214 "*.md" "*.markdown" "*.bat" "*.cmd"; do
215 find_name+=( ${find_exp} "${match}" )
216 done
217
218 # Remove various development and/or inappropriate files and
219 # useless docs of dependend packages.
220 find "${LIBDIR}"/node_modules \
221 \( -type d -name examples \) -or \( -type f \( \
222 -iname "LICEN?E*" \
223 "${find_name[@]}" \
224 \) \) -exec rm -rf "{}" \;
225 fi
226
227 use corepack &&
228 "${D}"/usr/bin/corepack enable --install-directory "${D}"/usr/bin
229
230 mv "${ED}"/usr/share/doc/node "${ED}"/usr/share/doc/${PF} || die
231}
232
233src_test() {
234 local drop_tests=(
235 test/parallel/test-dns.js
236 test/parallel/test-dns-resolveany.js
237 test/parallel/test-dns-resolveany-bad-ancount.js
238 test/parallel/test-dns-setserver-when-querying.js
239 test/parallel/test-fs-mkdir.js
240 test/parallel/test-fs-utimes-y2K38.js
241 test/parallel/test-release-npm.js
242 test/parallel/test-socket-write-after-fin-error.js
243 test/parallel/test-strace-openat-openssl.js
244 test/sequential/test-util-debug.js
245 )
246 rm -f "${drop_tests[@]}" || die "disabling tests failed"
247
248 out/${BUILDTYPE}/cctest || die
249 "${EPYTHON}" tools/test.py --mode=${BUILDTYPE,,} --flaky-tests=dontcare -J message parallel sequential || die
250}
251
252pkg_postinst() {
253 if use npm; then
254 ewarn "remember to run: source /etc/profile if you plan to use nodejs"
255 ewarn " in your current shell"
256 fi
257}