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