]> git.ipfire.org Git - thirdparty/util-linux.git/blob - rfkill/version.sh
rfkill: merge rfkill.8 project to util-linux
[thirdparty/util-linux.git] / rfkill / version.sh
1 #!/bin/sh
2
3 VERSION="0.5"
4
5 SUFFIX=
6 if test "x$1" = x--suffix; then
7 shift
8 SUFFIX="-$1"
9 shift
10 fi
11 OUT="$1"
12
13 if test "x$SUFFIX" != 'x'; then
14 v="$VERSION$SUFFIX"
15 elif head=`git rev-parse --verify HEAD 2>/dev/null`; then
16 git update-index --refresh --unmerged > /dev/null
17 descr=$(git describe 2>/dev/null || echo "v$VERSION")
18
19 # on git builds check that the version number above
20 # is correct...
21 [ "${descr%%-*}" = "v$VERSION" ] || exit 2
22
23 echo -n 'const char rfkill_version[] = "' > "$OUT"
24 v="${descr#v}"
25 if git diff-index --name-only HEAD | read dummy ; then
26 v="$v"-dirty
27 fi
28 else
29 v="$VERSION"
30 fi
31
32 echo "const char rfkill_version[] = \"$v\";" > "$OUT"