hhorak / rpms / nodejs

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