@ -3,24 +3,23 @@
# arguments, make sure to call
# arguments, make sure to call
# `argbash nodejs-tarball.sh -o nodejs-tarball.sh`
# `argbash nodejs-tarball.sh -o nodejs-tarball.sh`
# 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([debug],[],[Print all commands],[off])
# 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()
# needed because of Argbash --> m4_ignore([
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2. 10.0 one line above ###
### START OF CODE GENERATED BY Argbash v2. 8. 1 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
die( )
die( )
{
{
local _ret = " ${ 2 :- 1 } "
local _ret = $2
test " ${ _PRINT_HELP :- no } " = yes && print_help >& 2
test -n " $_ret " || _ret = 1
test " $_PRINT_HELP " = yes && print_help >& 2
echo " $1 " >& 2
echo " $1 " >& 2
exit " ${ _ret } "
exit ${ _ret }
}
}
@ -33,19 +32,15 @@ begins_with_short_option()
# THE DEFAULTS INITIALIZATION - POSITIONALS
# THE DEFAULTS INITIALIZATION - POSITIONALS
_positionals = ( )
_positionals = ( )
_arg_version =
_arg_version = ""
# THE DEFAULTS INITIALIZATION - OPTIONALS
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_push = "on"
_arg_debug = "off"
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] [-h|--help] <version>\n' " $0 "
printf 'Usage: %s [-h|--help] [<version>]\n' " $0 "
printf '\t%s\n' "<version>: Node.js release version"
printf '\t%s\n' "<version>: Node.js release version (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' "-h, --help: Prints help"
printf '\t%s\n' "-h, --help: Prints help"
}
}
@ -57,14 +52,6 @@ parse_commandline()
do
do
_key = " $1 "
_key = " $1 "
case " $_key " in
case " $_key " in
--no-push| --push)
_arg_push = "on"
test " ${ 1 : 0 : 5 } " = "--no-" && _arg_push = "off"
; ;
--no-debug| --debug)
_arg_debug = "on"
test " ${ 1 : 0 : 5 } " = "--no-" && _arg_debug = "off"
; ;
-h| --help)
-h| --help)
print_help
print_help
exit 0
exit 0
@ -86,9 +73,7 @@ parse_commandline()
handle_passed_args_count( )
handle_passed_args_count( )
{
{
local _required_args_string = "'version'"
test " ${ _positionals_count } " -le 1 || _PRINT_HELP = yes die " FATAL ERROR: There were spurious positional arguments --- we expect between 0 and 1, but got ${ _positionals_count } (the last one was: ' ${ _last_positional } '). " 1
test " ${ _positionals_count } " -ge 1 || _PRINT_HELP = yes die " FATAL ERROR: Not enough positional arguments - we require exactly 1 (namely: $_required_args_string ), but got only ${ _positionals_count } . " 1
test " ${ _positionals_count } " -le 1 || _PRINT_HELP = yes die " FATAL ERROR: There were spurious positional arguments --- we expect exactly 1 (namely: $_required_args_string ), but got ${ _positionals_count } (the last one was: ' ${ _last_positional } '). " 1
}
}
@ -115,78 +100,33 @@ assign_positional_args 1 "${_positionals[@]}"
### END OF CODE GENERATED BY Argbash (sortof) ### ])
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
# [ <-- needed because of Argbash
if [ $_arg_debug = 'on' ] ; then
set -x
fi
SCRIPT_DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
alias wget = 'wget --quiet'
packages = ( "jq" "wget" "tar" "fedpkg" "grep" "sed" "python3-jinja2-cli" "nodejs" )
rpm -q ${ packages [@] } >/dev/null
if [ $? -ne 0 ] ; then
sudo dnf -y install ${ packages [@] }
fi
set -e
set -e
version = $_arg_version
echo $_arg_version
NODE_MAJOR = $( echo $version | cut -d. -f1)
NODE_MINOR = $( echo $version | cut -d. -f2)
NODE_PATCH = $( echo $version | cut -d. -f3)
# Treat odd-numbered major releases as pre-releases for the
if [ x$_arg_version != x ] ; then
# next LTS release.
version = $_arg_version
if [ [ $(( NODE_MAJOR % 2 )) -eq 0 ] ] ;
else
then NODE_PKG_MAJOR = ${ NODE_MAJOR } ;
version = $( rpm -q --specfile --qf= '%{version}\n' nodejs.spec | head -n1)
else NODE_PKG_MAJOR = $(( NODE_MAJOR + 1 )) ;
fi
fi
FEDORA_DEFAULT_RELEASE_LOW = $(( NODE_PKG_MAJOR + 19 ))
rm -f node-v${ version } .tar.gz node-v${ version } -stripped.tar.gz
FEDORA_DEFAULT_RELEASE_HIGH = $(( NODE_PKG_MAJOR + 20 ))
if [ [ $(( NODE_PKG_MAJOR)) -eq 20 ] ]
then RHEL_DEFAULT_RELEASE = " || 0%{?rhel} == 10"
elif [ [ $(( NODE_PKG_MAJOR)) -eq 22 ] ] ;
then RHEL_DEFAULT_RELEASE = " || 0%{?rhel} == 11"
fi
rm -rf node-v${ version } .tar.gz \
node-v${ version } -stripped.tar.gz \
node-v${ version } / \
wasi-sdk-* \
cjs-module-lexer* \
undici* \
SHASUMS256.txt
echo Downloading node-v${ version } .tar.gz
wget http://nodejs.org/dist/v${ version } /node-v${ version } .tar.gz \
wget http://nodejs.org/dist/v${ version } /node-v${ version } .tar.gz \
http://nodejs.org/dist/v${ version } /SHASUMS256.txt
http://nodejs.org/dist/v${ version } /SHASUMS256.txt
echo Validating sha256sum
sha256sum -c SHASUMS256.txt --ignore-missing
sha256sum -c SHASUMS256.txt --ignore-missing
rm -f SHASUMS256.txt
tar -zxf node-v${ version } .tar.gz
tar -zxf node-v${ version } .tar.gz
# Remove bundled OpenSSL
# We will link to the system version
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 }
# Record the bundled cjs-module-lexer version
# Download the ICU binary data files
LEXER_VERSION = $( jq -r '.version' node-v${ version } /deps/cjs-module-lexer/package.json)
# Record the bundled undici version
UNDICI_VERSION = $( jq -r '.version' node-v${ version } /deps/undici/src/package.json)
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' )
# 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.j2 | sed --expression= "s/.*http/http/g" --expression= " s/\(\%{icu_major}\)/ ${ ICU_MAJOR } /g " --expression= " s/\(\%{icu_minor}\)/ ${ ICU_MINOR } /g " )
wget $( grep Source3 nodejs.spec | 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 " )
wget $( grep Source4 nodejs.spec | sed --expression= "s/.*http/http/g" --expression= " s/\(\%{icu_major}\)/ ${ ICU_MAJOR } /g " --expression= " s/\(\%{icu_minor}\)/ ${ ICU_MINOR } /g " )
#fedpkg new-sources node-v${version}-stripped.tar.gz icu4c*-src.tgz
rm -f node-v${ version } .tar.gz
rm -f node-v${ version } .tar.gz
@ -200,7 +140,10 @@ echo "Node.js version"
echo "========================="
echo "========================="
echo " ${ version } "
echo " ${ version } "
echo
echo
echo "libnode shared object version"
echo "Bundled software versions"
echo "-------------------------"
echo
echo "libnode shared object version (nodejs_soversion)"
echo "========================="
echo "========================="
NODE_SOVERSION = $( grep -oP '(?<=#define NODE_MODULE_VERSION )\d+' node-v${ version } /src/node_version.h)
NODE_SOVERSION = $( grep -oP '(?<=#define NODE_MODULE_VERSION )\d+' node-v${ version } /src/node_version.h)
echo " ${ NODE_SOVERSION } "
echo " ${ NODE_SOVERSION } "
@ -251,6 +194,8 @@ echo $NGTCP2_VERSION
echo
echo
echo "ICU"
echo "ICU"
echo "========================="
echo "========================="
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' )
echo " ${ ICU_MAJOR } . ${ ICU_MINOR } "
echo " ${ ICU_MAJOR } . ${ ICU_MINOR } "
echo
echo
echo "simdutf"
echo "simdutf"
@ -258,90 +203,46 @@ echo "========================="
SIMDUTF_VERSION = $( grep -oP '(?<=#define SIMDUTF_VERSION ).*\"' node-v${ version } /deps/simdutf/simdutf.h | sed -e 's/^"//' -e 's/"$//' )
SIMDUTF_VERSION = $( grep -oP '(?<=#define SIMDUTF_VERSION ).*\"' node-v${ version } /deps/simdutf/simdutf.h | sed -e 's/^"//' -e 's/"$//' )
echo $SIMDUTF_VERSION
echo $SIMDUTF_VERSION
echo
echo
echo " punycode "
echo " ada "
echo "========================="
echo "========================="
PUNYCODE_VERSION = $( /usr/bin/node -e "console.log(require('punycode').version)" )
ADA_VERSION = $( grep -osP '(?<=#define ADA_VERSION ).*\"' node-v${ version } /deps/ada/ada.h | sed -e 's/^"//' -e 's/"$//' )
echo $PUNYCODE_VERSION
ADA_VERSION = ${ ADA_VERSION :- 0 }
echo " ${ ADA_VERSION } "
echo
echo
echo " uvwasi "
echo " punycode "
echo "========================="
echo "========================="
UVWASI_MAJOR = $( grep -oP '(?<=#define UVWASI_VERSION_MAJOR )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
PUNYCODE_VERSION = $( grep -oP "'version': '\K[^']+" ./node-v${ version } /lib/punycode.js)
UVWASI_MINOR = $( grep -oP '(?<=#define UVWASI_VERSION_MINOR )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
echo $PUNYCODE_VERSION
UVWASI_PATCH = $( grep -oP '(?<=#define UVWASI_VERSION_PATCH )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
UVWASI_VERSION = " ${ UVWASI_MAJOR } . ${ UVWASI_MINOR } . ${ UVWASI_PATCH } "
echo $UVWASI_VERSION
echo
echo
echo "npm"
echo "npm"
echo "========================="
echo "========================="
NPM_VERSION = $( jq -r .version ./node-v${ version } /deps/npm/package.json)
NPM_VERSION = $( jq -r .version ./node-v${ version } /deps/npm/package.json)
echo $NPM_VERSION
echo $NPM_VERSION
echo
echo
echo " zlib "
echo " corepack "
echo "========================="
echo "========================="
ZLIB_VERSION= $( grep -oP '(?<=#define ZLIB_VERSION ).*\"' node-v${ version } /deps/zlib/zlib.h | sed -e 's/^"//' -e 's/"$//' )
COREPACK_VERSION= $( jq -r .version ./node-v${ version } /deps/corepack/package.json )
echo $ ZLIB _VERSION
echo $ COREPACK _VERSION
echo
echo
echo " cjs-module-lexer "
echo " uvwasi "
echo "========================="
echo "========================="
echo " ${ LEXER_VERSION } "
UVWASI_MAJOR = $( grep -oP '(?<=#define UVWASI_VERSION_MAJOR )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
UVWASI_MINOR = $( grep -oP '(?<=#define UVWASI_VERSION_MINOR )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
UVWASI_PATCH = $( grep -oP '(?<=#define UVWASI_VERSION_PATCH )\d+' node-v${ version } /deps/uvwasi/include/uvwasi.h)
UVWASI_VERSION = " ${ UVWASI_MAJOR } . ${ UVWASI_MINOR } . ${ UVWASI_PATCH } "
echo $UVWASI_VERSION
echo
echo
echo "undici"
echo " histogram_c "
echo "========================="
echo "========================="
echo " ${ UNDICI_VERSION } "
HISTOGRAM_VERSION = $( grep -oP '(?<=#define HDR_HISTOGRAM_VERSION ).*\"' node-v${ version } /deps/histogram/include/hdr/hdr_histogram_version.h| sed -e 's/^"//' -e 's/"$//' )
echo $HISTOGRAM_VERSION
echo
echo
echo " ada "
echo " sqlite "
echo "========================="
echo "========================="
ADA_VERSION = $( grep -osP '(?<=#define ADA_VERSION ).*\"' node-v${ version } /deps/ada/ada.h | sed -e 's/^"//' -e 's/"$//' )
SQLITE_VERSION = " $( grep -osP '(?<=#define SQLITE_VERSION ).*\"' node-v${ version } /deps/sqlite/sqlite3.h | sed -e 's/^\s*"//' -e 's/"\s*$//' ) "
ADA_VERSION = ${ ADA_VERSION :- 0 }
echo " ${ SQLITE_VERSION } "
echo " ${ ADA_VERSION } "
echo
echo
echo "Applying versions to spec template"
echo "Make sure these versions match what is in the RPM spec file"
# Get the list of patches we need to add to the specfile
readarray -t patchlist < <( git ls-files | grep '^[0-9]\{4\}-.*\.patch' )
json_patchlist = $( jq --compact-output --null-input '$ARGS.positional' --args -- " ${ patchlist [@] } " )
IFS = '' read -r -d '' template_json <<EOF
{
"NODE_PKG_MAJOR" : $NODE_PKG_MAJOR ,
"NODE_MAJOR" : $NODE_MAJOR ,
"NODE_MINOR" : $NODE_MINOR ,
"NODE_PATCH" : $NODE_PATCH ,
"FEDORA_DEFAULT_RELEASE_LOW" : $FEDORA_DEFAULT_RELEASE_LOW ,
"FEDORA_DEFAULT_RELEASE_HIGH" : $FEDORA_DEFAULT_RELEASE_HIGH ,
"RHEL_DEFAULT_RELEASE" : " $RHEL_DEFAULT_RELEASE " ,
"NODE_SOVERSION" : $NODE_SOVERSION ,
"V8_MAJOR" : $V8_MAJOR ,
"V8_MINOR" : $V8_MINOR ,
"V8_BUILD" : $V8_BUILD ,
"V8_PATCH" : $V8_PATCH ,
"C_ARES_VERSION" : $C_ARES_VERSION ,
"LLHTTP_VERSION" : $LLHTTP_VERSION ,
"LIBUV_VERSION" : $LIBUV_VERSION ,
"NGHTTP2_VERSION" : $NGHTTP2_VERSION ,
"NGHTTP3_VERSION" : $NGHTTP3_VERSION ,
"NGTCP2_VERSION" : $NGTCP2_VERSION ,
"ICU_MAJOR" : $ICU_MAJOR ,
"ICU_MINOR" : $ICU_MINOR ,
"SIMDUTF_VERSION" : $SIMDUTF_VERSION ,
"PUNYCODE_VERSION" : $PUNYCODE_VERSION ,
"UVWASI_VERSION" : $UVWASI_VERSION ,
"NPM_VERSION" : $NPM_VERSION ,
"ZLIB_VERSION" : $ZLIB_VERSION ,
"LEXER_VERSION" : $LEXER_VERSION ,
"UNDICI_VERSION" : $UNDICI_VERSION ,
"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
if [ $_arg_push = 'on' ] ; then
fedpkg new-sources node-v${ version } -stripped.tar.gz \
icu4c-${ ICU_MAJOR } _${ ICU_MINOR } -data-bin-*.zip
fi
rm -rf node-v${ version }
rm -rf node-v${ version }
# ] <-- needed because of Argbash
# ] <-- needed because of Argbash