blob: 5c8e55d6d0dab78d64751b649334ff472b22f61d [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
Bill Robertsa4486ce2024-02-21 09:10:08 -060070[ $VERBOSE ] && echo "Bumping PKGCONFIG_VERSION in pkgconfig/CMakeLists.txt"
71sed -e "s/PKGCONFIG_VERSION [0-9.]\{1,\}/PKGCONFIG_VERSION $VERSION/g" < pkgconfig/CMakeLists.txt > tmp
72mv tmp pkgconfig/CMakeLists.txt
73
Paul Bakker34558732012-11-26 17:18:12 +010074[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020075sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010076mv tmp library/CMakeLists.txt
77
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020078if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010079then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020080 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
81 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010082 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010083
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020084 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
85 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
86 mv tmp library/Makefile
87fi
88
89if [ "X" != "X$SO_X509" ];
90then
91 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
92 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
93 mv tmp library/CMakeLists.txt
94
95 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
96 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
97 mv tmp library/Makefile
98fi
99
100if [ "X" != "X$SO_TLS" ];
101then
102 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
103 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
104 mv tmp library/CMakeLists.txt
105
106 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
107 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 +0100108 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +0100109fi
110
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000111[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +0100112read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
113VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000114cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200115 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
116 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
117 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
118 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
119 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
Gilles Peskinef08ca832023-09-12 19:21:54 +0200120 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"Mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100121 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000122mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100123
124[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200125sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100126mv tmp tests/suites/test_suite_version.data
127
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000128[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
129for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100130do
Gilles Peskinebd44d932023-08-03 17:22:44 +0200131 sed -e "s/\\([Mm]bed TLS v\\)[0-9][0-9.]*/\\1$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100132 mv tmp $i
133done
134
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200135[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200136scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200137
Jaeden Amero7cb47de2019-02-28 11:37:23 +0000138[ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
Andres Amaya Garcia4c981a02018-10-16 22:13:57 +0100139scripts/generate_query_config.pl
140
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200141[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200142scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200143
144[ $VERBOSE ] && echo "Re-generating visualc files"
145scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100146