Skip to content

Commit 71e0baa

Browse files
authored
Merge pull request #41 from mattthias/getversion
Support more ways to determine the version
2 parents 2dc27eb + fcfc38d commit 71e0baa

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

getversion

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22
#
33
# Generate a version string for use when building.
44
#
5-
# * If RELEASE exists, and is non-empty, use the contents of that file.
6-
# This is in case we're building from a tarball.
5+
# * If in a git repository use "git describe"
6+
# * If building from tarball extract the version from the directory name or
7+
# try to get the version fronm the packaging.
78

8-
if [ -s "RELEASE" ]; then
9-
cat RELEASE
9+
10+
generate_version_string_from_dir() {
11+
basename $(pwd) | grep -e '^munin-c' | cut -c9-
12+
}
13+
14+
generate_version_string_from_packaging() {
15+
if [ -d debian ]; then
16+
dpkg-parsechangelog -SVersion 2> /dev/null
17+
fi
18+
}
19+
20+
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
21+
git describe --always
22+
elif [ ! -z "$(generate_version_string_from_dir)" ]; then
23+
generate_version_string_from_dir
24+
elif [ ! -z "$(generate_version_string_from_packaging)" ]; then
25+
generate_version_string_from_packaging
1026
else
11-
git describe --always
27+
echo "unknown"
1228
fi
29+

0 commit comments

Comments
 (0)