remove bundled WASM blobs

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Jan Staněk 2023-11-21 15:53:31 +00:00 committed by Stephen Gallagher
parent f523665c4d
commit ed578ec737
4 changed files with 41 additions and 104 deletions

View File

@ -6,7 +6,6 @@
# ARG_POSITIONAL_SINGLE([version],[Node.js release version]) # ARG_POSITIONAL_SINGLE([version],[Node.js release version])
# ARG_OPTIONAL_BOOLEAN([push],[],[Whether to upload to the lookaside cache],[on]) # ARG_OPTIONAL_BOOLEAN([push],[],[Whether to upload to the lookaside cache],[on])
# ARG_OPTIONAL_BOOLEAN([debug],[],[Print all commands],[off]) # ARG_OPTIONAL_BOOLEAN([debug],[],[Print all commands],[off])
# ARG_OPTIONAL_SINGLE([undici-wasi-sdk-version],[],[Override the wasi-sdk version for undici])
# ARG_DEFAULTS_POS([]) # ARG_DEFAULTS_POS([])
# ARG_HELP([Tool to aid in Node.js packaging of new releases]) # ARG_HELP([Tool to aid in Node.js packaging of new releases])
# ARGBASH_GO() # ARGBASH_GO()
@ -38,17 +37,15 @@ _arg_version=
# THE DEFAULTS INITIALIZATION - OPTIONALS # THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_push="on" _arg_push="on"
_arg_debug="off" _arg_debug="off"
_arg_undici_wasi_sdk_version=
print_help() print_help()
{ {
printf '%s\n' "Tool to aid in Node.js packaging of new releases" printf '%s\n' "Tool to aid in Node.js packaging of new releases"
printf 'Usage: %s [--(no-)push] [--(no-)debug] [--undici-wasi-sdk-version <arg>] [-h|--help] <version>\n' "$0" printf 'Usage: %s [--(no-)push] [--(no-)debug] [-h|--help] <version>\n' "$0"
printf '\t%s\n' "<version>: Node.js release version" printf '\t%s\n' "<version>: Node.js release version"
printf '\t%s\n' "--push, --no-push: Whether to upload to the lookaside cache (on by default)" printf '\t%s\n' "--push, --no-push: Whether to upload to the lookaside cache (on by default)"
printf '\t%s\n' "--debug, --no-debug: Print all commands (off by default)" printf '\t%s\n' "--debug, --no-debug: Print all commands (off by default)"
printf '\t%s\n' "--undici-wasi-sdk-version: Override the wasi-sdk version for undici (no default)"
printf '\t%s\n' "-h, --help: Prints help" printf '\t%s\n' "-h, --help: Prints help"
} }
@ -68,14 +65,6 @@ parse_commandline()
_arg_debug="on" _arg_debug="on"
test "${1:0:5}" = "--no-" && _arg_debug="off" test "${1:0:5}" = "--no-" && _arg_debug="off"
;; ;;
--undici-wasi-sdk-version)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_undici_wasi_sdk_version="$2"
shift
;;
--undici-wasi-sdk-version=*)
_arg_undici_wasi_sdk_version="${_key##--undici-wasi-sdk-version=}"
;;
-h|--help) -h|--help)
print_help print_help
exit 0 exit 0
@ -183,43 +172,11 @@ tar -zxf node-v${version}.tar.gz
rm -rf node-v${version}/deps/openssl rm -rf node-v${version}/deps/openssl
tar -zcf node-v${version}-stripped.tar.gz node-v${version} tar -zcf node-v${version}-stripped.tar.gz node-v${version}
# Download the cjs-module-lexer sources # Record the bundled cjs-module-lexer version
LEXER_VERSION=$(jq -r '.version' node-v${version}/deps/cjs-module-lexer/package.json) LEXER_VERSION=$(jq -r '.version' node-v${version}/deps/cjs-module-lexer/package.json)
wget https://github.com/nodejs/cjs-module-lexer/archive/refs/tags/${LEXER_VERSION}.tar.gz
tar -zxf ${LEXER_VERSION}.tar.gz
rm -f cjs-module-lexer-${LEXER_VERSION}/lib/lexer.wasm
tar -zcf cjs-module-lexer-${LEXER_VERSION}-stripped.tar.gz cjs-module-lexer-${LEXER_VERSION}/
rm -f ${LEXER_VERSION}.tar.gz
# Download the WASI compiler used to build cjs-module-lexer # Record the bundled undici version
LEXER_WASI_MAJOR=$(grep -oP '(?<=^\W../wasi-sdk-)\d+\.\d+' cjs-module-lexer-${LEXER_VERSION}/Makefile | cut -d'.' -f1)
LEXER_WASI_MINOR=$(grep -oP '(?<=^\W../wasi-sdk-)\d+\.\d+' cjs-module-lexer-${LEXER_VERSION}/Makefile | cut -d'.' -f2)
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${LEXER_WASI_MAJOR}/wasi-sdk-${LEXER_WASI_MAJOR}.${LEXER_WASI_MINOR}-linux.tar.gz
rm -rf cjs-module-lexer-${LEXER_VERSION}/
# Download the undici sources
UNDICI_VERSION=$(jq -r '.version' node-v${version}/deps/undici/src/package.json) UNDICI_VERSION=$(jq -r '.version' node-v${version}/deps/undici/src/package.json)
wget https://github.com/nodejs/undici/archive/refs/tags/v${UNDICI_VERSION}.tar.gz
tar -zxf v${UNDICI_VERSION}.tar.gz
rm -f undici-${UNDICI_VERSION}/lib/llhttp/llhttp*.wasm*
tar -zcf undici-${UNDICI_VERSION}-stripped.tar.gz undici-${UNDICI_VERSION}/
rm -f v${UNDICI_VERSION}.tar.gz
# Download the WASI compiler used to build undici
if [ -z $_arg_undici_wasi_sdk_version ]; then
UNDICI_WASI_MAJOR=$(grep -oP '(?<=WASI_SDK_VERSION_MAJOR=).*' undici-${UNDICI_VERSION}/build/Dockerfile)
UNDICI_WASI_MINOR=$(grep -oP '(?<=WASI_SDK_VERSION_MINOR=).*' undici-${UNDICI_VERSION}/build/Dockerfile)
else
OIFS=$IFS
IFS="."
UNDICI_WASI_VERSION=($_arg_undici_wasi_sdk_version)
UNDICI_WASI_MAJOR=${UNDICI_WASI_VERSION[0]}
UNDICI_WASI_MINOR=${UNDICI_WASI_VERSION[1]}
IFS=$OIFS
fi
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${UNDICI_WASI_MAJOR}/wasi-sdk-${UNDICI_WASI_MAJOR}.${UNDICI_WASI_MINOR}-linux.tar.gz
rm -rf undici-${UNDICI_VERSION}/
ICU_MAJOR=$(jq -r '.[0].url' node-v${version}/tools/icu/current_ver.dep | sed --expression='s/.*release-\([[:digit:]]\+\)-\([[:digit:]]\+\).*/\1/g') ICU_MAJOR=$(jq -r '.[0].url' node-v${version}/tools/icu/current_ver.dep | sed --expression='s/.*release-\([[:digit:]]\+\)-\([[:digit:]]\+\).*/\1/g')
ICU_MINOR=$(jq -r '.[0].url' node-v${version}/tools/icu/current_ver.dep | sed --expression='s/.*release-\([[:digit:]]\+\)-\([[:digit:]]\+\).*/\2/g') ICU_MINOR=$(jq -r '.[0].url' node-v${version}/tools/icu/current_ver.dep | sed --expression='s/.*release-\([[:digit:]]\+\)-\([[:digit:]]\+\).*/\2/g')
@ -310,12 +267,10 @@ echo
echo "cjs-module-lexer" echo "cjs-module-lexer"
echo "=========================" echo "========================="
echo "${LEXER_VERSION}" echo "${LEXER_VERSION}"
echo "WASI-SDK: ${LEXER_WASI_MAJOR}.${LEXER_WASI_MINOR}"
echo echo
echo "undici" echo "undici"
echo "=========================" echo "========================="
echo "${UNDICI_VERSION}" echo "${UNDICI_VERSION}"
echo "WASI-SDK: ${UNDICI_WASI_MAJOR}.${UNDICI_WASI_MINOR}"
echo echo
echo "ada" echo "ada"
echo "=========================" echo "========================="
@ -354,11 +309,7 @@ IFS='' read -r -d '' template_json <<EOF
"NPM_VERSION": $NPM_VERSION, "NPM_VERSION": $NPM_VERSION,
"ZLIB_VERSION": $ZLIB_VERSION, "ZLIB_VERSION": $ZLIB_VERSION,
"LEXER_VERSION": $LEXER_VERSION, "LEXER_VERSION": $LEXER_VERSION,
"LEXER_WASI_MAJOR": $LEXER_WASI_MAJOR,
"LEXER_WASI_MINOR": $LEXER_WASI_MINOR,
"UNDICI_VERSION": $UNDICI_VERSION, "UNDICI_VERSION": $UNDICI_VERSION,
"UNDICI_WASI_MAJOR": $UNDICI_WASI_MAJOR,
"UNDICI_WASI_MINOR": $UNDICI_WASI_MINOR,
"ADA_VERSION": $ADA_VERSION, "ADA_VERSION": $ADA_VERSION,
"PATCHES": $json_patchlist "PATCHES": $json_patchlist
} }

