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