blob: df629e9243e6b93c777001740ef823db991df195 [file] [log] [blame]
Paul Bakker34558732012-11-26 17:18:12 +01001#!/bin/bash
Simon Butcher768594d2016-05-23 00:22:58 +01002#
Bence Szépkúti1e148272020-08-07 13:07:28 +02003# Copyright The Mbed TLS Contributors
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02004# SPDX-License-Identifier: Apache-2.0
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
Simon Butcher768594d2016-05-23 00:22:58 +010018# Purpose
19#
20# Sets the version numbers in the source code to those given.
21#
22# Usage: bump_version.sh [ --version <version> ] [ --so-crypto <version>]
23# [ --so-x509 <version> ] [ --so-tls <version> ]
24# [ -v | --verbose ] [ -h | --help ]
25#
Paul Bakker34558732012-11-26 17:18:12 +010026
27VERSION=""
28SOVERSION=""
29
30# Parse arguments
31#
32until [ -z "$1" ]
33do
34 case "$1" in
35 --version)
36 # Version to use
37 shift
38 VERSION=$1
39 ;;
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020040 --so-crypto)
Paul Bakker34558732012-11-26 17:18:12 +010041 shift
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020042 SO_CRYPTO=$1
43 ;;
44 --so-x509)
45 shift
46 SO_X509=$1
47 ;;
48 --so-tls)
49 shift
50 SO_TLS=$1
Paul Bakker34558732012-11-26 17:18:12 +010051 ;;
52 -v|--verbose)
53 # Be verbose
54 VERBOSE="1"
55 ;;
56 -h|--help)
57 # print help
58 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020059 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010060 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020061 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
62 echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
63 echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
Paul Bakker34558732012-11-26 17:18:12 +010064 echo -e " -v|--verbose\t\tVerbose."
65 exit 1
66 ;;
67 *)
68 # print error
69 echo "Unknown argument: '$1'"
70 exit 1
71 ;;
72 esac
73 shift
74done
75
76if [ "X" = "X$VERSION" ];
77then
78 echo "No version specified. Unable to continue."
79 exit 1
80fi
81
82[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020083sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010084mv tmp library/CMakeLists.txt
85
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020086if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010087then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020088 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
89 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010090 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010091
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020092 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
93 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
94 mv tmp library/Makefile
95fi
96
97if [ "X" != "X$SO_X509" ];
98then
99 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
100 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
101 mv tmp library/CMakeLists.txt
102
103 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
104 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
105 mv tmp library/Makefile
106fi
107
108if [ "X" != "X$SO_TLS" ];
109then
110 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
111 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
112 mv tmp library/CMakeLists.txt
113
114 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
115 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 +0100116 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +0100117fi
118
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000119[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +0100120read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
121VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000122cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200123 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
124 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
125 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
126 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
127 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
128 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100129 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000130mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100131
132[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200133sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100134mv tmp tests/suites/test_suite_version.data
135
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000136[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
137for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100138do
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200139 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100140 mv tmp $i
141done
142
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200143[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200144scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200145
Jaeden Amero7cb47de2019-02-28 11:37:23 +0000146[ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
Andres Amaya Garcia4c981a02018-10-16 22:13:57 +0100147scripts/generate_query_config.pl
148
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200149[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200150scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200151
152[ $VERBOSE ] && echo "Re-generating visualc files"
153scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100154