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