PERF-VERSION-GEN 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. if [ $# -eq 1 ] ; then
  3. OUTPUT=$1
  4. fi
  5. GVF=${OUTPUT}PERF-VERSION-FILE
  6. LF='
  7. '
  8. # First check if there is a .git to get the version from git describe
  9. # otherwise try to get the version from the kernel makefile
  10. if test -d ../../.git -o -f ../../.git &&
  11. VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
  12. case "$VN" in
  13. *$LF*) (exit 1) ;;
  14. v[0-9]*)
  15. git update-index -q --refresh
  16. test -z "$(git diff-index --name-only HEAD --)" ||
  17. VN="$VN-dirty" ;;
  18. esac
  19. then
  20. VN=$(echo "$VN" | sed -e 's/-/./g');
  21. else
  22. eval `grep '^VERSION\s*=' ../../Makefile|tr -d ' '`
  23. eval `grep '^PATCHLEVEL\s*=' ../../Makefile|tr -d ' '`
  24. eval `grep '^SUBLEVEL\s*=' ../../Makefile|tr -d ' '`
  25. eval `grep '^EXTRAVERSION\s*=' ../../Makefile|tr -d ' '`
  26. VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
  27. fi
  28. VN=$(expr "$VN" : v*'\(.*\)')
  29. if test -r $GVF
  30. then
  31. VC=$(sed -e 's/^PERF_VERSION = //' <$GVF)
  32. else
  33. VC=unset
  34. fi
  35. test "$VN" = "$VC" || {
  36. echo >&2 "PERF_VERSION = $VN"
  37. echo "PERF_VERSION = $VN" >$GVF
  38. }