Whamcloud - gitweb
LU-17744 ldiskfs: mballoc stats fixes
[fs/lustre-release.git] / LUSTRE-VERSION-GEN
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # This file is part of Lustre, http://www.lustre.org/
6 #
7 # LUSTRE-VERSION-GEN
8 #
9 # Return lustre version string
10 #
11
12 DEFAULT_VERSION=2.15.62
13 LVF=LUSTRE-VERSION-FILE
14
15 LF='
16 '
17
18 if test -d ${GIT_DIR:-.git} -o -f .git &&
19         VN=$(git describe --match "[0-9]*" --abbrev=7 HEAD 2>/dev/null) &&
20         case "$VN" in
21         *$LF*) (exit 1) ;;
22         [0-9]*)
23                 git update-index -q --refresh
24                 test -z "$(git diff-index --name-only HEAD --)" ||
25                 VN="$VN-dirty" ;;
26         esac
27 then
28         VN=$(echo "$VN" | sed -e 's/-/_/g');
29 elif test -r $LVF
30 then
31         VN=$(sed -e 's/^LUSTRE_VERSION = //' <$LVF)
32 else
33         VN="$DEFAULT_VERSION"
34 fi
35
36 if test -r $LVF
37 then
38         VC=$(sed -e 's/^LUSTRE_VERSION = //' <$LVF)
39 else
40         VC=unset
41 fi
42 test "$VN" = "$VC" || {
43         echo "LUSTRE_VERSION = $VN" >$LVF
44 }
45
46 echo $VN