blob: 1ca1952fd917efac9978d6596343e74f6cc05cec [file] [log] [blame]
Chris Masonb3c3da72008-07-23 12:12:13 -04001#!/bin/bash
2#
3# determine-version -- report a useful version for releases
4#
5# Copyright 2008, Aron Griffis <agriffis@n01se.net>
6# Copyright 2008, Oracle
7# Released under the GNU GPLv2
8
Chris Mason5707e3b2008-08-04 15:45:30 -04009v="v0.16"
Chris Masonb3c3da72008-07-23 12:12:13 -040010
Chris Mason15916de2008-11-19 21:17:22 -050011which git &> /dev/null
12if [ $? == 0 ]; then
13 git branch >& /dev/null
14 if [ $? == 0 ]; then
15 if head=`git rev-parse --verify HEAD 2>/dev/null`; then
16 if tag=`git describe --tags 2>/dev/null`; then
17 v="$tag"
18 fi
19
20 # Are there uncommitted changes?
21 git update-index --refresh --unmerged > /dev/null
22 if git diff-index --name-only HEAD | \
23 grep -v "^scripts/package" \
24 | read dummy; then
25 v="$v"-dirty
26 fi
Chris Masonb3c3da72008-07-23 12:12:13 -040027 fi
Chris Mason15916de2008-11-19 21:17:22 -050028 fi
Chris Masonb3c3da72008-07-23 12:12:13 -040029fi
30
31echo "#ifndef __BUILD_VERSION" > .build-version.h
32echo "#define __BUILD_VERSION" >> .build-version.h
33echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
34echo "#endif" >> .build-version.h
35
36diff -q version.h .build-version.h >& /dev/null
37
38if [ $? == 0 ]; then
39 rm .build-version.h
40 exit 0
41fi
42
43mv .build-version.h version.h