blob: 7c7bf78bf10fa19697ecae4c2c063629f4be565c [file] [log] [blame]
Paul Bakker34558732012-11-26 17:18:12 +01001#!/bin/bash
Simon Butcher768594d2016-05-23 00:22:58 +01002#
Simon Butcher768594d2016-05-23 00:22:58 +01003# Copyright (c) 2012-2016, ARM Limited, All Rights Reserved
Bence Szépkúti09b4f192020-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#
18# This file is part of Mbed TLS (https://tls.mbed.org)
Simon Butcher768594d2016-05-23 00:22:58 +010019#
20# Purpose
21#
22# Sets the version numbers in the source code to those given.
23#
24# Usage: bump_version.sh [ --version <version> ] [ --so-crypto <version>]
25# [ --so-x509 <version> ] [ --so-tls <version> ]
26# [ -v | --verbose ] [ -h | --help ]
27#
Paul Bakker34558732012-11-26 17:18:12 +010028
29VERSION=""
30SOVERSION=""
31
32# Parse arguments
33#
34until [ -z "$1" ]
35do
36 case "$1" in
37 --version)
38 # Version to use
39 shift
40 VERSION=$1
41 ;;
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020042 --so-crypto)
Paul Bakker34558732012-11-26 17:18:12 +010043 shift
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020044 SO_CRYPTO=$1
45 ;;
46 --so-x509)
47 shift
48 SO_X509=$1
49 ;;
50 --so-tls)
51 shift
52 SO_TLS=$1
Paul Bakker34558732012-11-26 17:18:12 +010053 ;;
54 -v|--verbose)
55 # Be verbose
56 VERBOSE="1"
57 ;;
58 -h|--help)
59 # print help
60 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020061 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010062 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020063 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
64 echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
65 echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
Paul Bakker34558732012-11-26 17:18:12 +010066 echo -e " -v|--verbose\t\tVerbose."
67 exit 1
68 ;;
69 *)
70 # print error
71 echo "Unknown argument: '$1'"
72 exit 1
73 ;;
74 esac
75 shift
76done
77
78if [ "X" = "X$VERSION" ];
79then
80 echo "No version specified. Unable to continue."
81 exit 1
82fi
83
84[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020085sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010086mv tmp library/CMakeLists.txt
87
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020088if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010089then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020090 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
91 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010092 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010093
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020094 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
95 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
96 mv tmp library/Makefile
97fi
98
99if [ "X" != "X$SO_X509" ];
100then
101 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
102 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
103 mv tmp library/CMakeLists.txt
104
105 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
106 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
107 mv tmp library/Makefile
108fi
109
110if [ "X" != "X$SO_TLS" ];
111then
112 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
113 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
114 mv tmp library/CMakeLists.txt
115
116 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
117 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 +0100118 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +0100119fi
120
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000121[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +0100122read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
123VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000124cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200125 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
126 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
127 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
128 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
129 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
130 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100131 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000132mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100133
134[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200135sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100136mv tmp tests/suites/test_suite_version.data
137
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000138[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
139for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100140do
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200141 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100142 mv tmp $i
143done
144
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200145[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200146scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200147
148[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200149scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200150
151[ $VERBOSE ] && echo "Re-generating visualc files"
152scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100153