Skip to content

Commit b1f7b35

Browse files
author
dbrownell
committed
Change version labels to work better with GIT
- The guess-rev.sh script is now a tweaked version of "setlocalversion" as seen in Linux, U-Boot, and various other projects. When it finds source control support (git, hg, svn) it uses IDs from there. Else (specific to this project) it reports itself as "-snapshot", e.g. from gitweb. I verified this new "guess-rev.sh" script runs under Cygwin. - Also update the generic version strings to be like "0.3.0-dev" (during development) instead of the very long "0.3.0-in-development". These also show up in the PDF docs. For better tracking, we might eventually change these strings to include the version IDs too. - Change the startup banner version strings so they include the guess-rev output. Development and release versions with GIT will be like Open On-Chip Debugger 0.3.0-dev-00282-g7191a4f-dirty (2009-10-05-20:57) Open On-Chip Debugger 0.3.0 (2009-10-05-20:57) instead of the previous SVN-specific (even when using git-svn!) Open On-Chip Debugger 0.3.0-in-development (2009-10-05-01:39) svn:exported Open On-Chip Debugger 0.3.0 (2009-10-05-01:39) Release git-svn-id: svn://svn.berlios.de/openocd/trunk@2809 b42882b7-edfa-0310-969c-e2dbd0fdcd60
1 parent 0da2f75 commit b1f7b35

File tree

6 files changed

+92
-15
lines changed

6 files changed

+92
-15
lines changed

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AC_PREREQ(2.60)
2-
AC_INIT([openocd], [0.3.0-in-development],
2+
AC_INIT([openocd], [0.3.0-dev],
33
[OpenOCD Mailing List <[email protected]>])
44
AC_CONFIG_SRCDIR([src/openocd.c])
55

doc/manual/release.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ the minor version will @a also be zero (<code>y = 0, z = 0</code>).
6262
@subsection releaseversiontags Version Tags
6363

6464
After these required numeric components, the version string may contain
65-
one or more <i>version tags</i>, such as '-rc1' or '-in-development'.
65+
one or more <i>version tags</i>, such as '-rc1' or '-dev'.
6666

67-
The trunk and all branches should have the tag '-in-development' in
67+
The trunk and all branches should have the tag '-dev' in
6868
their version number. This tag helps developers identify reports
6969
created from the Subversion repository, and it can be detected and
7070
manipulated by the release script. Specifically, this tag will be
@@ -218,7 +218,7 @@ The following steps should be followed to produce each release:
218218
- This material should be produced during the development cycle.
219219
- Add a new item for each @c NEWS-worthy contribution, when committed.
220220
-# bump library version if our API changed (not yet required)
221-
-# Remove -in-development tag from package version:
221+
-# Remove -dev tag from package version in configure.in:
222222
- For major/minor releases, remove version tag from trunk, @a or
223223
- For bug-fix releases, remove version tag from release branch.
224224
-# Branch or tag the required tree in the Subversion repository:

guess-rev.sh

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,83 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
#
3+
# This scripts adds local version information from the version
4+
# control systems git, mercurial (hg) and subversion (svn).
5+
#
6+
# Copied from Linux 2.6.32 scripts/setlocalversion and modified
7+
# slightly to work better for OpenOCD.
8+
#
9+
10+
usage() {
11+
echo "Usage: $0 [srctree]" >&2
12+
exit 1
13+
}
14+
15+
cd "${1:-.}" || usage
16+
17+
# Check for git and a git repo.
18+
if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
19+
20+
# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it,
21+
# because this version is defined in the top level Makefile.
22+
if [ -z "`git describe --exact-match 2>/dev/null`" ]; then
23+
24+
# If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"),
25+
# we pretty print it.
26+
if atag="`git describe 2>/dev/null`"; then
27+
echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
28+
29+
# If we don't have a tag at all we print -g{commitish}.
30+
else
31+
printf '%s%s' -g $head
32+
fi
33+
fi
34+
35+
# Is this git on svn?
36+
if git config --get svn-remote.svn.url >/dev/null; then
37+
printf -- '-svn%s' "`git svn find-rev $head`"
38+
fi
39+
40+
# Update index only on r/w media
41+
[ -w . ] && git update-index --refresh --unmerged > /dev/null
42+
43+
# Check for uncommitted changes
44+
if git diff-index --name-only HEAD | grep -v "^scripts/package" \
45+
| read dummy; then
46+
printf '%s' -dirty
47+
fi
48+
49+
# All done with git
50+
exit
51+
fi
52+
53+
# Check for mercurial and a mercurial repo.
54+
if hgid=`hg id 2>/dev/null`; then
55+
tag=`printf '%s' "$hgid" | cut -d' ' -f2`
56+
57+
# Do we have an untagged version?
58+
if [ -z "$tag" -o "$tag" = tip ]; then
59+
id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
60+
printf '%s%s' -hg "$id"
61+
fi
62+
63+
# Are there uncommitted changes?
64+
# These are represented by + after the changeset id.
65+
case "$hgid" in
66+
*+|*+\ *) printf '%s' -dirty ;;
67+
esac
68+
69+
# All done with mercurial
70+
exit
71+
fi
372

