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