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