View File

@ -1,3 +1,6 @@
# Break circular dependencies
%bcond bootstrap 0
%if 0%{?rhel} && 0%{?rhel} < 8 %if 0%{?rhel} && 0%{?rhel} < 8
%bcond_without bundled_zlib %bcond_without bundled_zlib
%else %else
@ -139,15 +142,6 @@ Source201: npmrc.builtin.in
Source202: nodejs.pc.in Source202: nodejs.pc.in
Source203: v8.pc.in Source203: v8.pc.in
# These are full sources for dependencies included as WASM blobs in the source of Node itself.
# Note: These sources would also include pre-compiled WASM blobs… so they are adjusted not to.
# Recipes for creating these blobs are included in the sources.
# These are generated by nodejs-sources.sh
Source101: cjs-module-lexer-1.2.2-stripped.tar.gz
Source102: wasi-sdk-11.0-linux.tar.gz
Source111: undici-5.26.4-stripped.tar.gz
Source112: wasi-sdk-20.0-linux.tar.gz
Patch: 0001-Remove-unused-OpenSSL-config.patch Patch: 0001-Remove-unused-OpenSSL-config.patch
%if 0%{?nodejs_default} %if 0%{?nodejs_default}
@ -313,6 +307,15 @@ Provides: bundled(histogram) = %{histogram_version}
Provides: bundled(ada) = 2.7.2 Provides: bundled(ada) = 2.7.2
# undici and cjs-module-lexer ship with pre-built WASM binaries.
%if %{with bootstrap}
Provides: bundled(nodejs-cjs-module-lexer) = 1.2.2
Provides: bundled(nodejs-undici) = 5.26.4
%else
BuildRequires: nodejs-cjs-module-lexer nodejs-undici
Requires: nodejs-cjs-module-lexer nodejs-undici
%endif
%unversioned_obsoletes_of_nodejsXX_if_default %unversioned_obsoletes_of_nodejsXX_if_default
@ -477,21 +480,10 @@ rm -rf deps/brotli
rm -rf deps/v8/third_party/jinja2 rm -rf deps/v8/third_party/jinja2
rm -rf tools/inspector_protocol/jinja2 rm -rf tools/inspector_protocol/jinja2
# check for correct versions of dependencies we are bundling %if %{without bootstrap}
check_wasm_dep() { rm -rf deps/cjs-module-lexer
local -r name="$1" source="$2" packagejson="$3" rm -rf deps/undici
local -r expected_version="$(jq -r '.version' "${packagejson}")" %endif
if ls "${source}"|grep -q --fixed-strings "${expected_version}"; then
printf '%s version matches\n' "${name}" >&2
else
printf '%s version MISMATCH: %s !~ %s\n' "${name}" "${expected_version}" "${source}" >&2
return 1
fi
}
check_wasm_dep cjs-module-lexer '%{SOURCE101}' deps/cjs-module-lexer/package.json
check_wasm_dep undici '%{SOURCE111}' deps/undici/src/package.json
# Replace any instances of unversioned python with python3 # Replace any instances of unversioned python with python3
pfiles=( $(grep -rl python) ) pfiles=( $(grep -rl python) )
@ -553,6 +545,9 @@ export PATH="${cwd}/.bin:$PATH"
%{ssl_configure} \ %{ssl_configure} \
%{dtrace_configure} \ %{dtrace_configure} \
%{!?with_bundled_zlib:--shared-zlib} \ %{!?with_bundled_zlib:--shared-zlib} \
%{!?with_bootstrap:--shared-builtin-cjs_module_lexer/lexer-path %{nodejs_default_sitelib}/cjs-module-lexer/lexer.js} \
%{!?with_bootstrap:--shared-builtin-cjs_module_lexer/dist/lexer-path %{nodejs_default_sitelib}/cjs-module-lexer/dist/lexer.js} \
%{!?with_bootstrap:--shared-builtin-undici/undici-path %{nodejs_default_sitelib}/undici/index.js} \
--shared-brotli \ --shared-brotli \
--shared-libuv \ --shared-libuv \
--with-intl=small-icu \ --with-intl=small-icu \

