update_libopenmpt_version.sh 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/usr/bin/env bash
  2. set -e
  3. MODE="${1}"
  4. PARAM1="${2}"
  5. function checkclean {
  6. if [ $(svn status | wc -l) -ne 0 ]; then
  7. echo "error: Working copy not clean"
  8. exit 1
  9. fi
  10. }
  11. function checkparam1 {
  12. if [ "${PARAM1}x" = "x" ]; then
  13. echo "error: No RC version provided"
  14. fi
  15. }
  16. DATE=$(date --iso)
  17. source libopenmpt/libopenmpt_version.mk
  18. LIBOPENMPT_VERSION_PRERELVER=${LIBOPENMPT_VERSION_PREREL/-pre./}
  19. function setprerel {
  20. cat libopenmpt/libopenmpt_version.h | sed -e 's/#define OPENMPT_API_VERSION_IS_PREREL .*/#define OPENMPT_API_VERSION_IS_PREREL 1/' > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  21. }
  22. function addchangelog {
  23. echo -n > libopenmpt/dox/changelog.md.tmp
  24. cat libopenmpt/dox/changelog.md | head -n 7 >> libopenmpt/dox/changelog.md.tmp
  25. echo "### libopenmpt ${LIBOPENMPT_VERSION_MAJOR}.${LIBOPENMPT_VERSION_MINOR}.${LIBOPENMPT_VERSION_PATCH}-pre" >> libopenmpt/dox/changelog.md.tmp
  26. echo "" >> libopenmpt/dox/changelog.md.tmp
  27. cat libopenmpt/dox/changelog.md | tail -n +8 >> libopenmpt/dox/changelog.md.tmp
  28. mv libopenmpt/dox/changelog.md.tmp libopenmpt/dox/changelog.md
  29. }
  30. function writeall {
  31. cat libopenmpt/libopenmpt_version.h | sed -e s/#define\ OPENMPT_API_VERSION_MAJOR\ .\*/#define\ OPENMPT_API_VERSION_MAJOR\ $LIBOPENMPT_VERSION_MAJOR/ > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  32. cat libopenmpt/libopenmpt_version.h | sed -e s/#define\ OPENMPT_API_VERSION_MINOR\ .\*/#define\ OPENMPT_API_VERSION_MINOR\ $LIBOPENMPT_VERSION_MINOR/ > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  33. cat libopenmpt/libopenmpt_version.h | sed -e s/#define\ OPENMPT_API_VERSION_PATCH\ .\*/#define\ OPENMPT_API_VERSION_PATCH\ $LIBOPENMPT_VERSION_PATCH/ > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  34. cat libopenmpt/libopenmpt_version.h | sed -e s/#define\ OPENMPT_API_VERSION_PREREL\ .\*/#define\ OPENMPT_API_VERSION_PREREL\ \"$LIBOPENMPT_VERSION_PREREL\"/ > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  35. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_VERSION_MAJOR\=.\*/LIBOPENMPT_VERSION_MAJOR\=$LIBOPENMPT_VERSION_MAJOR/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  36. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_VERSION_MINOR\=.\*/LIBOPENMPT_VERSION_MINOR\=$LIBOPENMPT_VERSION_MINOR/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  37. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_VERSION_PATCH\=.\*/LIBOPENMPT_VERSION_PATCH\=$LIBOPENMPT_VERSION_PATCH/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  38. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_VERSION_PREREL\=.\*/LIBOPENMPT_VERSION_PREREL\=$LIBOPENMPT_VERSION_PREREL/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  39. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_LTVER_CURRENT\=.\*/LIBOPENMPT_LTVER_CURRENT\=$LIBOPENMPT_LTVER_CURRENT/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  40. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_LTVER_REVISION\=.\*/LIBOPENMPT_LTVER_REVISION\=$LIBOPENMPT_LTVER_REVISION/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  41. cat libopenmpt/libopenmpt_version.mk | sed -e s/LIBOPENMPT_LTVER_AGE\=.\*/LIBOPENMPT_LTVER_AGE\=$LIBOPENMPT_LTVER_AGE/ > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  42. }
  43. case $MODE in
  44. release)
  45. checkclean
  46. cat libopenmpt/libopenmpt_version.h | sed -e 's/#define OPENMPT_API_VERSION_PREREL.*/#define OPENMPT_API_VERSION_PREREL ""/' > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  47. cat libopenmpt/libopenmpt_version.h | sed -e 's/#define OPENMPT_API_VERSION_IS_PREREL.*/#define OPENMPT_API_VERSION_IS_PREREL 0/' > libopenmpt/libopenmpt_version.h.tmp && mv libopenmpt/libopenmpt_version.h.tmp libopenmpt/libopenmpt_version.h
  48. cat libopenmpt/libopenmpt_version.mk | sed -e 's/LIBOPENMPT_VERSION_PREREL=.*/LIBOPENMPT_VERSION_PREREL=/' > libopenmpt/libopenmpt_version.mk.tmp && mv libopenmpt/libopenmpt_version.mk.tmp libopenmpt/libopenmpt_version.mk
  49. echo -n > libopenmpt/dox/changelog.md.tmp
  50. cat libopenmpt/dox/changelog.md | head -n 7 >> libopenmpt/dox/changelog.md.tmp
  51. cat libopenmpt/dox/changelog.md | head -n 8 | tail -n 1 | sed -e s/-pre/\ \(${DATE}\)/ | sed -e s/-rc/\ \(${DATE}\)/ >> libopenmpt/dox/changelog.md.tmp
  52. cat libopenmpt/dox/changelog.md | tail -n +9 >> libopenmpt/dox/changelog.md.tmp
  53. mv libopenmpt/dox/changelog.md.tmp libopenmpt/dox/changelog.md
  54. ;;
  55. release-rc)
  56. checkparam1
  57. LIBOPENMPT_VERSION_PREREL=-rc.$PARAM1
  58. writeall
  59. setprerel
  60. echo -n > libopenmpt/dox/changelog.md.tmp
  61. cat libopenmpt/dox/changelog.md | head -n 7 >> libopenmpt/dox/changelog.md.tmp
  62. cat libopenmpt/dox/changelog.md | head -n 8 | tail -n 1 | sed -e s/-pre/-rc/ >> libopenmpt/dox/changelog.md.tmp
  63. cat libopenmpt/dox/changelog.md | tail -n +9 >> libopenmpt/dox/changelog.md.tmp
  64. mv libopenmpt/dox/changelog.md.tmp libopenmpt/dox/changelog.md
  65. ;;
  66. bumpmajor)
  67. checkclean
  68. LIBOPENMPT_VERSION_MAJOR=$(($LIBOPENMPT_VERSION_MAJOR + 1))
  69. LIBOPENMPT_VERSION_MINOR=0
  70. LIBOPENMPT_VERSION_PATCH=0
  71. LIBOPENMPT_VERSION_PRERELVER=0
  72. LIBOPENMPT_VERSION_PREREL=-pre.0
  73. writeall
  74. setprerel
  75. addchangelog
  76. ;;
  77. bumpminor)
  78. checkclean
  79. LIBOPENMPT_VERSION_MINOR=$(($LIBOPENMPT_VERSION_MINOR + 1))
  80. LIBOPENMPT_VERSION_PATCH=0
  81. LIBOPENMPT_VERSION_PRERELVER=0
  82. LIBOPENMPT_VERSION_PREREL=-pre.0
  83. writeall
  84. setprerel
  85. addchangelog
  86. ;;
  87. bumppatch)
  88. checkclean
  89. LIBOPENMPT_VERSION_PATCH=$(($LIBOPENMPT_VERSION_PATCH + 1))
  90. LIBOPENMPT_VERSION_PRERELVER=0
  91. LIBOPENMPT_VERSION_PREREL=-pre.0
  92. writeall
  93. setprerel
  94. addchangelog
  95. ;;
  96. bumpprerel)
  97. LIBOPENMPT_VERSION_PRERELVER=$(($LIBOPENMPT_VERSION_PRERELVER + 1))
  98. LIBOPENMPT_VERSION_PREREL=-pre.$LIBOPENMPT_VERSION_PRERELVER
  99. writeall
  100. setprerel
  101. ;;
  102. breakltabi)
  103. checkclean
  104. LIBOPENMPT_LTVER_CURRENT=$(($LIBOPENMPT_LTVER_CURRENT + 1))
  105. LIBOPENMPT_LTVER_REVISION=0
  106. LIBOPENMPT_LTVER_AGE=0
  107. writeall
  108. ;;
  109. bumpltabi)
  110. LIBOPENMPT_LTVER_CURRENT=$(($LIBOPENMPT_LTVER_CURRENT + 1))
  111. LIBOPENMPT_LTVER_REVISION=0
  112. LIBOPENMPT_LTVER_AGE=$(($LIBOPENMPT_LTVER_AGE + 1))
  113. writeall
  114. ;;
  115. bumpltrev)
  116. LIBOPENMPT_LTVER_REVISION=$(($LIBOPENMPT_LTVER_REVISION + 1))
  117. writeall
  118. ;;
  119. *)
  120. echo "error: Wrong argument"
  121. exit 1
  122. ;;
  123. esac