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