Skip to content

Commit 483ed9c

Browse files
committed
nodejs-26: rewrite build script, support stage 2 build
1 parent 19363c1 commit 483ed9c

6 files changed

Lines changed: 203 additions & 56 deletions

File tree

lang-js/nodejs-26/autobuild/beyond

Lines changed: 0 additions & 18 deletions
This file was deleted.

lang-js/nodejs-26/autobuild/build

Lines changed: 81 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,62 @@
1+
function replace_string() {
2+
dst=$3
3+
checksum_before_replace=$(sha256sum "$3")
4+
if [[ $# -gt 3 ]]; then
5+
dst=$4
6+
argv+=("$3")
7+
sed -e "s|$1|$2|" "$3" > "$dst"
8+
else
9+
sed -e "s|$1|$2|" -i "$3"
10+
fi
11+
checksum_after_replace=$(sha256sum "$dst")
12+
13+
if [[ "$checksum_before_replace" == "$checksum_after_replace" ]]; then
14+
abwarn "Replaced nothing, aborting ..."
15+
abinfo "Content of $3 :"
16+
cat "$3"
17+
exit 1
18+
fi
19+
}
20+
121
#### Control part variable.
2-
_NODE_PREFIX=/usr/lib/node-${PKGVER%%.*}
22+
NODE_PREFIX=/usr/lib/node-${PKGVER%%.*}
323

424
abinfo "Configuring Node.js ..."
5-
export WITHOUT_LIEF=""
25+
ARGV=(
26+
"--prefix=$NODE_PREFIX"
27+
"--ninja"
28+
"--shared-ada"
29+
"--shared-brotli"
30+
"--shared-cares"
31+
"--shared-ffi"
32+
"--shared-hdr-histogram"
33+
"--shared-http-parser"
34+
"--shared-libuv"
35+
"--shared-nghttp2"
36+
"--shared-nghttp3"
37+
"--shared-ngtcp2"
38+
"--shared-openssl"
39+
"--shared-simdutf"
40+
"--shared-sqlite"
41+
"--shared-zstd"
42+
"--shared-zlib"
43+
"--with-intl=full-icu"
44+
"--with-corepack"
45+
"--v8-enable-temporal-support"
46+
)
47+
648
if ab_match_arch loongson3; then
7-
# FIXME:
8-
# ../deps/LIEF/include/LIEF/asm/mips/opcodes.hpp:22:11: error: expected identifier or '{'
9-
# 22 | namespace mips {
10-
# | ^
11-
# <built-in>:420:14: note: expanded from macro 'mips'
49+
# FIXME:
50+
# ../deps/LIEF/include/LIEF/asm/mips/opcodes.hpp:22:11: error: expected identifier or '{'
51+
# 22 | namespace mips {
52+
# | ^
53+
# <built-in>:420:14: note: expanded from macro 'mips'
1254
abinfo "Disabling LIEF for loongson3 ..."
13-
export WITHOUT_LIEF="--without-lief"
55+
ARGV+=("--without-lief")
1456
fi
1557
# FIXME: According to https://github.com/nodejs/node/issues/62676
1658
# Use bundled icu for now until v8 has fixed the problem
17-
"$SRCDIR"/configure \
18-
--prefix=${_NODE_PREFIX} \
19-
--ninja \
20-
--shared-ada \
21-
--shared-brotli \
22-
--shared-cares \
23-
--shared-ffi \
24-
--shared-hdr-histogram \
25-
--shared-http-parser \
26-
--shared-libuv \
27-
--shared-nghttp2 \
28-
--shared-nghttp3 \
29-
--shared-ngtcp2 \
30-
--shared-openssl \
31-
--shared-simdutf \
32-
--shared-sqlite \
33-
--shared-zstd \
34-
--shared-zlib \
35-
--with-intl=full-icu \
36-
--with-corepack \
37-
--v8-enable-temporal-support \
38-
$WITHOUT_LIEF \
39-
$NODE_FLAGS_ARCH
59+
"$SRCDIR"/configure "${ARGV[@]}"
4060

4161
abinfo "Building Node.js ..."
4262
make "$MAKEFLAGS"
@@ -47,12 +67,35 @@ make install \
4767

4868
abinfo "Installing node-gyp ..."
4969
install -Dvm755 \
50-
"$PKGDIR"/${_NODE_PREFIX}/lib/node_modules/npm/bin/node-gyp-bin/node-gyp \
51-
"$PKGDIR"/${_NODE_PREFIX}/bin/node-gyp
52-
sed -e 's|"`dirname "$0"`/../../|"`dirname "$0"`/../lib/node-${PKGVER%%.*}/lib/node_modules/npm/|' \
53-
-i "$PKGDIR"/${_NODE_PREFIX}/bin/node-gyp
70+
"$PKGDIR"/"$NODE_PREFIX"/lib/node_modules/npm/bin/node-gyp-bin/node-gyp \
71+
"$PKGDIR"/"$NODE_PREFIX"/bin/node-gyp
72+
73+
# Note:
74+
# original line is:
75+
# node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@"
76+
# see https://github.com/npm/cli/blob/eacec5f49060d3dfcdc3c7043115619e4bb22864/bin/node-gyp-bin/node-gyp#L3
77+
# should replace to:
78+
# node /usr/lib/node-%version%/lib/node_modules/npm/node_modules/node-gyp/bin//node-gyp.js "$@"
79+
# intentionally use single quote for literal
80+
# shellcheck disable=SC2016
81+
original_gyp_path='"`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js"'
82+
actual_gyp_path="$NODE_PREFIX/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
83+
replace_string "$original_gyp_path" "$actual_gyp_path" "$PKGDIR"/"$NODE_PREFIX"/bin/node-gyp
5484

5585
abinfo "Creating Corepack shims..."
56-
PATH="$PATH:"$PKGDIR"/${_NODE_PREFIX}/bin" \
57-
"$PKGDIR"/${_NODE_PREFIX}/bin/corepack \
58-
enable
86+
PATH="$PATH:$PKGDIR/$NODE_PREFIX/bin" \
87+
"$PKGDIR"/"$NODE_PREFIX"/bin/corepack \
88+
enable
89+
90+
abinfo "Generating postinst scripts ..."
91+
echo "update-alternatives --install /usr/bin/node node $NODE_PREFIX/bin/node 50 \\" > "$SRCDIR/autobuild/postinst"
92+
for i in "$PKGDIR/$NODE_PREFIX/bin/"*; do
93+
BIN="$(basename "$i")"
94+
if [[ "$BIN" == "node" ]]; then
95+
continue
96+
fi
97+
echo " --slave /usr/bin/$BIN $BIN $NODE_PREFIX/bin/$BIN \\" >> "$SRCDIR/autobuild/postinst"
98+
done
99+
echo "" >> "$SRCDIR/autobuild/postinst"
100+
101+
replace_string %PFX% "$NODE_PREFIX" "$SRCDIR"/autobuild/postrm.in "$SRCDIR"/autobuild/postrm
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
function replace_string() {
2+
dst=$3
3+
checksum_before_replace=$(sha256sum "$3")
4+
if [[ $# -gt 3 ]]; then
5+
dst=$4
6+
argv+=("$3")
7+
sed -e "s|$1|$2|" "$3" > "$dst"
8+
else
9+
sed -e "s|$1|$2|" -i "$3"
10+
fi
11+
checksum_after_replace=$(sha256sum "$dst")
12+
13+
if [[ "$checksum_before_replace" == "$checksum_after_replace" ]]; then
14+
abwarn "Replaced nothing, aborting ..."
15+
abinfo "Content of $3 :"
16+
cat "$3"
17+
exit 1
18+
fi
19+
}
20+
21+
#### Control part variable.
22+
NODE_PREFIX=/usr/lib/node-${PKGVER%%.*}
23+
24+
abinfo "Configuring Node.js ..."
25+
ARGV=(
26+
"--prefix=$NODE_PREFIX"
27+
"--ninja"
28+
"--shared-ada"
29+
"--shared-brotli"
30+
"--shared-cares"
31+
"--shared-ffi"
32+
"--shared-hdr-histogram"
33+
# "--shared-http-parser" # llhttp depends on nodejs
34+
"--shared-libuv"
35+
"--shared-nghttp2"
36+
"--shared-nghttp3"
37+
"--shared-ngtcp2"
38+
"--shared-openssl"
39+
"--shared-simdutf"
40+
"--shared-sqlite"
41+
"--shared-zstd"
42+
"--shared-zlib"
43+
"--with-intl=full-icu"
44+
"--with-corepack"
45+
"--v8-enable-temporal-support"
46+
)
47+
48+
if ab_match_arch loongson3; then
49+
# FIXME:
50+
# ../deps/LIEF/include/LIEF/asm/mips/opcodes.hpp:22:11: error: expected identifier or '{'
51+
# 22 | namespace mips {
52+
# | ^
53+
# <built-in>:420:14: note: expanded from macro 'mips'
54+
abinfo "Disabling LIEF for loongson3 ..."
55+
ARGV+=("--without-lief")
56+
fi
57+
# FIXME: According to https://github.com/nodejs/node/issues/62676
58+
# Use bundled icu for now until v8 has fixed the problem
59+
"$SRCDIR"/configure "${ARGV[@]}"
60+
61+
abinfo "Building Node.js ..."
62+
make "$MAKEFLAGS"
63+
64+
abinfo "Installing Node.js ..."
65+
make install \
66+
DESTDIR="$PKGDIR"
67+
68+
abinfo "Installing node-gyp ..."
69+
install -Dvm755 \
70+
"$PKGDIR"/"$NODE_PREFIX"/lib/node_modules/npm/bin/node-gyp-bin/node-gyp \
71+
"$PKGDIR"/"$NODE_PREFIX"/bin/node-gyp
72+
73+
# Note:
74+
# original line is:
75+
# node "`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js" "$@"
76+
# see https://github.com/npm/cli/blob/eacec5f49060d3dfcdc3c7043115619e4bb22864/bin/node-gyp-bin/node-gyp#L3
77+
# should replace to:
78+
# node /usr/lib/node-%version%/lib/node_modules/npm/node_modules/node-gyp/bin//node-gyp.js "$@"
79+
# intentionally use single quote for literal
80+
# shellcheck disable=SC2016
81+
original_gyp_path='"`dirname "$0"`/../../node_modules/node-gyp/bin/node-gyp.js"'
82+
actual_gyp_path="$NODE_PREFIX/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
83+
replace_string "$original_gyp_path" "$actual_gyp_path" "$PKGDIR"/"$NODE_PREFIX"/bin/node-gyp
84+
85+
abinfo "Creating Corepack shims..."
86+
PATH="$PATH:$PKGDIR/$NODE_PREFIX/bin" \
87+
"$PKGDIR"/"$NODE_PREFIX"/bin/corepack \
88+
enable
89+
90+
abinfo "Generating postinst scripts ..."
91+
echo "update-alternatives --install /usr/bin/node node $NODE_PREFIX/bin/node 50 \\" > "$SRCDIR/autobuild/postinst"
92+
for i in "$PKGDIR/$NODE_PREFIX/bin/"*; do
93+
BIN="$(basename "$i")"
94+
if [[ "$BIN" == "node" ]]; then
95+
continue
96+
fi
97+
echo " --slave /usr/bin/$BIN $BIN $NODE_PREFIX/bin/$BIN \\" >> "$SRCDIR/autobuild/postinst"
98+
done
99+
echo "" >> "$SRCDIR/autobuild/postinst"
100+
101+
replace_string %PFX% "$NODE_PREFIX" "$SRCDIR"/autobuild/postrm.in "$SRCDIR"/autobuild/postrm
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
PKGNAME=nodejs-26
2+
PKGSEC=devel
3+
# FIXME: ICU is now bundled into nodejs-26, see buildscript
4+
PKGDEP="zlib brotli libuv openssl ca-certs nghttp2 nghttp3 ngtcp2 sqlite zstd ada libffi simdutf hdrhistogram-c"
5+
BUILDDEP="python-3 rustc llvm"
6+
PKGDES="JavaScript runtime built on the V8 JavaScript engine (Current branch 26.x)"
7+
8+
ABTYPE=self
9+
10+
# https://github.com/nodejs/node/issues/44195#issuecomment-1545966528
11+
NOLTO=1
12+
13+
# https://github.com/nodejs/node/blob/9027f29e6d5de49842905d0ed082ad5907e80d78/common.gypi#L503
14+
AB_FLAGS_EXC=0
15+
16+
# FIXME: a lot of errors in LIEF, v8 and highway
17+
USECLANG=1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if [ "\$1" != "upgrade" ]; then
2+
update-alternatives --remove node %PFX%/bin/node || true
3+
fi

lang-js/nodejs-26/spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
VER=26.7.0
2+
REL=1
23
SRCS="git::commit=tags/v$VER::https://github.com/nodejs/node"
34
CHKSUMS="SKIP"
45
CHKUPDATE="anitya::id=8251"

0 commit comments

Comments
 (0)