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