bump_version.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #!/bin/bash
  2. #
  3. # This file is part of mbed TLS (https://tls.mbed.org)
  4. #
  5. # Copyright (c) 2012-2016, ARM Limited, All Rights Reserved
  6. #
  7. # Purpose
  8. #
  9. # Sets the version numbers in the source code to those given.
  10. #
  11. # Usage: bump_version.sh [ --version <version> ] [ --so-crypto <version>]
  12. # [ --so-x509 <version> ] [ --so-tls <version> ]
  13. # [ -v | --verbose ] [ -h | --help ]
  14. #
  15. VERSION=""
  16. SOVERSION=""
  17. # Parse arguments
  18. #
  19. until [ -z "$1" ]
  20. do
  21. case "$1" in
  22. --version)
  23. # Version to use
  24. shift
  25. VERSION=$1
  26. ;;
  27. --so-crypto)
  28. shift
  29. SO_CRYPTO=$1
  30. ;;
  31. --so-x509)
  32. shift
  33. SO_X509=$1
  34. ;;
  35. --so-tls)
  36. shift
  37. SO_TLS=$1
  38. ;;
  39. -v|--verbose)
  40. # Be verbose
  41. VERBOSE="1"
  42. ;;
  43. -h|--help)
  44. # print help
  45. echo "Usage: $0"
  46. echo -e " -h|--help\t\tPrint this help."
  47. echo -e " --version <version>\tVersion to bump to."
  48. echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
  49. echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
  50. echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
  51. echo -e " -v|--verbose\t\tVerbose."
  52. exit 1
  53. ;;
  54. *)
  55. # print error
  56. echo "Unknown argument: '$1'"
  57. exit 1
  58. ;;
  59. esac
  60. shift
  61. done
  62. if [ "X" = "X$VERSION" ];
  63. then
  64. echo "No version specified. Unable to continue."
  65. exit 1
  66. fi
  67. [ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
  68. sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
  69. mv tmp library/CMakeLists.txt
  70. if [ "X" != "X$SO_CRYPTO" ];
  71. then
  72. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
  73. sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
  74. mv tmp library/CMakeLists.txt
  75. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
  76. sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
  77. mv tmp library/Makefile
  78. fi
  79. if [ "X" != "X$SO_X509" ];
  80. then
  81. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
  82. sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
  83. mv tmp library/CMakeLists.txt
  84. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
  85. sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
  86. mv tmp library/Makefile
  87. fi
  88. if [ "X" != "X$SO_TLS" ];
  89. then
  90. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
  91. sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
  92. mv tmp library/CMakeLists.txt
  93. [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
  94. sed -e "s/SOEXT_TLS=so.[0-9]\{1,\}/SOEXT_TLS=so.$SO_TLS/g" < library/Makefile > tmp
  95. mv tmp library/Makefile
  96. fi
  97. [ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
  98. read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
  99. VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
  100. cat include/mbedtls/version.h | \
  101. sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
  102. sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
  103. sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
  104. sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
  105. sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
  106. sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
  107. > tmp
  108. mv tmp include/mbedtls/version.h
  109. [ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
  110. sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
  111. mv tmp tests/suites/test_suite_version.data
  112. [ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
  113. for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
  114. do
  115. sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
  116. mv tmp $i
  117. done
  118. [ $VERBOSE ] && echo "Re-generating library/error.c"
  119. scripts/generate_errors.pl
  120. [ $VERBOSE ] && echo "Re-generating programs/ssl/query_config.c"
  121. scripts/generate_query_config.pl
  122. [ $VERBOSE ] && echo "Re-generating library/version_features.c"
  123. scripts/generate_features.pl
  124. [ $VERBOSE ] && echo "Re-generating visualc files"
  125. scripts/generate_visualc_files.pl