2 # version.sh: openocd version process automation
3 # Copyright (C) 2009 by Zachary T Welch <zw@superlucidity.net>
4 # Release under the GNU GPL v2 (or later versions).
6 # FIXME Remove more bash-isms. Fix errors making "ash -e" lose.
8 # NOTE Use with care! "RC" should only follow x.x.x, with
9 # vendor tags after that. Be traditional; avoid "rc0".
11 # NOTE: This *ONLY* updates the "configure.in" version tag.
12 # It does not affect GIT tags. Use this script immediately
13 # before making a release, to remove the "-dev" tag and to
14 # update the version label. Then commit the change and tag
15 # that commit to match the version label.
17 .
"tools/release/helpers.sh"
23 tag {add|remove} <label> Add or remove the specified tag.
24 bump {major|minor|micro|rc} Bump the specified version number, and
25 reset less-significant numbers to zero.
26 bump tag <label> Add or bump a versioned tag (e.g. -rcN).
27 bump final <label> Remove a versioned tag (e.g. -rcN).
29 # REVISIT ... "commit" not listed.
33 local OLD_VERSION
="${PACKAGE_VERSION}"
34 local NEW_VERSION
="$1"
37 sed -i -e "/AC_INIT/ s|${OLD_VERSION}|${NEW_VERSION}|" configure.
in
39 echo "${MSG}: ${OLD_VERSION} -> ${NEW_VERSION}"
41 do_version_bump_sed
() {
42 local NEW_VERSION
="$1"
43 [ -z "${PACKAGE_VERSION_TAGS}" ] || \
44 NEW_VERSION
="${NEW_VERSION}${PACKAGE_VERSION_TAGS}"
46 do_version_sed
"${NEW_VERSION}" \
47 "Bump ${CMD} package version number"
49 do_version_bump_major
() {
50 do_version_bump_sed
"$((PACKAGE_MAJOR + 1)).0.0"
52 do_version_bump_minor
() {
53 do_version_bump_sed
"${PACKAGE_MAJOR}.$((PACKAGE_MINOR + 1)).0"
55 do_version_bump_micro
() {
56 do_version_bump_sed
"${PACKAGE_MAJOR_AND_MINOR}.$((PACKAGE_MICRO + 1))"
58 do_version_bump_tag
() {
60 [ "${TAG}" ] || die
"TAG argument is missing"
61 local TAGS
="${PACKAGE_VERSION_TAGS}"
62 if has_version_tag
"${TAG}"; then
63 local RC
=$
(do_version_tag_value
"${TAG}")
65 TAGS
=$
(echo ${TAGS} | perl -npe "s/-${TAG}[\\d]*/-${TAG}${RC}/")
67 TAGS="-${TAG}0${PACKAGE_VERSION_TAGS}"
69 PACKAGE_VERSION_TAGS="${TAGS}"
70 do_version_bump_sed "${PACKAGE_VERSION_BASE}"
72 do_version_bump_final() {
74 [ "${TAG}" ] || die "TAG argument is missing
"
75 has_version_tag "${TAG}" || die "-${TAG} tag is missing
"
76 do_version_tag_remove "${TAG}$
(do_version_tag_value
"${TAG}")"
82 major|minor|micro|final|tag)
83 "do_version_bump_
${CMD}" "$@
"
86 do_version_bump_tag "rc
"
95 test "${PACKAGE_VERSION/-${1}/}" != "${PACKAGE_VERSION}"
97 do_version_tag_value() {
99 echo ${PACKAGE_VERSION_TAGS} | perl -ne "/-${TAG}"'(\d+)/ && print $1'
101 do_version_tag_add() {
103 has_version_tag "${TAG}" && \
104 die "error
: tag
'-${TAG}' exists
in '${PACKAGE_VERSION}'"
105 do_version_sed "${PACKAGE_VERSION}-${TAG}" \
106 "Add
'-${TAG}' version tag
"
108 do_version_tag_remove() {
110 has_version_tag "${TAG}" || \
111 die "error
: tag
'-${TAG}' missing from
'${PACKAGE_VERSION}'"
112 do_version_sed "${PACKAGE_VERSION/-${TAG}/}" \
113 "Remove
'-${TAG}' version tag
"
122 "do_version_tag_
${CMD}" "${i}"
136 "do_version_
${CMD}" "$@
"
139 do_version_commit "$@
"