View File

@ -1,3 +1,6 @@
# Break circular dependencies
%bcond bootstrap 0
%if 0%{?rhel} && 0%{?rhel} < 8 %if 0%{?rhel} && 0%{?rhel} < 8
%bcond_without bundled_zlib %bcond_without bundled_zlib
%else %else
@ -139,15 +142,6 @@ Source201: npmrc.builtin.in
Source202: nodejs.pc.in Source202: nodejs.pc.in
Source203: v8.pc.in Source203: v8.pc.in
# These are full sources for dependencies included as WASM blobs in the source of Node itself.
# Note: These sources would also include pre-compiled WASM blobs… so they are adjusted not to.
# Recipes for creating these blobs are included in the sources.
# These are generated by nodejs-sources.sh
Source101: cjs-module-lexer-{{ LEXER_VERSION }}-stripped.tar.gz
Source102: wasi-sdk-{{ LEXER_WASI_MAJOR }}.{{ LEXER_WASI_MINOR }}-linux.tar.gz
Source111: undici-{{ UNDICI_VERSION }}-stripped.tar.gz
Source112: wasi-sdk-{{ UNDICI_WASI_MAJOR }}.{{ UNDICI_WASI_MINOR }}-linux.tar.gz
{% for patch in PATCHES -%} {% for patch in PATCHES -%}
Patch: {{ patch }} Patch: {{ patch }}
{% endfor -%} {% endfor -%}
@ -325,6 +319,15 @@ Provides: bundled(histogram) = %{histogram_version}
Provides: bundled(ada) = {{ ADA_VERSION }} Provides: bundled(ada) = {{ ADA_VERSION }}
{% endif %} {% endif %}
# undici and cjs-module-lexer ship with pre-built WASM binaries.
%if %{with bootstrap}
Provides: bundled(nodejs-cjs-module-lexer) = {{ LEXER_VERSION }}
Provides: bundled(nodejs-undici) = {{ UNDICI_VERSION }}
%else
BuildRequires: nodejs-cjs-module-lexer nodejs-undici
Requires: nodejs-cjs-module-lexer nodejs-undici
%endif
%unversioned_obsoletes_of_nodejsXX_if_default %unversioned_obsoletes_of_nodejsXX_if_default
@ -489,21 +492,10 @@ rm -rf deps/brotli
rm -rf deps/v8/third_party/jinja2 rm -rf deps/v8/third_party/jinja2
rm -rf tools/inspector_protocol/jinja2 rm -rf tools/inspector_protocol/jinja2
# check for correct versions of dependencies we are bundling %if %{without bootstrap}
check_wasm_dep() { rm -rf deps/cjs-module-lexer
local -r name="$1" source="$2" packagejson="$3" rm -rf deps/undici
local -r expected_version="$(jq -r '.version' "${packagejson}")" %endif
if ls "${source}"|grep -q --fixed-strings "${expected_version}"; then
printf '%s version matches\n' "${name}" >&2
else
printf '%s version MISMATCH: %s !~ %s\n' "${name}" "${expected_version}" "${source}" >&2
return 1
fi
}
check_wasm_dep cjs-module-lexer '%{SOURCE101}' deps/cjs-module-lexer/package.json
check_wasm_dep undici '%{SOURCE111}' deps/undici/src/package.json
# Replace any instances of unversioned python with python3 # Replace any instances of unversioned python with python3
pfiles=( $(grep -rl python) ) pfiles=( $(grep -rl python) )
@ -565,6 +557,9 @@ export PATH="${cwd}/.bin:$PATH"
%{ssl_configure} \ %{ssl_configure} \
%{dtrace_configure} \ %{dtrace_configure} \
%{!?with_bundled_zlib:--shared-zlib} \ %{!?with_bundled_zlib:--shared-zlib} \
%{!?with_bootstrap:--shared-builtin-cjs_module_lexer/lexer-path %{nodejs_default_sitelib}/cjs-module-lexer/lexer.js} \
%{!?with_bootstrap:--shared-builtin-cjs_module_lexer/dist/lexer-path %{nodejs_default_sitelib}/cjs-module-lexer/dist/lexer.js} \
%{!?with_bootstrap:--shared-builtin-undici/undici-path %{nodejs_default_sitelib}/undici/index.js} \
--shared-brotli \ --shared-brotli \
--shared-libuv \ --shared-libuv \
--with-intl=small-icu \ --with-intl=small-icu \

