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