4-
REV=unknown
73+
# Check for svn and a svn repo.
74+
if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
75+
rev=`echo $rev | awk '{print $NF}'`
76+
printf -- '-svn%s' "$rev"
577

6-
which svnversion > /dev/null 2>&1 && REV=`svnversion -n "$1"`
78+
# All done with svn
79+
exit
80+
fi
781

8-
echo -n $REV
82+
# There's no reecognized repository; we must be a snapshot.
83+
printf -- '-snapshot'

src/Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ AM_CPPFLAGS = \
2828

2929
libopenocd_la_CPPFLAGS = -DPKGBLDDATE=\"`date +%F-%R`\"
3030

31+
# banner output includes RELSTR appended to $VERSION from the configure script
32+
# guess-rev.sh returns either a repository version ID or "-snapshot"
3133
if RELEASE
32-
libopenocd_la_CPPFLAGS += -DRELSTR=\"Release\" -DPKGBLDREV=\"\"
34+
libopenocd_la_CPPFLAGS += -DRELSTR=\"\"
3335
else
34-
libopenocd_la_CPPFLAGS += -DRELSTR=\"svn:\" -DPKGBLDREV=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
36+
libopenocd_la_CPPFLAGS += -DRELSTR=\"`$(top_srcdir)/guess-rev.sh $(top_srcdir)`\"
3537
endif
3638

3739
# add default CPPFLAGS

src/openocd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050

5151
#define OPENOCD_VERSION \
52-
"Open On-Chip Debugger " VERSION " (" PKGBLDDATE ") " RELSTR PKGBLDREV
52+
"Open On-Chip Debugger " VERSION RELSTR " (" PKGBLDDATE ")"
5353

5454
static void print_version(void)
5555
{

tools/release.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ package_info_load() {
9797

9898
PACKAGE_VERSION="$(package_info_load_version)"
9999
[ "${RELEASE_VERSION}" ] || \
100-
RELEASE_VERSION=${PACKAGE_VERSION/-in-development/}
100+
RELEASE_VERSION=${PACKAGE_VERSION/-dev/}
101101

102102
[ "${PACKAGE_NAME}" -a "${PACKAGE_VERSION}" ] || \
103103
die "package information is missing from configure script"
@@ -427,7 +427,7 @@ do_commit() {
427427
package_info_load
428428
svn_setup_load
429429

430-
[ "${PACKAGE_VERSION/in-development/}" = "${PACKAGE_VERSION}" ] || \
430+
[ "${PACKAGE_VERSION/dev/}" = "${PACKAGE_VERSION}" ] || \
431431
die "'${PACKAGE_NAME}-${PACKAGE_VERSION}' cannot be released"
432432

433433
[ "${PACKAGE_VERSION%.0}" = "${PACKAGE_VERSION}" ] || \
@@ -437,7 +437,7 @@ do_commit() {
437437

438438

439439
do_release_step_prep() {
440-
do_version tag remove in-development
440+
do_version tag remove dev
441441
# reset RELEASE_VERSION now to allow release version to be detected
442442
export RELEASE_VERSION=
443443
}
@@ -447,7 +447,7 @@ do_release_step_branch_bump() {
447447
local TYPE="$1"
448448
echo "Bump ${TYPE} version and add tag:"
449449
do_version_bump ${TYPE}
450-
do_version_tag_add in-development
450+
do_version_tag_add dev
451451
}
452452
do_release_step_branch() {
453453
do_svn_switch "${PACKAGE_BRANCH}"

0 commit comments

Comments
 (0)