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