4c30b8
#!/bin/sh
4c30b8
# Uses Argbash to generate command argument parsing. To update
4c30b8
# arguments, make sure to call
4c30b8
# `argbash nodejs-tarball.sh -o nodejs-tarball.sh`
4c30b8
4c30b8
# ARG_POSITIONAL_SINGLE([version],[Node.js release version],[""])
4c30b8
# ARG_DEFAULTS_POS([])
4c30b8
# ARG_HELP([Tool to aid in Node.js packaging of new releases])
4c30b8
# ARGBASH_GO()
4c30b8
# needed because of Argbash --> m4_ignore([
4c30b8
### START OF CODE GENERATED BY Argbash v2.8.1 one line above ###
4c30b8
# Argbash is a bash code generator used to get arguments parsing right.
4c30b8
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
4c30b8
4c30b8
4c30b8
die()
4c30b8
{
4c30b8
	local _ret=$2
4c30b8
	test -n "$_ret" || _ret=1
4c30b8
	test "$_PRINT_HELP" = yes && print_help >&2
4c30b8
	echo "$1" >&2
4c30b8
	exit ${_ret}
4c30b8
}
4c30b8
4c30b8
4c30b8
begins_with_short_option()
4c30b8
{
4c30b8
	local first_option all_short_options='h'
4c30b8
	first_option="${1:0:1}"
4c30b8
	test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
4c30b8
}
4c30b8
4c30b8
# THE DEFAULTS INITIALIZATION - POSITIONALS
4c30b8
_positionals=()
4c30b8
_arg_version=""
4c30b8
# THE DEFAULTS INITIALIZATION - OPTIONALS
4c30b8
4c30b8
4c30b8
print_help()
4c30b8
{
4c30b8
	printf '%s\n' "Tool to aid in Node.js packaging of new releases"
4c30b8
	printf 'Usage: %s [-h|--help] [<version>]\n' "$0"
4c30b8
	printf '\t%s\n' "<version>: Node.js release version (default: '""')"
4c30b8
	printf '\t%s\n' "-h, --help: Prints help"
4c30b8
}
4c30b8
4c30b8
4c30b8
parse_commandline()
4c30b8
{
4c30b8
	_positionals_count=0
4c30b8
	while test $# -gt 0
4c30b8
	do
4c30b8
		_key="$1"
4c30b8
		case "$_key" in
4c30b8
			-h|--help)
4c30b8
				print_help
4c30b8
				exit 0
4c30b8
				;;
4c30b8
			-h*)
4c30b8
				print_help
4c30b8
				exit 0
4c30b8
				;;
4c30b8
			*)
4c30b8
				_last_positional="$1"
4c30b8
				_positionals+=("$_last_positional")
4c30b8
				_positionals_count=$((_positionals_count + 1))
4c30b8
				;;
4c30b8
		esac
4c30b8
		shift
4c30b8
	done
4c30b8
}
4c30b8
4c30b8
4c30b8
handle_passed_args_count()
4c30b8
{
4c30b8
	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
4c30b8
}
4c30b8
4c30b8
4c30b8
assign_positional_args()
4c30b8
{
4c30b8
	local _positional_name _shift_for=$1
4c30b8
	_positional_names="_arg_version "
4c30b8
4c30b8
	shift "$_shift_for"
4c30b8
	for _positional_name in ${_positional_names}
4c30b8
	do
4c30b8
		test $# -gt 0 || break
4c30b8
		eval "$_positional_name=\${1}" || die "Error during argument parsing, possibly an Argbash bug." 1
4c30b8
		shift
4c30b8
	done
4c30b8
}
4c30b8
4c30b8
parse_commandline "$@"
4c30b8
handle_passed_args_count
4c30b8
assign_positional_args 1 "${_positionals[@]}"
4c30b8
4c30b8
# OTHER STUFF GENERATED BY Argbash
4c30b8
4c30b8
### END OF CODE GENERATED BY Argbash (sortof) ### ])
4c30b8
# [ <-- needed because of Argbash
4c30b8
4c30b8
4c30b8
set -e
4c30b8
4c30b8
echo $_arg_version
4c30b8
4c30b8
if [ x$_arg_version != x ]; then
4c30b8
    version=$_arg_version
4c30b8
else
4c30b8
    version=$(rpm -q --specfile --qf='%{version}\n' nodejs.spec | head -n1)
4c30b8
fi
4c30b8
4c30b8
rm -f node-v${version}.tar.gz node-v${version}-stripped.tar.gz
4c30b8
wget http://nodejs.org/dist/v${version}/node-v${version}.tar.gz \
4c30b8
     http://nodejs.org/dist/v${version}/SHASUMS256.txt
