blob: cf875c88d8ec896e6c6745ba0f8a64602c258109 [file] [log] [blame]
Paul Bakker34558732012-11-26 17:18:12 +01001#!/bin/bash
Simon Butcher768594d2016-05-23 00:22:58 +01002#
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#
Paul Bakker34558732012-11-26 17:18:12 +010015
16VERSION=""
17SOVERSION=""
18
19# Parse arguments
20#
21until [ -z "$1" ]
22do
23 case "$1" in
24 --version)
25 # Version to use
26 shift
27 VERSION=$1
28 ;;
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020029 --so-crypto)
Paul Bakker34558732012-11-26 17:18:12 +010030 shift
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020031 SO_CRYPTO=$1
32 ;;
33 --so-x509)
34 shift
35 SO_X509=$1
36 ;;
37 --so-tls)
38 shift
39 SO_TLS=$1
Paul Bakker34558732012-11-26 17:18:12 +010040 ;;
41 -v|--verbose)
42 # Be verbose
43 VERBOSE="1"
44 ;;
45 -h|--help)
46 # print help
47 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020048 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010049 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020050 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
51 echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
52 echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
Paul Bakker34558732012-11-26 17:18:12 +010053 echo -e " -v|--verbose\t\tVerbose."
54 exit 1
55 ;;
56 *)
57 # print error
58 echo "Unknown argument: '$1'"
59 exit 1
60 ;;
61 esac
62 shift
63done
64
65if [ "X" = "X$VERSION" ];
66then
67 echo "No version specified. Unable to continue."
68 exit 1
69fi
70
71[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020072sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010073mv tmp library/CMakeLists.txt
74
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020075if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010076then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020077 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
78 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010079 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010080
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020081 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
82 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
83 mv tmp library/Makefile
84fi
85
86if [ "X" != "X$SO_X509" ];
87then
88 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
89 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
90 mv tmp library/CMakeLists.txt
91
92 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
93 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
94 mv tmp library/Makefile
95fi
96
97if [ "X" != "X$SO_TLS" ];
98then
99 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
100 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
101 mv tmp library/CMakeLists.txt
102
103 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
104 sed -e "s/SOEXT_TLS=so.[0-9]\{1,\}/SOEXT_TLS=so.$SO_TLS/g" < library/Makefile > tmp
Paul Bakker91180722013-11-05 11:28:32 +0100105 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +0100106fi
107
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000108[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +0100109read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
110VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000111cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200112 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
113 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
114 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
115 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
116 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
117 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100118 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000119mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100120
121[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200122sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100123mv tmp tests/suites/test_suite_version.data
124
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000125[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
126for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100127do
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200128 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100129 mv tmp $i
130done
131
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200132[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200133scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200134
Jaeden Amero7cb47de2019-02-28 11:37:23 +0000135[ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
Andres Amaya Garcia4c981a02018-10-16 22:13:57 +0100136scripts/generate_query_config.pl
137
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200138[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200139scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200140
141[ $VERBOSE ] && echo "Re-generating visualc files"
142scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100143