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
424abinfo "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+
648if 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")
1456fi
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
4161abinfo "Building Node.js ..."
4262make "$MAKEFLAGS"
@@ -47,12 +67,35 @@ make install \
4767
4868abinfo "Installing node-gyp ..."
4969install -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
5585abinfo "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
0 commit comments