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