From c970d03ddb7084713533c935864df18a6828d21a Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Thu, 22 Oct 2009 01:38:22 -0700 Subject: Factor release version functions into new script. --- tools/release/helpers.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tools/release/helpers.sh (limited to 'tools/release') diff --git a/tools/release/helpers.sh b/tools/release/helpers.sh new file mode 100644 index 00000000..2dd5bae1 --- /dev/null +++ b/tools/release/helpers.sh @@ -0,0 +1,60 @@ +#!/bin/sh -e + +die() { + echo "$@" >&2 + exit 1 +} + +package_info_load_name() { + grep AC_INIT configure.in | perl -ne 's/^.+\(\[([-\w]*)\],.+$/$1/ and print' +} +package_info_load_version() { + grep AC_INIT configure.in | perl -ne 's/^.+\[([-\w\.]*)\],$/$1/ and print' +} + +package_info_load() { + [ -f "configure.in" ] || \ + die "package_info_load: configure.in is missing" + + PACKAGE_NAME="$(package_info_load_name)" + # todo: fix this + PACKAGE_TARNAME="${PACKAGE_NAME}" + + PACKAGE_VERSION="$(package_info_load_version)" + + [ "${PACKAGE_NAME}" -a "${PACKAGE_VERSION}" ] || \ + die "package information is missing from configure script" + + PACKAGE_VERSION_TAGS= + [ "${PACKAGE_VERSION/-/}" = "${PACKAGE_VERSION}" ] || \ + PACKAGE_VERSION_TAGS="-${PACKAGE_VERSION#*-}" + PACKAGE_VERSION_BASE="${PACKAGE_VERSION%%-*}" + PACKAGE_MICRO="${PACKAGE_VERSION_BASE##*.}" + PACKAGE_MAJOR_AND_MINOR="${PACKAGE_VERSION_BASE%.*}" + PACKAGE_MAJOR="${PACKAGE_MAJOR_AND_MINOR%.*}" + PACKAGE_MINOR="${PACKAGE_MAJOR_AND_MINOR#*.}" + + [ "${RELEASE_FINAL}" ] \ + && RELEASE_VERSION="${PACKAGE_VERSION_BASE}" \ + || RELEASE_VERSION="${PACKAGE_VERSION/-dev/}" + PACKAGE_RELEASE="${PACKAGE_TARNAME}-${RELEASE_VERSION}" + PACKAGE_STRING="${PACKAGE_NAME} ${PACKAGE_VERSION}" +} + +package_info_show() { + cat <