2013-05-29 03:23:27 +00:00
#!/bin/sh
2019-08-16 11:14:28 +00:00
# Uses Argbash to generate command argument parsing. To update
# arguments, make sure to call
# `argbash nodejs-tarball.sh -o nodejs-tarball.sh`
2023-01-16 21:50:17 +00:00
# ARG_POSITIONAL_SINGLE([version],[Node.js release version])
# ARG_OPTIONAL_BOOLEAN([push],[],[Whether to upload to the lookaside cache],[on])
2023-04-27 12:58:13 +00:00
# ARG_OPTIONAL_BOOLEAN([debug],[],[Print all commands],[off])
2019-08-16 11:14:28 +00:00
# ARG_DEFAULTS_POS([])
# ARG_HELP([Tool to aid in Node.js packaging of new releases])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
2023-01-16 21:50:17 +00:00
### START OF CODE GENERATED BY Argbash v2.10.0 one line above ###
2019-08-16 11:14:28 +00:00
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
die( )
{
2023-01-16 21:50:17 +00:00
local _ret = " ${ 2 :- 1 } "
test " ${ _PRINT_HELP :- no } " = yes && print_help >& 2
2019-08-16 11:14:28 +00:00
echo " $1 " >& 2
2023-01-16 21:50:17 +00:00
exit " ${ _ret } "
2019-08-16 11:14:28 +00:00
}
begins_with_short_option( )
{
local first_option all_short_options = 'h'
first_option = " ${ 1 : 0 : 1 } "
test " $all_short_options " = " ${ all_short_options / $first_option / } " && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - POSITIONALS
_positionals = ( )
2023-01-16 21:50:17 +00:00
_arg_version =
2019-08-16 11:14:28 +00:00
# THE DEFAULTS INITIALIZATION - OPTIONALS
2023-01-16 21:50:17 +00:00
_arg_push = "on"
2023-04-27 12:58:13 +00:00
_arg_debug = "off"
2019-08-16 11:14:28 +00:00
print_help( )
{
printf '%s\n' "Tool to aid in Node.js packaging of new releases"
2024-04-09 17:19:27 +00:00
printf 'Usage: %s [--(no-)push] [--(no-)debug] [-h|--help] <version>\n' " $0 "
2023-01-16 21:50:17 +00:00
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)"
2023-04-27 12:58:13 +00:00
printf '\t%s\n' "--debug, --no-debug: Print all commands (off by default)"
2019-08-16 11:14:28 +00:00
printf '\t%s\n' "-h, --help: Prints help"
}
parse_commandline( )
{
_positionals_count = 0
while test $# -gt 0
do
_key = " $1 "
case " $_key " in
2023-01-16 21:50:17 +00:00
--no-push| --push)
_arg_push = "on"
test " ${ 1 : 0 : 5 } " = "--no-" && _arg_push = "off"
; ;
2023-04-27 12:58:13 +00:00
--no-debug| --debug)
_arg_debug = "on"
test " ${ 1 : 0 : 5 } " = "--no-" && _arg_debug = "off"
; ;
2019-08-16 11:14:28 +00:00
-h| --help)
print_help
exit 0
; ;
-h*)
print_help
exit 0
; ;
*)
_last_positional = " $1 "
_positionals += ( " $_last_positional " )
_positionals_count = $(( _positionals_count + 1 ))
; ;
esac
shift
done
}
handle_passed_args_count( )
{
2023-01-16 21:50:17 +00:00
local _required_args_string = "'version'"
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
2019-08-16 11:14:28 +00:00
}
assign_positional_args( )
{
local _positional_name _shift_for = $1
_positional_names = "_arg_version "
shift " $_shift_for "
for _positional_name in ${ _positional_names }
do
test $# -gt 0 || break
eval " $_positional_name =\${1} " || die "Error during argument parsing, possibly an Argbash bug." 1
shift
done
}
parse_commandline " $@ "
handle_passed_args_count
assign_positional_args 1 " ${ _positionals [@] } "
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
2023-04-27 12:58:13 +00:00
if [ $_arg_debug = 'on' ] ; then
set -x
fi
2023-01-16 21:50:17 +00:00
SCRIPT_DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
alias wget = 'wget --quiet'
2023-07-12 17:36:15 +00:00
packages = ( "jq" "wget" "tar" "fedpkg" "grep" "sed" "python3-jinja2-cli" "nodejs" )
2022-05-17 18:12:32 +00:00
rpm -q ${ packages [@] } >/dev/null
if [ $? -ne 0 ] ; then
sudo dnf -y install ${ packages [@] }
fi
2019-08-16 11:14:28 +00:00
2019-12-02 16:41:30 +00:00
set -e
2019-08-16 11:14:28 +00:00
2023-01-16 21:50:17 +00:00
version = $_arg_version
2016-09-08 12:45:11 +00:00
2022-08-05 18:45:55 +00:00
NODE_MAJOR = $( echo $version | cut -d. -f1)
2023-01-16 21:50:17 +00:00
NODE_MINOR = $( echo $version | cut -d. -f2)
NODE_PATCH = $( echo $version | cut -d. -f3)
2022-08-05 18:45:55 +00:00
2023-02-21 19:59:23 +00:00
# Treat odd-numbered major releases as pre-releases for the
# next LTS release.
if [ [ $(( NODE_MAJOR % 2 )) -eq 0 ] ] ;
then NODE_PKG_MAJOR = ${ NODE_MAJOR } ;
else NODE_PKG_MAJOR = $(( NODE_MAJOR + 1 )) ;
fi
FEDORA_DEFAULT_RELEASE_LOW = $(( NODE_PKG_MAJOR + 19 ))
FEDORA_DEFAULT_RELEASE_HIGH = $(( NODE_PKG_MAJOR + 20 ))
2024-04-09 17:19:27 +00:00
if [ [ $(( NODE_PKG_MAJOR)) -eq 20 ] ] ; then
RHEL_DEFAULT_RELEASE = " || 0%{?rhel} == 10"
fi
# Handle the situation where the next stable release of Node.js isn't yet
# available to include.
if [ [ $(( NODE_PKG_MAJOR)) -eq 20 ] ] ; then
TEMPORARY_RELEASE = " || 0%{?fedora} == 41 || 0%{?rhel} >= 11"
2023-03-01 18:12:07 +00:00
fi
2021-09-13 21:05:10 +00:00
rm -rf node-v${ version } .tar.gz \
node-v${ version } -stripped.tar.gz \
node-v${ version } / \
2023-01-16 16:29:46 +00:00
wasi-sdk-* \
cjs-module-lexer* \
undici* \
2021-09-13 21:05:10 +00:00
SHASUMS256.txt
2023-01-16 21:50:17 +00:00
echo Downloading node-v${ version } .tar.gz
2019-12-02 16:41:30 +00:00
wget http://nodejs.org/dist/v${ version } /node-v${ version } .tar.gz \
http://nodejs.org/dist/v${ version } /SHASUMS256.txt
2023-01-16 21:50:17 +00:00
echo Validating sha256sum
2019-12-02 16:41:30 +00:00
sha256sum -c SHASUMS256.txt --ignore-missing
2022-09-23 19:31:03 +00:00
rm -f SHASUMS256.txt
2013-05-29 03:23:27 +00:00
tar -zxf node-v${ version } .tar.gz
2022-04-28 15:22:34 +00:00
2022-05-31 11:30:35 +00:00
# Remove bundled OpenSSL
2022-04-28 15:22:34 +00:00
# We will link to the system version
2022-05-31 11:30:35 +00:00
rm -rf node-v${ version } /deps/openssl
2016-09-09 12:16:32 +00:00
tar -zcf node-v${ version } -stripped.tar.gz node-v${ version }
2018-03-22 00:35:22 +00:00
2024-04-09 17:19:27 +00:00
# Record the bundled cjs-module-lexer version
2023-01-16 16:29:46 +00:00
LEXER_VERSION = $( jq -r '.version' node-v${ version } /deps/cjs-module-lexer/package.json)
2023-07-12 17:36:15 +00:00
2024-04-09 17:19:27 +00:00
# Record the bundled undici version
UNDICI_VERSION = $( jq -r '.version' node-v${ version } /deps/undici/src/package.json)
2023-01-16 16:29:46 +00:00
2022-04-28 15:22:57 +00:00
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' )
2019-12-02 16:41:30 +00:00
2022-04-27 23:03:01 +00:00
# Download the ICU binary data files
rm -Rf icu4c-${ ICU_MAJOR } _${ ICU_MINOR } -data-bin-*.zip
2023-03-01 18:12:07 +00:00
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.j2 | sed --expression= "s/.*http/http/g" --expression= " s/\(\%{icu_major}\)/ ${ ICU_MAJOR } /g " --expression= " s/\(\%{icu_minor}\)/ ${ ICU_MINOR } /g " )
2019-04-30 12:51:56 +00:00
rm -f node-v${ version } .tar.gz
2019-08-16 11:14:28 +00:00
2020-02-25 16:22:47 +00:00
set +e
2019-08-16 15:13:09 +00:00
# Determine the bundled versions of the various packages
2023-01-16 21:50:17 +00:00
echo "Included software versions"
2019-08-16 15:13:09 +00:00
echo "-------------------------"
echo
2023-01-16 21:50:17 +00:00
echo "Node.js version"
echo "========================="
echo " ${ version } "
echo
2019-12-02 16:41:30 +00:00
echo "libnode shared object version"
echo "========================="
2023-01-16 21:50:17 +00:00
NODE_SOVERSION = $( grep -oP '(?<=#define NODE_MODULE_VERSION )\d+' node-v${ version } /src/node_version.h)
echo " ${ NODE_SOVERSION } "
2019-12-02 16:41:30 +00:00
echo
2019-08-16 15:13:09 +00:00
echo "V8"
echo "========================="
2023-01-16 21:50:17 +00:00
V8_MAJOR = $( grep -oP '(?<=#define V8_MAJOR_VERSION )\d+' node-v${ version } /deps/v8/include/v8-version.h)
V8_MINOR = $( grep -oP '(?<=#define V8_MINOR_VERSION )\d+' node-v${ version } /deps/v8/include/v8-version.h)
V8_BUILD = $( grep -oP '(?<=#define V8_BUILD_NUMBER )\d+' node-v${ version } /deps/v8/include/v8-version.h)
V8_PATCH = $( grep -oP '(?<=#define V8_PATCH_LEVEL )\d+' node-v${ version } /deps/v8/include/v8-version.h)
echo " ${ V8_MAJOR } . ${ V8_MINOR } . ${ V8_BUILD } . ${ V8_PATCH } "
2019-08-16 15:13:09 +00:00
echo
echo "c-ares"
echo "========================="
2023-01-16 21:50:17 +00:00
C_ARES_VERSION = $( grep -oP '(?<=#define ARES_VERSION_STR ).*\"' node-v${ version } /deps/cares/include/ares_version.h | sed -e 's/^"//' -e 's/"$//' )
echo $C_ARES_VERSION
2019-08-16 15:13:09 +00:00
echo
echo "llhttp"
echo "========================="
2023-01-16 21:50:17 +00:00
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_PATCH = $( grep -oP '(?<=#define LLHTTP_VERSION_PATCH )\d+' node-v${ version } /deps/llhttp/include/llhttp.h)
2023-03-01 18:12:07 +00:00
LLHTTP_VERSION = " ${ LLHTTP_MAJOR } . ${ LLHTTP_MINOR } . ${ LLHTTP_PATCH } "
echo $LLHTTP_VERSION
2019-08-16 15:13:09 +00:00
echo
echo "libuv"
echo "========================="
2023-01-16 21:50:17 +00:00
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_PATCH = $( grep -oP '(?<=#define UV_VERSION_PATCH )\d+' node-v${ version } /deps/uv/include/uv/version.h)
2023-03-01 18:12:07 +00:00
LIBUV_VERSION = " ${ UV_MAJOR } . ${ UV_MINOR } . ${ UV_PATCH } "
2024-04-09 17:19:27 +00:00
echo $LIBUV_VERSION
2019-08-16 15:13:09 +00:00
echo
2020-04-17 09:56:38 +00:00
echo "nghttp2"
2019-08-16 15:13:09 +00:00
echo "========================="
2023-01-16 21:50:17 +00:00
NGHTTP2_VERSION = $( grep -oP '(?<=#define NGHTTP2_VERSION ).*\"' node-v${ version } /deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h | sed -e 's/^"//' -e 's/"$//' )
echo $NGHTTP2_VERSION
2019-08-16 15:13:09 +00:00
echo
2024-04-09 17:19:27 +00:00
echo "nghttp3"
echo "========================="
NGHTTP3_VERSION = $( grep -oP '(?<=#define NGHTTP3_VERSION ).*\"' node-v${ version } /deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h | sed -e 's/^"//' -e 's/"$//' )
echo $NGHTTP3_VERSION
echo
echo "ngtcp2"
echo "========================="
NGTCP2_VERSION = $( grep -oP '(?<=#define NGTCP2_VERSION ).*\"' node-v${ version } /deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h | sed -e 's/^"//' -e 's/"$//' )
echo $NGTCP2_VERSION
echo
2019-08-16 15:13:09 +00:00
echo "ICU"
echo "========================="
2022-04-27 23:03:01 +00:00
echo " ${ ICU_MAJOR } . ${ ICU_MINOR } "
2019-08-16 15:13:09 +00:00
echo
2024-04-09 17:19:27 +00:00
echo "simdutf"
echo "========================="
SIMDUTF_VERSION = $( grep -oP '(?<=#define SIMDUTF_VERSION ).*\"' node-v${ version } /deps/simdutf/simdutf.h | sed -e 's/^"//' -e 's/"$//' )
echo $SIMDUTF_VERSION
echo
2019-08-16 15:13:09 +00:00
echo "punycode"
echo "========================="
2023-01-16 21:50:17 +00:00
PUNYCODE_VERSION = $( /usr/bin/node -e "console.log(require('punycode').version)" )
echo $PUNYCODE_VERSION
2019-08-16 15:13:09 +00:00
echo
2020-04-17 09:56:38 +00:00
echo "uvwasi"
echo "========================="
2023-01-16 21:50:17 +00:00
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
2020-04-17 09:56:38 +00:00
echo
2019-08-16 15:13:09 +00:00
echo "npm"
echo "========================="
2023-01-16 21:50:17 +00:00
NPM_VERSION = $( jq -r .version ./node-v${ version } /deps/npm/package.json)
echo $NPM_VERSION
2019-08-16 15:13:09 +00:00
echo
2022-01-19 19:04:11 +00:00
echo "zlib"
echo "========================="
2023-01-16 21:50:17 +00:00
ZLIB_VERSION = $( grep -oP '(?<=#define ZLIB_VERSION ).*\"' node-v${ version } /deps/zlib/zlib.h | sed -e 's/^"//' -e 's/"$//' )
echo $ZLIB_VERSION
2022-01-19 19:04:11 +00:00
echo
2023-01-16 16:29:46 +00:00
echo "cjs-module-lexer"
echo "========================="
echo " ${ LEXER_VERSION } "
echo
echo "undici"
echo "========================="
echo " ${ UNDICI_VERSION } "
echo
2023-02-21 19:59:23 +00:00
echo "ada"
echo "========================="
2023-03-01 18:12:07 +00:00
ADA_VERSION = $( grep -osP '(?<=#define ADA_VERSION ).*\"' node-v${ version } /deps/ada/ada.h | sed -e 's/^"//' -e 's/"$//' )
ADA_VERSION = ${ ADA_VERSION :- 0 }
2023-02-21 19:59:23 +00:00
echo " ${ ADA_VERSION } "
echo
2023-01-16 21:50:17 +00:00
echo "Applying versions to spec template"
2023-03-01 18:12:07 +00:00
# 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 ,
2024-04-09 17:19:27 +00:00
"TEMPORARY_RELEASE" : " $TEMPORARY_RELEASE " ,
"RHEL_DEFAULT_RELEASE" : " $RHEL_DEFAULT_RELEASE " ,
2023-03-01 18:12:07 +00:00
"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 ,
2024-04-09 17:19:27 +00:00
"NGHTTP3_VERSION" : $NGHTTP3_VERSION ,
"NGTCP2_VERSION" : $NGTCP2_VERSION ,
2023-03-01 18:12:07 +00:00
"ICU_MAJOR" : $ICU_MAJOR ,
"ICU_MINOR" : $ICU_MINOR ,
2024-04-09 17:19:27 +00:00
"SIMDUTF_VERSION" : $SIMDUTF_VERSION ,
2023-03-01 18:12:07 +00:00
"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 ,
2024-04-09 17:19:27 +00:00
"PATCHES" : $json_patchlist
2023-03-01 18:12:07 +00:00
}
EOF
echo ${ template_json } | jinja2 ${ SCRIPT_DIR } /packaging/nodejs.spec.j2 \
2023-02-21 19:59:23 +00:00
> ${ SCRIPT_DIR } /nodejs${ NODE_PKG_MAJOR } .spec
2019-12-02 16:41:30 +00:00
2023-03-01 18:12:07 +00:00
if [ $_arg_push = 'on' ] ; then
fedpkg new-sources node-v${ version } -stripped.tar.gz \
2024-04-09 17:19:27 +00:00
icu4c-${ ICU_MAJOR } _${ ICU_MINOR } -data-bin-*.zip
2023-03-01 18:12:07 +00:00
fi
2019-12-02 16:41:30 +00:00
rm -rf node-v${ version }
2019-08-16 11:14:28 +00:00
# ] <-- needed because of Argbash