quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

bump_version.sh (4853B)


      1 #!/bin/bash
      2 #
      3 # Copyright The Mbed TLS Contributors
      4 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
      5 #
      6 # Purpose
      7 #
      8 # Sets the version numbers in the source code to those given.
      9 #
     10 # Usage: bump_version.sh [ --version <version> ] [ --so-crypto <version>]
     11 #                           [ --so-x509 <version> ] [ --so-tls <version> ]
     12 #                           [ -v | --verbose ] [ -h | --help ]
     13 #
     14 
     15 set -e
     16 
     17 VERSION=""
     18 SOVERSION=""
     19 
     20 # Parse arguments
     21 #
     22 until [ -z "$1" ]
     23 do
     24   case "$1" in
     25     --version)
     26       # Version to use
     27       shift
     28       VERSION=$1
     29       ;;
     30     --so-crypto)
     31       shift
     32       SO_CRYPTO=$1
     33       ;;
     34     --so-x509)
     35       shift
     36       SO_X509=$1
     37       ;;
     38     --so-tls)
     39       shift
     40       SO_TLS=$1
     41       ;;
     42     -v|--verbose)
     43       # Be verbose
     44       VERBOSE="1"
     45       ;;
     46     -h|--help)
     47       # print help
     48       echo "Usage: $0"
     49       echo -e "  -h|--help\t\tPrint this help."
     50       echo -e "  --version <version>\tVersion to bump to."
     51       echo -e "  --so-crypto <version>\tSO version to bump libmbedcrypto to."
     52       echo -e "  --so-x509 <version>\tSO version to bump libmbedx509 to."
     53       echo -e "  --so-tls <version>\tSO version to bump libmbedtls to."
     54       echo -e "  -v|--verbose\t\tVerbose."
     55       exit 1
     56       ;;
     57     *)
     58       # print error
     59       echo "Unknown argument: '$1'"
     60       exit 1
     61       ;;
     62   esac
     63   shift
     64 done
     65 
     66 if [ "X" = "X$VERSION" ];
     67 then
     68   echo "No version specified. Unable to continue."
     69   exit 1
     70 fi
     71 
     72 [ $VERBOSE ] && echo "Bumping VERSION in CMakeLists.txt"
     73 sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < CMakeLists.txt > tmp
     74 mv tmp CMakeLists.txt
     75 
     76 [ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
     77 sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
     78 mv tmp library/CMakeLists.txt
     79 
     80 if [ "X" != "X$SO_CRYPTO" ];
     81 then
     82   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
     83   sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
     84   mv tmp library/CMakeLists.txt
     85 
     86   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
     87   sed -e "s/SOEXT_CRYPTO?=so.[0-9]\{1,\}/SOEXT_CRYPTO?=so.$SO_CRYPTO/g" < library/Makefile > tmp
     88   mv tmp library/Makefile
     89 fi
     90 
     91 if [ "X" != "X$SO_X509" ];
     92 then
     93   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
     94   sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
     95   mv tmp library/CMakeLists.txt
     96 
     97   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
     98   sed -e "s/SOEXT_X509?=so.[0-9]\{1,\}/SOEXT_X509?=so.$SO_X509/g" < library/Makefile > tmp
     99   mv tmp library/Makefile
    100 fi
    101 
    102 if [ "X" != "X$SO_TLS" ];
    103 then
    104   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
    105   sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
    106   mv tmp library/CMakeLists.txt
    107 
    108   [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
    109   sed -e "s/SOEXT_TLS?=so.[0-9]\{1,\}/SOEXT_TLS?=so.$SO_TLS/g" < library/Makefile > tmp
    110   mv tmp library/Makefile
    111 fi
    112 
    113 [ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/build_info.h"
    114 read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
    115 VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
    116 cat include/mbedtls/build_info.h |                                    \
    117     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_MAJOR .\{1,\}/\1_MAJOR  $MAJOR/" |    \
    118     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_MINOR .\{1,\}/\1_MINOR  $MINOR/" |    \
    119     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_PATCH .\{1,\}/\1_PATCH  $PATCH/" |    \
    120     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_NUMBER .\{1,\}/\1_NUMBER         $VERSION_NR/" |    \
    121     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_STRING .\{1,\}/\1_STRING         \"$VERSION\"/" |    \
    122     sed -e "s/\(# *define  *[A-Z]*_VERSION\)_STRING_FULL .\{1,\}/\1_STRING_FULL    \"Mbed TLS $VERSION\"/" \
    123     > tmp
    124 mv tmp include/mbedtls/build_info.h
    125 
    126 [ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
    127 sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
    128 mv tmp tests/suites/test_suite_version.data
    129 
    130 [ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
    131 for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
    132 do
    133   sed -e "s/\\([Mm]bed TLS v\\)[0-9][0-9.]*/\\1$VERSION/g" < $i > tmp
    134   mv tmp $i
    135 done
    136 
    137 [ $VERBOSE ] && echo "Re-generating library/error.c"
    138 scripts/generate_errors.pl
    139 
    140 [ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
    141 scripts/generate_query_config.pl
    142 
    143 [ $VERBOSE ] && echo "Re-generating library/version_features.c"
    144 scripts/generate_features.pl
    145 
    146 [ $VERBOSE ] && echo "Re-generating visualc files"
    147 scripts/generate_visualc_files.pl
    148