blob: d6c9434b3f2b0557b6264b083f08704f25b228d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#!/bin/bash
# version.sh: openocd version process automation
# Copyright (C) 2009 by Zachary T Welch <zw@superlucidity.net>
# Release under the GNU GPL v2 (or later versions).
# FIXME Remove more bash-isms. Fix errors making "ash -e" lose.
# NOTE Use with care! "RC" should only follow x.x.x, with
# vendor tags after that. Be traditional; avoid "rc0".
# NOTE: This *ONLY* updates the "configure.ac" version tag.
# It does not affect GIT tags. Use this script immediately
# before making a release, to remove the "-dev" tag and to
# update the version label. Then commit the change and tag
# that commit to match the version label.
. "tools/release/helpers.sh"
do_version_usage() {
cat << USAGE
usage: $0 <command>
Version Commands:
tag {add|remove} <label> Add or remove the specified tag.
bump {major|minor|micro|rc} Bump the specified version number, and
reset less-significant numbers to zero.
bump tag <label> Add or bump a versioned tag (e.g. -rcN).
bump final <label> Remove a versioned tag (e.g. -rcN).
USAGE
# REVISIT ... "commit" not listed.
}
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.ac
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=$(do_version_tag_value "${TAG}")
RC=$((${RC} + 1))
TAGS=$(echo ${TAGS} | perl -npe "s/-${TAG}[\\d]*/-${TAG}${RC}/")
else
TAGS="-${TAG}0${PACKAGE_VERSION_TAGS}"
fi
PACKAGE_VERSION_TAGS="${TAGS}"
do_version_bump_sed "${PACKAGE_VERSION_BASE}"
}
do_version_bump_final() {
local TAG="$1"
[ "${TAG}" ] || die "TAG argument is missing"
has_version_tag "${TAG}" || die "-${TAG} tag is missing"
do_version_tag_remove "${TAG}$(do_version_tag_value "${TAG}")"
}
do_version_bump() {
CMD="$1"
shift
case "${CMD}" in
major|minor|micro|final|tag)
"do_version_bump_${CMD}" "$@"
;;
rc)
do_version_bump_tag "rc"
;;
*)
do_version_usage
;;
esac
}
has_version_tag() {
test "${PACKAGE_VERSION/-${1}/}" != "${PACKAGE_VERSION}"
}
do_version_tag_value() {
local TAG="$1"
echo ${PACKAGE_VERSION_TAGS} | perl -ne "/-${TAG}"'(\d+)/ && print $1'
}
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
"do_version_tag_${CMD}" "${i}"
done
;;
*)
do_version_usage
;;
esac
}
do_version() {
CMD="$1"
shift
case "${CMD}" in
tag|bump)
"do_version_${CMD}" "$@"
;;
commit)
do_version_commit "$@"
;;
*)
do_version_usage
;;
esac
}
package_info_load
do_version "$@"
|