2024-08-06 12:03:45 +00:00
#!/bin/sh
# Uses Argbash to generate command argument parsing. To update
# arguments, make sure to call
# `argbash nodejs-tarball.sh -o nodejs-tarball.sh`
2024-11-19 14:13:27 +00:00
# ARG_POSITIONAL_SINGLE([version],[Node.js release version],[""])
2024-08-06 12:03:45 +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([
2024-11-19 14:13:27 +00:00
### START OF CODE GENERATED BY Argbash v2.8.1 one line above ###
2024-08-06 12:03:45 +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( )
{
2024-11-19 14:13:27 +00:00
local _ret = $2
test -n " $_ret " || _ret = 1
test " $_PRINT_HELP " = yes && print_help >& 2
2024-08-06 12:03:45 +00:00
echo " $1 " >& 2
2024-11-19 14:13:27 +00:00
exit ${ _ret }
2024-08-06 12:03:45 +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 = ( )
2024-11-19 14:13:27 +00:00
_arg_version = ""
2024-08-06 12:03:45 +00:00
# THE DEFAULTS INITIALIZATION - OPTIONALS
print_help( )
{
printf '%s\n' "Tool to aid in Node.js packaging of new releases"
2024-11-19 14:13:27 +00:00
printf 'Usage: %s [-h|--help] [<version>]\n' " $0 "
printf '\t%s\n' "<version>: Node.js release version (default: '" "')"
2024-08-06 12:03:45 +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
-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( )
{
2024-11-19 14:13:27 +00:00
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
2024-08-06 12:03:45 +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
set -e
2024-11-19 14:13:27 +00:00
echo $_arg_version
2024-08-06 12:03:45 +00:00
2024-11-19 14:13:27 +00:00
if [ x$_arg_version != x ] ; then
version = $_arg_version
else
version = $( rpm -q --specfile --qf= '%{version}\n' nodejs.spec | head -n1)
2024-08-06 12:03:45 +00:00
fi
2024-11-19 14:13:27 +00:00
rm -f node-v${ version } .tar.gz node-v${ version } -stripped.tar.gz
2024-08-06 12:03:45 +00:00
wget http://nodejs.org/dist/v${ version } /node-v${ version } .tar.gz \
http://nodejs.org/dist/v${ version } /SHASUMS256.txt
sha256sum -c SHASUMS256.txt --ignore-missing
tar -zxf node-v${ version } .tar.gz
rm -rf node-v${ version } /deps/openssl
tar -zcf node-v${ version } -stripped.tar.gz node-v${ version }
2024-11-19 14:13:27 +00:00
# Download the ICU binary data files
2024-08-06 12:03:45 +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' )
rm -Rf icu4c-${ ICU_MAJOR } _${ ICU_MINOR } -data-bin-*.zip
2024-11-19 14:13:27 +00:00
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 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
2024-08-06 12:03:45 +00:00
rm -f node-v${ version } .tar.gz
set +e
# Determine the bundled versions of the various packages
echo "Included software versions"
echo "-------------------------"
echo
echo "Node.js version"
echo "========================="
echo " ${ version } "
echo
2024-11-19 14:13:27 +00:00
echo "Bundled software versions"
echo "-------------------------"
echo
echo "libnode shared object version (nodejs_soversion)"
2024-08-06 12:03:45 +00:00
echo "========================="
NODE_SOVERSION = $( grep -oP '(?<=#define NODE_MODULE_VERSION )\d+' node-v${ version } /src/node_version.h)
echo " ${ NODE_SOVERSION } "
echo
echo "V8"
echo "========================="
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 } "
echo
echo "c-ares"
echo "========================="
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
echo
echo "llhttp"
echo "========================="
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)
LLHTTP_VERSION = " ${ LLHTTP_MAJOR } . ${ LLHTTP_MINOR } . ${ LLHTTP_PATCH } "
echo $LLHTTP_VERSION
echo
echo "libuv"
echo "========================="
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)
LIBUV_VERSION = " ${ UV_MAJOR } . ${ UV_MINOR } . ${ UV_PATCH } "
echo $LIBUV_VERSION
echo
echo "nghttp2"
echo "========================="
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
echo
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
echo "ICU"
echo "========================="
2024-11-19 14:13:27 +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' )
2024-08-06 12:03:45 +00:00
echo " ${ ICU_MAJOR } . ${ ICU_MINOR } "
echo
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
2024-11-19 14:13:27 +00:00
echo "ada"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +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 }
echo " ${ ADA_VERSION } "
2024-08-06 12:03:45 +00:00
echo
2024-11-19 14:13:27 +00:00
echo "punycode"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +00:00
PUNYCODE_VERSION = $( grep -oP "'version': '\K[^']+" ./node-v${ version } /lib/punycode.js)
echo $PUNYCODE_VERSION
2024-08-06 12:03:45 +00:00
echo
echo "npm"
echo "========================="
NPM_VERSION = $( jq -r .version ./node-v${ version } /deps/npm/package.json)
echo $NPM_VERSION
echo
2024-11-19 14:13:27 +00:00
echo "corepack"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +00:00
COREPACK_VERSION = $( jq -r .version ./node-v${ version } /deps/corepack/package.json)
echo $COREPACK_VERSION
2024-08-06 12:03:45 +00:00
echo
2024-11-19 14:13:27 +00:00
echo "uvwasi"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +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
2024-08-06 12:03:45 +00:00
echo
2024-11-19 14:13:27 +00:00
echo "histogram_c"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +00:00
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
2024-08-06 12:03:45 +00:00
echo
2024-11-19 14:13:27 +00:00
echo "sqlite"
2024-08-06 12:03:45 +00:00
echo "========================="
2024-11-19 14:13:27 +00:00
SQLITE_VERSION = " $( grep -osP '(?<=#define SQLITE_VERSION ).*\"' node-v${ version } /deps/sqlite/sqlite3.h | sed -e 's/^\s*"//' -e 's/"\s*$//' ) "
echo " ${ SQLITE_VERSION } "
2024-08-06 12:03:45 +00:00
echo
2024-11-19 14:13:27 +00:00
echo "Make sure these versions match what is in the RPM spec file"
2024-08-06 12:03:45 +00:00
rm -rf node-v${ version }
# ] <-- needed because of Argbash