4c30b8
sha256sum -c SHASUMS256.txt --ignore-missing
4c30b8
tar -zxf node-v${version}.tar.gz
4c30b8
rm -rf node-v${version}/deps/openssl
4c30b8
tar -zcf node-v${version}-stripped.tar.gz node-v${version}
4c30b8
4c30b8
# Download the matching version of ICU
4c30b8
rm -f icu4c*-src.tgz icu.md5
4c30b8
ICUMD5=$(cat node-v${version}/tools/icu/current_ver.dep |jq -r '.[0].md5')
4c30b8
wget $(cat node-v${version}/tools/icu/current_ver.dep |jq -r '.[0].url')
4c30b8
ICUTARBALL=$(ls -1 icu4c*-src.tgz)
4c30b8
echo "$ICUMD5  $ICUTARBALL" > icu.md5
4c30b8
md5sum -c icu.md5
4c30b8
rm -f icu.md5 SHASUMS256.txt
4c30b8
4c30b8
rhpkg new-sources node-v${version}-stripped.tar.gz icu4c*-src.tgz
4c30b8
4c30b8
rm -f node-v${version}.tar.gz
4c30b8
4c30b8
set +e
4c30b8
4c30b8
# Determine the bundled versions of the various packages
4c30b8
echo "Bundled software versions"
4c30b8
echo "-------------------------"
4c30b8
echo
4c30b8
echo "libnode shared object version"
4c30b8
echo "========================="
4c30b8
grep "define NODE_MODULE_VERSION" node-v${version}/src/node_version.h
4c30b8
echo
4c30b8
echo "V8"
4c30b8
echo "========================="
4c30b8
grep "define V8_MAJOR_VERSION" node-v${version}/deps/v8/include/v8-version.h
4c30b8
grep "define V8_MINOR_VERSION" node-v${version}/deps/v8/include/v8-version.h
4c30b8
grep "define V8_BUILD_NUMBER" node-v${version}/deps/v8/include/v8-version.h
4c30b8
grep "define V8_PATCH_LEVEL" node-v${version}/deps/v8/include/v8-version.h
4c30b8
echo
4c30b8
echo "c-ares"
4c30b8
echo "========================="
4c30b8
grep "define ARES_VERSION_MAJOR" node-v${version}/deps/cares/include/ares_version.h
4c30b8
grep "define ARES_VERSION_MINOR" node-v${version}/deps/cares/include/ares_version.h
4c30b8
grep "define ARES_VERSION_PATCH" node-v${version}/deps/cares/include/ares_version.h
4c30b8
echo
4c30b8
echo "llhttp"
4c30b8
echo "========================="
4c30b8
grep "define LLHTTP_VERSION_MAJOR" node-v${version}/deps/llhttp/include/llhttp.h
4c30b8
grep "define LLHTTP_VERSION_MINOR" node-v${version}/deps/llhttp/include/llhttp.h
4c30b8
grep "define LLHTTP_VERSION_PATCH" node-v${version}/deps/llhttp/include/llhttp.h
4c30b8
echo
4c30b8
echo "libuv"
4c30b8
echo "========================="
4c30b8
grep "define UV_VERSION_MAJOR" node-v${version}/deps/uv/include/uv/version.h
4c30b8
grep "define UV_VERSION_MINOR" node-v${version}/deps/uv/include/uv/version.h
4c30b8
grep "define UV_VERSION_PATCH" node-v${version}/deps/uv/include/uv/version.h
4c30b8
echo
4c30b8
echo "nghttp2"
4c30b8
echo "========================="
4c30b8
grep "define NGHTTP2_VERSION " node-v${version}/deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h
4c30b8
echo
4c30b8
echo "nghttp3"
4c30b8
echo "========================="
4c30b8
grep "define NGHTTP3_VERSION " node-v${version}/deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h
4c30b8
echo
4c30b8
echo "ngtcp2"
4c30b8
echo "========================="
4c30b8
grep "define NGTCP2_VERSION " node-v${version}/deps/ngtcp2/ngtcp2/lib/includes/ngtcp2/version.h
4c30b8
echo
4c30b8
echo "ICU"
4c30b8
echo "========================="
4c30b8
grep "url" node-v${version}/tools/icu/current_ver.dep
4c30b8
echo
4c30b8
echo "punycode"
4c30b8
echo "========================="
4c30b8
grep "'version'" node-v${version}/lib/punycode.js
4c30b8
echo
4c30b8
echo "uvwasi"
4c30b8
echo "========================="
4c30b8
grep "define UVWASI_VERSION_MAJOR" node-v${version}/deps/uvwasi/include/uvwasi.h
4c30b8
grep "define UVWASI_VERSION_MINOR" node-v${version}/deps/uvwasi/include/uvwasi.h
4c30b8
grep "define UVWASI_VERSION_PATCH" node-v${version}/deps/uvwasi/include/uvwasi.h
4c30b8
echo
4c30b8
echo "npm"
4c30b8
echo "========================="
4c30b8
grep "\"version\":" node-v${version}/deps/npm/package.json
4c30b8
echo
4c30b8
echo "Make sure these versions match what is in the RPM spec file"
4c30b8
4c30b8
rm -rf node-v${version}
4c30b8
# ] <-- needed because of Argbash