Update version.sh to v0.17
[btrfs-progs-unstable/devel.git] / version.sh
blob92c3953e4cb05ceb6f213dda5fd1bf17d118c574
1 #!/bin/bash
3 # determine-version -- report a useful version for releases
5 # Copyright 2008, Aron Griffis <agriffis@n01se.net>
6 # Copyright 2008, Oracle
7 # Released under the GNU GPLv2
9 v="Btrfs v0.17"
11 which git &> /dev/null
12 if [ $? == 0 -a -d .git ]; then
13 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
14 if tag=`git describe --tags 2>/dev/null`; then
15 v="$tag"
18 # Are there uncommitted changes?
19 git update-index --refresh --unmerged > /dev/null
20 if git diff-index --name-only HEAD | grep -v "^scripts/package" \
21 | read dummy; then
22 v="$v"-dirty
27 which hg &> /dev/null
28 if [ $? == 0 -a -d .hg ]; then
29 last=$(hg tags | grep -m1 -o '^v[0-9.]\+')
31 # now check if the repo has commits since then...
32 if [[ $(hg id -t) == $last || \
33 $(hg di -r "$last:." | awk '/^diff/{print $NF}' | sort -u) == .hgtags ]]
34 then
35 # check if it's dirty
36 if [[ $(hg id | cut -d' ' -f1) == *+ ]]; then
37 v=$last+
38 else
39 v=$last
41 else
42 # includes dirty flag
43 v=$last+$(hg id -i)
47 echo "#ifndef __BUILD_VERSION" > .build-version.h
48 echo "#define __BUILD_VERSION" >> .build-version.h
49 echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
50 echo "#endif" >> .build-version.h
52 diff -q version.h .build-version.h >& /dev/null
54 if [ $? == 0 ]; then
55 rm .build-version.h
56 exit 0
59 mv .build-version.h version.h