update_openmpt_version.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. set -e
  3. MODE="${1}"
  4. function checkclean {
  5. if [ $(svn status | wc -l) -ne 0 ]; then
  6. echo "error: Working copy not clean"
  7. exit 1
  8. fi
  9. }
  10. VER_MAJOR=$(cat common/versionNumber.h | grep "VER_MAJORMAJOR " | awk '{print $3;}')
  11. VER_MINOR=$(cat common/versionNumber.h | grep "VER_MAJOR " | awk '{print $3;}')
  12. VER_PATCH=$(cat common/versionNumber.h | grep "VER_MINOR " | awk '{print $3;}')
  13. VER_BUILD=$(cat common/versionNumber.h | grep "VER_MINORMINOR " | awk '{print $3;}')
  14. function writeall {
  15. cat common/versionNumber.h | sed -e s/#define\ VER_MAJORMAJOR\ \ .\*/#define\ VER_MAJORMAJOR\ \ $VER_MAJOR/ > common/versionNumber.h.tmp && mv common/versionNumber.h.tmp common/versionNumber.h
  16. cat common/versionNumber.h | sed -e s/#define\ VER_MAJOR\ \ \ \ \ \ .\*/#define\ VER_MAJOR\ \ \ \ \ \ $VER_MINOR/ > common/versionNumber.h.tmp && mv common/versionNumber.h.tmp common/versionNumber.h
  17. cat common/versionNumber.h | sed -e s/#define\ VER_MINOR\ \ \ \ \ \ .\*/#define\ VER_MINOR\ \ \ \ \ \ $VER_PATCH/ > common/versionNumber.h.tmp && mv common/versionNumber.h.tmp common/versionNumber.h
  18. cat common/versionNumber.h | sed -e s/#define\ VER_MINORMINOR\ .\*/#define\ VER_MINORMINOR\ $VER_BUILD/ > common/versionNumber.h.tmp && mv common/versionNumber.h.tmp common/versionNumber.h
  19. }
  20. case $MODE in
  21. bumpmajor)
  22. checkclean
  23. VER_MAJOR=$(($VER_MAJOR + 1))
  24. VER_MINOR=00
  25. VER_PATCH=00
  26. VER_BUILD=01
  27. writeall
  28. ;;
  29. bumpminor)
  30. checkclean
  31. VER_MINOR=$(printf "%02d" $(($(echo $VER_MINOR | sed 's/^0*//') + 1)))
  32. VER_PATCH=00
  33. VER_BUILD=01
  34. writeall
  35. ;;
  36. bumppatch)
  37. checkclean
  38. VER_PATCH=$(printf "%02d" $(($(echo $VER_PATCH | sed 's/^0*//') + 1)))
  39. VER_BUILD=00
  40. writeall
  41. ;;
  42. bumpbuild)
  43. VER_BUILD=$(printf "%02d" $(($(echo $VER_BUILD | sed 's/^0*//') + 1)))
  44. writeall
  45. ;;
  46. *)
  47. echo "error: Wrong argument"
  48. exit 1
  49. ;;
  50. esac