View File

@ -1,7 +1,3 @@
SHA512 (node-v20.10.0-stripped.tar.gz) = aeab2855f2475e64d4d5453a641dd5998bdb42b5a78a600c903670f3d7e44843655bc8a5efbd386796b235a83ebae0341329ec6589c8ac4a1d64cd65d441382d SHA512 (node-v20.10.0-stripped.tar.gz) = aeab2855f2475e64d4d5453a641dd5998bdb42b5a78a600c903670f3d7e44843655bc8a5efbd386796b235a83ebae0341329ec6589c8ac4a1d64cd65d441382d
SHA512 (icu4c-73_2-data-bin-b.zip) = 8512947da7b2a927627abed6bd7e04218cd4fcd02d44eb72a82ffa87aedabfc3be5d3152e9fba33a769ef35e2db55764c2ab8f5bd65b4e89aa9c15b33392e078 SHA512 (icu4c-73_2-data-bin-b.zip) = 8512947da7b2a927627abed6bd7e04218cd4fcd02d44eb72a82ffa87aedabfc3be5d3152e9fba33a769ef35e2db55764c2ab8f5bd65b4e89aa9c15b33392e078
SHA512 (icu4c-73_2-data-bin-l.zip) = 420c2f5090927dab13f5449da3b0ec7bf86a91ea8723f177aca2907a8eea9bcb4c3475b66c54355ae320001813db57a00afdab00bd85b8c36d39adedcab80bfc SHA512 (icu4c-73_2-data-bin-l.zip) = 420c2f5090927dab13f5449da3b0ec7bf86a91ea8723f177aca2907a8eea9bcb4c3475b66c54355ae320001813db57a00afdab00bd85b8c36d39adedcab80bfc
SHA512 (cjs-module-lexer-1.2.2-stripped.tar.gz) = 0779a99768976954446514cebe2fdba2da6033a00c3a31d4d8552fdf3a9fc0f8f0c1ce149522ff3802234160cd9a587feb0b3d691c5cc69af0ae2cdd3cbe891e
SHA512 (wasi-sdk-11.0-linux.tar.gz) = e3ed4597f7f2290967eef6238e9046f60abbcb8633a4a2a51525d00e7393df8df637a98a5b668217d332dd44fcbf2442ec7efd5e65724e888d90611164451e20
SHA512 (undici-5.26.4-stripped.tar.gz) = 557107ce7baf939b3b1137630a0ab6fbdecac12ee518a1d028be042999690eb4b1b4ce6460489e48ce1d2de1481a783c849bc7fad7f30635930eee1d88f18040
SHA512 (wasi-sdk-20.0-linux.tar.gz) = ff3d368267526887534f50767ff010bd368e9c24178ab2f0cf57a8ed0b3a82fbf85986d620ab2327ac6bb3f456c65adc6edb80626a1289e630dde7e43b191b42