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