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