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