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