version.sh 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/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. v="v0.16"
  9. which git &> /dev/null
  10. if [ $? == 0 ]; then
  11. git branch >& /dev/null
  12. if [ $? == 0 ]; 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"
  16. fi
  17. # Are there uncommitted changes?
  18. git update-index --refresh --unmerged > /dev/null
  19. if git diff-index --name-only HEAD | \
  20. grep -v "^scripts/package" \
  21. | read dummy; then
  22. v="$v"-dirty
  23. fi
  24. fi
  25. fi
  26. fi
  27. echo "#ifndef __BUILD_VERSION" > .build-version.h
  28. echo "#define __BUILD_VERSION" >> .build-version.h
  29. echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
  30. echo "#endif" >> .build-version.h
  31. diff -q version.h .build-version.h >& /dev/null
  32. if [ $? == 0 ]; then
  33. rm .build-version.h
  34. exit 0
  35. fi
  36. mv .build-version.h version.h