sources: use jinja2 template to support patches

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2023-02-28 21:54:45 -05:00
parent c37ef81437
commit 0b4597e2bc
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11
3 changed files with 82 additions and 72 deletions

View File

@ -190,8 +190,8 @@ ICU_MINOR=$(jq -r '.[0].url' node-v${version}/tools/icu/current_ver.dep | sed --
# Download the ICU binary data files # Download the ICU binary data files
rm -Rf icu4c-${ICU_MAJOR}_${ICU_MINOR}-data-bin-*.zip rm -Rf icu4c-${ICU_MAJOR}_${ICU_MINOR}-data-bin-*.zip
wget $(grep Source3 packaging/nodejs.spec.in | sed --expression="s/.*http/http/g" --expression="s/\(\%{icu_major}\)/${ICU_MAJOR}/g" --expression="s/\(\%{icu_minor}\)/${ICU_MINOR}/g") wget $(grep Source3 packaging/nodejs.spec.j2 | sed --expression="s/.*http/http/g" --expression="s/\(\%{icu_major}\)/${ICU_MAJOR}/g" --expression="s/\(\%{icu_minor}\)/${ICU_MINOR}/g")
wget $(grep Source4 packaging/nodejs.spec.in | sed --expression="s/.*http/http/g" --expression="s/\(\%{icu_major}\)/${ICU_MAJOR}/g" --expression="s/\(\%{icu_minor}\)/${ICU_MINOR}/g") wget $(grep Source4 packaging/nodejs.spec.j2 | sed --expression="s/.*http/http/g" --expression="s/\(\%{icu_major}\)/${ICU_MAJOR}/g" --expression="s/\(\%{icu_minor}\)/${ICU_MINOR}/g")
rm -f node-v${version}.tar.gz rm -f node-v${version}.tar.gz
@ -228,14 +228,16 @@ echo "========================="
LLHTTP_MAJOR=$(grep -oP '(?<=#define LLHTTP_VERSION_MAJOR )\d+' node-v${version}/deps/llhttp/include/llhttp.h) LLHTTP_MAJOR=$(grep -oP '(?<=#define LLHTTP_VERSION_MAJOR )\d+' node-v${version}/deps/llhttp/include/llhttp.h)
LLHTTP_MINOR=$(grep -oP '(?<=#define LLHTTP_VERSION_MINOR )\d+' node-v${version}/deps/llhttp/include/llhttp.h) LLHTTP_MINOR=$(grep -oP '(?<=#define LLHTTP_VERSION_MINOR )\d+' node-v${version}/deps/llhttp/include/llhttp.h)
LLHTTP_PATCH=$(grep -oP '(?<=#define LLHTTP_VERSION_PATCH )\d+' node-v${version}/deps/llhttp/include/llhttp.h) LLHTTP_PATCH=$(grep -oP '(?<=#define LLHTTP_VERSION_PATCH )\d+' node-v${version}/deps/llhttp/include/llhttp.h)
echo "${LLHTTP_MAJOR}.${LLHTTP_MINOR}.${LLHTTP_PATCH}" LLHTTP_VERSION="${LLHTTP_MAJOR}.${LLHTTP_MINOR}.${LLHTTP_PATCH}"
echo $LLHTTP_VERSION
echo echo
echo "libuv" echo "libuv"
echo "=========================" echo "========================="
UV_MAJOR=$(grep -oP '(?<=#define UV_VERSION_MAJOR )\d+' node-v${version}/deps/uv/include/uv/version.h) UV_MAJOR=$(grep -oP '(?<=#define UV_VERSION_MAJOR )\d+' node-v${version}/deps/uv/include/uv/version.h)
UV_MINOR=$(grep -oP '(?<=#define UV_VERSION_MINOR )\d+' node-v${version}/deps/uv/include/uv/version.h) UV_MINOR=$(grep -oP '(?<=#define UV_VERSION_MINOR )\d+' node-v${version}/deps/uv/include/uv/version.h)
UV_PATCH=$(grep -oP '(?<=#define UV_VERSION_PATCH )\d+' node-v${version}/deps/uv/include/uv/version.h) UV_PATCH=$(grep -oP '(?<=#define UV_VERSION_PATCH )\d+' node-v${version}/deps/uv/include/uv/version.h)
echo ${UV_MAJOR}.${UV_MINOR}.${UV_PATCH} LIBUV_VERSION="${UV_MAJOR}.${UV_MINOR}.${UV_PATCH}"
echo $UV_VERSION
echo echo
echo "nghttp2" echo "nghttp2"
echo "=========================" echo "========================="
@ -281,40 +283,51 @@ echo "WASI-SDK: ${UNDICI_WASI_MAJOR}.${UNDICI_WASI_MINOR}"
echo echo
echo "ada" echo "ada"
echo "=========================" echo "========================="
ADA_VERSION=$(grep -oP '(?<=#define ADA_VERSION ).*\"' node-v${version}/deps/ada/ada.h |sed -e 's/^"//' -e 's/"$//') ADA_VERSION=$(grep -osP '(?<=#define ADA_VERSION ).*\"' node-v${version}/deps/ada/ada.h |sed -e 's/^"//' -e 's/"$//')
ADA_VERSION=${ADA_VERSION:-0}
echo "${ADA_VERSION}" echo "${ADA_VERSION}"
echo echo
echo "Applying versions to spec template" echo "Applying versions to spec template"
sed -e "s/@NODE_PKG_MAJOR@/${NODE_PKG_MAJOR}/g" \ # Get the list of patches we need to add to the specfile
-e "s/@NODE_MAJOR@/${NODE_MAJOR}/g" \ readarray -t patchlist < <(git ls-files |grep '^[0-9]\{4\}-.*\.patch')
-e "s/@NODE_MINOR@/${NODE_MINOR}/g" \ json_patchlist=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${patchlist[@]}")
-e "s/@NODE_PATCH@/${NODE_PATCH}/g" \
-e "s/@FEDORA_DEFAULT_RELEASE_LOW@/${FEDORA_DEFAULT_RELEASE_LOW}/g" \ IFS='' read -r -d '' template_json <<EOF
-e "s/@FEDORA_DEFAULT_RELEASE_HIGH@/${FEDORA_DEFAULT_RELEASE_HIGH}/g" \ {
-e "s/@NODE_SOVERSION@/${NODE_SOVERSION}/g" \ "NODE_PKG_MAJOR": $NODE_PKG_MAJOR,
-e "s/@V8_MAJOR@/${V8_MAJOR}/g" \ "NODE_MAJOR": $NODE_MAJOR,
-e "s/@V8_MINOR@/${V8_MINOR}/g" \ "NODE_MINOR": $NODE_MINOR,
-e "s/@V8_BUILD@/${V8_BUILD}/g" \ "NODE_PATCH": $NODE_PATCH,
-e "s/@V8_PATCH@/${V8_PATCH}/g" \ "FEDORA_DEFAULT_RELEASE_LOW": $FEDORA_DEFAULT_RELEASE_LOW,
-e "s/@C_ARES_VERSION@/${C_ARES_VERSION}/g" \ "FEDORA_DEFAULT_RELEASE_HIGH": $FEDORA_DEFAULT_RELEASE_HIGH,
-e "s/@LLHTTP_VERSION@/${LLHTTP_MAJOR}.${LLHTTP_MINOR}.${LLHTTP_PATCH}/g" \ "NODE_SOVERSION": $NODE_SOVERSION,
-e "s/@LIBUV_VERSION@/${UV_MAJOR}.${UV_MINOR}.${UV_PATCH}/g" \ "V8_MAJOR": $V8_MAJOR,
-e "s/@NGHTTP2_VERSION@/${NGHTTP2_VERSION}/g" \ "V8_MINOR": $V8_MINOR,
-e "s/@ICU_MAJOR@/${ICU_MAJOR}/g" \ "V8_BUILD": $V8_BUILD,
-e "s/@ICU_MINOR@/${ICU_MINOR}/g" \ "V8_PATCH": $V8_PATCH,
-e "s/@PUNYCODE_VERSION@/${PUNYCODE_VERSION}/g" \ "C_ARES_VERSION": $C_ARES_VERSION,
-e "s/@UVWASI_VERSION@/${UVWASI_VERSION}/g" \ "LLHTTP_VERSION": $LLHTTP_VERSION,
-e "s/@NPM_VERSION@/${NPM_VERSION}/g" \ "LIBUV_VERSION": $LIBUV_VERSION,
-e "s/@ZLIB_VERSION@/${ZLIB_VERSION}/g" \ "NGHTTP2_VERSION": $NGHTTP2_VERSION,
-e "s/@LEXER_VERSION@/${LEXER_VERSION}/g" \ "ICU_MAJOR": $ICU_MAJOR,
-e "s/@LEXER_WASI_MAJOR@/${LEXER_WASI_MAJOR}/g" \ "ICU_MINOR": $ICU_MINOR,
-e "s/@LEXER_WASI_MINOR@/${LEXER_WASI_MINOR}/g" \ "PUNYCODE_VERSION": $PUNYCODE_VERSION,
-e "s/@UNDICI_VERSION@/${UNDICI_VERSION}/g" \ "UVWASI_VERSION": $UVWASI_VERSION,
-e "s/@UNDICI_WASI_MAJOR@/${UNDICI_WASI_MAJOR}/g" \ "NPM_VERSION": $NPM_VERSION,
-e "s/@UNDICI_WASI_MINOR@/${UNDICI_WASI_MINOR}/g" \ "ZLIB_VERSION": $ZLIB_VERSION,
-e "s/@ADA_VERSION@/${ADA_VERSION}/g" \ "LEXER_VERSION": $LEXER_VERSION,
${SCRIPT_DIR}/packaging/nodejs.spec.in \ "LEXER_WASI_MAJOR": $LEXER_WASI_MAJOR,
"LEXER_WASI_MINOR": $LEXER_WASI_MINOR,
"UNDICI_VERSION": $UNDICI_VERSION,
"UNDICI_WASI_MAJOR": $UNDICI_WASI_MAJOR,
"UNDICI_WASI_MINOR": $UNDICI_WASI_MINOR,
"ADA_VERSION": $ADA_VERSION,
"PATCHES": $json_patchlist
}
EOF
echo ${template_json} | jinja2 ${SCRIPT_DIR}/packaging/nodejs.spec.j2 \
> ${SCRIPT_DIR}/nodejs${NODE_PKG_MAJOR}.spec > ${SCRIPT_DIR}/nodejs${NODE_PKG_MAJOR}.spec
if [ $_arg_push = 'on' ]; then if [ $_arg_push = 'on' ]; then

View File

@ -127,9 +127,6 @@
# histogram_c - assumed from timestamps # histogram_c - assumed from timestamps
%global histogram_version 0.9.7 %global histogram_version 0.9.7
# ada URL parser
%global ada_version 1.0.1
Name: nodejs20 Name: nodejs20
Epoch: %{nodejs_epoch} Epoch: %{nodejs_epoch}
@ -162,6 +159,8 @@ Source102: wasi-sdk-11.0-linux.tar.gz
Source111: undici-5.20.0-stripped.tar.gz Source111: undici-5.20.0-stripped.tar.gz
Source112: wasi-sdk-14.0-linux.tar.gz Source112: wasi-sdk-14.0-linux.tar.gz
Patch: 0001-Remove-unused-OpenSSL-config.patch
%if 0%{?nodejs_default} %if 0%{?nodejs_default}
%global pkgname nodejs %global pkgname nodejs
%package -n %{pkgname} %package -n %{pkgname}
@ -299,11 +298,9 @@ Provides: bundled(icu) = %{icu_version}
Provides: bundled(uvwasi) = %{uvwasi_version} Provides: bundled(uvwasi) = %{uvwasi_version}
Provides: bundled(histogram) = %{histogram_version} Provides: bundled(histogram) = %{histogram_version}
%if 0%{?nodejs_major} > 9
# Upstream has added a new URL parser that has no option to build as a shared # Upstream has added a new URL parser that has no option to build as a shared
# library (19.7.0+) # library (19.7.0+)
Provides: bundled(ada) = ${ada_version} Provides: bundled(ada) = 1.0.1
%endif
%description %description

View File

@ -43,11 +43,11 @@
# feature releases that are only supported for nine months, which is shorter # feature releases that are only supported for nine months, which is shorter
# than a Fedora release lifecycle. # than a Fedora release lifecycle.
%global nodejs_epoch 1 %global nodejs_epoch 1
%global nodejs_major @NODE_MAJOR@ %global nodejs_major {{ NODE_MAJOR }}
%global nodejs_minor @NODE_MINOR@ %global nodejs_minor {{ NODE_MINOR }}
%global nodejs_patch @NODE_PATCH@ %global nodejs_patch {{ NODE_PATCH }}
# nodejs_soversion - from NODE_MODULE_VERSION in src/node_version.h # nodejs_soversion - from NODE_MODULE_VERSION in src/node_version.h
%global nodejs_soversion @NODE_SOVERSION@ %global nodejs_soversion {{ NODE_SOVERSION }}
%global nodejs_abi %{nodejs_soversion} %global nodejs_abi %{nodejs_soversion}
%global nodejs_version %{nodejs_major}.%{nodejs_minor}.%{nodejs_patch} %global nodejs_version %{nodejs_major}.%{nodejs_minor}.%{nodejs_patch}
%global nodejs_release %{baserelease} %global nodejs_release %{baserelease}
@ -57,7 +57,7 @@
# Determine if this should be the default version for this Fedora release # Determine if this should be the default version for this Fedora release
# The default version will own /usr/bin/node and friends # The default version will own /usr/bin/node and friends
%if 0%{?fedora} == @FEDORA_DEFAULT_RELEASE_LOW@ || 0%{?fedora} == @FEDORA_DEFAULT_RELEASE_HIGH@ %if 0%{?fedora} == {{ FEDORA_DEFAULT_RELEASE_LOW }} || 0%{?fedora} == {{ FEDORA_DEFAULT_RELEASE_HIGH }}
%global nodejs_default %{nodejs_major} %global nodejs_default %{nodejs_major}
%endif %endif
%global nodejs_private_sitelib %{nodejs_sitelib}_%{nodejs_major} %global nodejs_private_sitelib %{nodejs_sitelib}_%{nodejs_major}
@ -67,32 +67,32 @@
# v8 - from deps/v8/include/v8-version.h # v8 - from deps/v8/include/v8-version.h
# Epoch is set to ensure clean upgrades from the old v8 package # Epoch is set to ensure clean upgrades from the old v8 package
%global v8_epoch 3 %global v8_epoch 3
%global v8_major @V8_MAJOR@ %global v8_major {{ V8_MAJOR }}
%global v8_minor @V8_MINOR@ %global v8_minor {{ V8_MINOR }}
%global v8_build @V8_BUILD@ %global v8_build {{ V8_BUILD }}
%global v8_patch @V8_PATCH@ %global v8_patch {{ V8_PATCH }}
%global v8_version %{v8_major}.%{v8_minor}.%{v8_build}.%{v8_patch} %global v8_version %{v8_major}.%{v8_minor}.%{v8_build}.%{v8_patch}
%global v8_release %{nodejs_epoch}.%{nodejs_major}.%{nodejs_minor}.%{nodejs_patch}.%{nodejs_release} %global v8_release %{nodejs_epoch}.%{nodejs_major}.%{nodejs_minor}.%{nodejs_patch}.%{nodejs_release}
# zlib - from deps/zlib/zlib.h # zlib - from deps/zlib/zlib.h
%global zlib_version @ZLIB_VERSION@ %global zlib_version {{ ZLIB_VERSION }}
# c-ares - from deps/cares/include/ares_version.h # c-ares - from deps/cares/include/ares_version.h
# https://github.com/nodejs/node/pull/9332 # https://github.com/nodejs/node/pull/9332
%global c_ares_version @C_ARES_VERSION@ %global c_ares_version {{ C_ARES_VERSION }}
# llhttp - from deps/llhttp/include/llhttp.h # llhttp - from deps/llhttp/include/llhttp.h
%global llhttp_version @LLHTTP_VERSION@ %global llhttp_version {{ LLHTTP_VERSION }}
# libuv - from deps/uv/include/uv/version.h # libuv - from deps/uv/include/uv/version.h
%global libuv_version @LIBUV_VERSION@ %global libuv_version {{ LIBUV_VERSION }}
# nghttp2 - from deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h # nghttp2 - from deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h
%global nghttp2_version @NGHTTP2_VERSION@ %global nghttp2_version {{ NGHTTP2_VERSION }}
# ICU - from tools/icu/current_ver.dep # ICU - from tools/icu/current_ver.dep
%global icu_major @ICU_MAJOR@ %global icu_major {{ ICU_MAJOR }}
%global icu_minor @ICU_MINOR@ %global icu_minor {{ ICU_MINOR }}
%global icu_version %{icu_major}.%{icu_minor} %global icu_version %{icu_major}.%{icu_minor}
%global icudatadir %{nodejs_datadir}/icudata %global icudatadir %{nodejs_datadir}/icudata
@ -107,11 +107,11 @@
# punycode - from lib/punycode.js # punycode - from lib/punycode.js
# Note: this was merged into the mainline since 0.6.x # Note: this was merged into the mainline since 0.6.x
# Note: this will be unmerged in an upcoming major release # Note: this will be unmerged in an upcoming major release
%global punycode_version @PUNYCODE_VERSION@ %global punycode_version {{ PUNYCODE_VERSION }}
# npm - from deps/npm/package.json # npm - from deps/npm/package.json
%global npm_epoch 1 %global npm_epoch 1
%global npm_version @NPM_VERSION@ %global npm_version {{ NPM_VERSION }}
# In order to avoid needing to keep incrementing the release version for the # In order to avoid needing to keep incrementing the release version for the
# main package forever, we will just construct one for npm that is guaranteed # main package forever, we will just construct one for npm that is guaranteed
@ -122,16 +122,13 @@
%global npm_envr %{npm_epoch}:%{npm_version}-%{npm_release} %global npm_envr %{npm_epoch}:%{npm_version}-%{npm_release}
# uvwasi - from deps/uvwasi/include/uvwasi.h # uvwasi - from deps/uvwasi/include/uvwasi.h
%global uvwasi_version @UVWASI_VERSION@ %global uvwasi_version {{ UVWASI_VERSION }}
# histogram_c - assumed from timestamps # histogram_c - assumed from timestamps
%global histogram_version 0.9.7 %global histogram_version 0.9.7
# ada URL parser
%global ada_version @ADA_VERSION@
Name: nodejs{{ NODE_PKG_MAJOR }}
Name: nodejs@NODE_PKG_MAJOR@
Epoch: %{nodejs_epoch} Epoch: %{nodejs_epoch}
Version: %{nodejs_version} Version: %{nodejs_version}
Release: %{nodejs_release} Release: %{nodejs_release}
@ -157,17 +154,21 @@ Source100: nodejs-sources.sh
# Note: These sources would also include pre-compiled WASM blobs… so they are adjusted not to. # 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. # Recipes for creating these blobs are included in the sources.
# These are generated by nodejs-sources.sh # These are generated by nodejs-sources.sh
Source101: cjs-module-lexer-@LEXER_VERSION@-stripped.tar.gz Source101: cjs-module-lexer-{{ LEXER_VERSION }}-stripped.tar.gz
Source102: wasi-sdk-@LEXER_WASI_MAJOR@.@LEXER_WASI_MINOR@-linux.tar.gz Source102: wasi-sdk-{{ LEXER_WASI_MAJOR }}.{{ LEXER_WASI_MINOR }}-linux.tar.gz
Source111: undici-@UNDICI_VERSION@-stripped.tar.gz Source111: undici-{{ UNDICI_VERSION }}-stripped.tar.gz
Source112: wasi-sdk-@UNDICI_WASI_MAJOR@.@UNDICI_WASI_MINOR@-linux.tar.gz Source112: wasi-sdk-{{ UNDICI_WASI_MAJOR }}.{{ UNDICI_WASI_MINOR }}-linux.tar.gz
{% for patch in PATCHES -%}
Patch: {{ patch }}
{% endfor -%}
{# #}
%if 0%{?nodejs_default} %if 0%{?nodejs_default}
%global pkgname nodejs %global pkgname nodejs
%package -n %{pkgname} %package -n %{pkgname}
Summary: JavaScript runtime Summary: JavaScript runtime
%else %else
%global pkgname nodejs@NODE_PKG_MAJOR@ %global pkgname nodejs{{ NODE_PKG_MAJOR }}
%endif %endif
BuildRequires: make BuildRequires: make
@ -299,12 +300,11 @@ Provides: bundled(icu) = %{icu_version}
Provides: bundled(uvwasi) = %{uvwasi_version} Provides: bundled(uvwasi) = %{uvwasi_version}
Provides: bundled(histogram) = %{histogram_version} Provides: bundled(histogram) = %{histogram_version}
%if 0%{?nodejs_major} > 9 {% if ADA_VERSION -%}
# Upstream has added a new URL parser that has no option to build as a shared # Upstream has added a new URL parser that has no option to build as a shared
# library (19.7.0+) # library (19.7.0+)
Provides: bundled(ada) = ${ada_version} Provides: bundled(ada) = {{ ADA_VERSION }}
%endif {% endif %}
%description %description
Node.js is a platform built on Chrome's JavaScript runtime \ Node.js is a platform built on Chrome's JavaScript runtime \