blob: 926e497b4eb5b5b118b8f3fe00d3540cfc9eb7a1 [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
Dave Rodgman7ff79652023-11-03 12:04:52 +00004# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02005#
Simon Butcher768594d2016-05-23 00:22:58 +01006# 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#
Paul Bakker34558732012-11-26 17:18:12 +010014
15VERSION=""
16SOVERSION=""
17
18# Parse arguments
19#
20until [ -z "$1" ]
21do
22 case "$1" in
23 --version)
24 # Version to use
25 shift
26 VERSION=$1
27 ;;
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020028 --so-crypto)
Paul Bakker34558732012-11-26 17:18:12 +010029 shift
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020030 SO_CRYPTO=$1
31 ;;
32 --so-x509)
33 shift
34 SO_X509=$1
35 ;;
36 --so-tls)
37 shift
38 SO_TLS=$1
Paul Bakker34558732012-11-26 17:18:12 +010039 ;;
40 -v|--verbose)
41 # Be verbose
42 VERBOSE="1"
43 ;;
44 -h|--help)
45 # print help
46 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020047 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010048 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020049 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
50 echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
51 echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
Paul Bakker34558732012-11-26 17:18:12 +010052 echo -e " -v|--verbose\t\tVerbose."
53 exit 1
54 ;;
55 *)
56 # print error
57 echo "Unknown argument: '$1'"
58 exit 1
59 ;;
60 esac
61 shift
62done
63
64if [ "X" = "X$VERSION" ];
65then
66 echo "No version specified. Unable to continue."
67 exit 1
68fi
69
70[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020071sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010072mv tmp library/CMakeLists.txt
73
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020074if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010075then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020076 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
77 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010078 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010079
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020080 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
81 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
82 mv tmp library/Makefile
83fi
84
85if [ "X" != "X$SO_X509" ];
86then
87 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
88 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
89 mv tmp library/CMakeLists.txt
90
91 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
92 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
93 mv tmp library/Makefile
94fi
95
96if [ "X" != "X$SO_TLS" ];
97then
98 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
99 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
100 mv tmp library/CMakeLists.txt
101
102 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
103 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 +0100104 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +0100105fi
106
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000107[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +0100108read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
109VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000110cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200111 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
112 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
113 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
114 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
115 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
Gilles Peskinef08ca832023-09-12 19:21:54 +0200116 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"Mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100117 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000118mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100119
120[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200121sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100122mv tmp tests/suites/test_suite_version.data
123
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000124[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
125for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100126do
Gilles Peskinebd44d932023-08-03 17:22:44 +0200127 sed -e "s/\\([Mm]bed TLS v\\)[0-9][0-9.]*/\\1$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100128 mv tmp $i
129done
130
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200131[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200132scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200133
Jaeden Amero7cb47de2019-02-28 11:37:23 +0000134[ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
Andres Amaya Garcia4c981a02018-10-16 22:13:57 +0100135scripts/generate_query_config.pl
136
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200137[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200138scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200139
140[ $VERBOSE ] && echo "Re-generating visualc files"
141scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100142