-do_version_usage() {
- cat << USAGE
-usage: $0 version <command>
-Version Commands:
- tag {add|remove} <label> Add or remove the specified tag.
- bump {major|minor|micro|rc} Bump the specified version number;
- resets less-significant numbers to zero.
- All but 'rc' releases drop that tag.
-USAGE
-}
-
-do_version_sed() {
- local OLD_VERSION="${PACKAGE_VERSION}"
- local NEW_VERSION="$1"
- local MSG="$2"
-
- sed -i -e "/AC_INIT/ s|${OLD_VERSION}|${NEW_VERSION}|" configure.in
- package_info_load
- echo "${MSG}: ${OLD_VERSION} -> ${NEW_VERSION}"
-}
-do_version_bump_sed() {
- local NEW_VERSION="$1"
- [ -z "${PACKAGE_VERSION_TAGS}" ] || \
- NEW_VERSION="${NEW_VERSION}${PACKAGE_VERSION_TAGS}"
-
- do_version_sed "${NEW_VERSION}" \
- "Bump ${CMD} package version number"
-}
-do_version_bump_major() {
- do_version_bump_sed "$((PACKAGE_MAJOR + 1)).0.0"
-}
-do_version_bump_minor() {
- do_version_bump_sed "${PACKAGE_MAJOR}.$((PACKAGE_MINOR + 1)).0"
-}
-do_version_bump_micro() {
- do_version_bump_sed "${PACKAGE_MAJOR_AND_MINOR}.$((PACKAGE_MICRO + 1))"
-}
-do_version_bump_tag() {
- local TAG="$1"
- [ "${TAG}" ] || die "TAG argument is missing"
- local TAGS="${PACKAGE_VERSION_TAGS}"
- if has_version_tag "${TAG}"; then
- local RC=$(echo ${TAGS} | perl -ne "/-${TAG}"'(\d+)/ && print $1')
- RC=$((${RC} + 1))
- TAGS=$(echo ${TAGS} | perl -npe "s/-${TAG}[\\d]*/-${TAG}${RC}/")
- else
- TAGS="-${TAG}1${PACKAGE_VERSION_TAGS}"
- fi
- PACKAGE_VERSION_TAGS="${TAGS}"
- do_version_bump_sed "${PACKAGE_VERSION_BASE}"
-}
-do_version_bump_rc() { do_version_bump_tag 'rc'; }
-do_version_bump() {
- CMD="$1"
- shift
- case "${CMD}" in
- major|minor|micro|rc|tag)
- eval "do_version_bump_${CMD}" "$@"
- ;;
- *)
- do_version_usage
- ;;
- esac
-}
-
-has_version_tag() {
- test "${PACKAGE_VERSION/-${1}/}" != "${PACKAGE_VERSION}"
-}
-
-do_version_tag_add() {
- local TAG="$1"
- has_version_tag "${TAG}" && \
- die "error: tag '-${TAG}' exists in '${PACKAGE_VERSION}'"
- do_version_sed "${PACKAGE_VERSION}-${TAG}" \
- "Add '-${TAG}' version tag"
-}
-do_version_tag_remove() {
- local TAG="$1"
- has_version_tag "${TAG}" || \
- die "error: tag '-${TAG}' missing from '${PACKAGE_VERSION}'"
- do_version_sed "${PACKAGE_VERSION/-${TAG}/}" \
- "Remove '-${TAG}' version tag"
-}
-do_version_tag() {
- CMD="$1"
- shift
- case "${CMD}" in
- add|remove)
- local i=
- for i in "$@"; do
- eval "do_version_tag_${CMD}" "${i}"
- done
- ;;
- *)
- do_version_usage
- ;;
- esac
-}
-