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