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