blob: d76e313c8b3d045b98d27c6360835ff09fe8f27b [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>]
Simon Butcher768594d2016-05-23 00:22:58 +010012# [ -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 ;;
Paul Bakker34558732012-11-26 17:18:12 +010032 -v|--verbose)
33 # Be verbose
34 VERBOSE="1"
35 ;;
36 -h|--help)
37 # print help
38 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020039 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010040 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020041 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
Paul Bakker34558732012-11-26 17:18:12 +010042 echo -e " -v|--verbose\t\tVerbose."
43 exit 1
44 ;;
45 *)
46 # print error
47 echo "Unknown argument: '$1'"
48 exit 1
49 ;;
50 esac
51 shift
52done
53
54if [ "X" = "X$VERSION" ];
55then
56 echo "No version specified. Unable to continue."
57 exit 1
58fi
59
60[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020061sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010062mv tmp library/CMakeLists.txt
63
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020064if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010065then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020066 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
67 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010068 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010069
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020070 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
71 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
72 mv tmp library/Makefile
73fi
74
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000075[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +010076read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
77VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000078cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020079 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
80 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
81 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
82 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
83 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
84 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +010085 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000086mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +010087
88[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020089sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +010090mv tmp tests/suites/test_suite_version.data
91
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +000092[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
93for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +010094do
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020095 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +010096 mv tmp $i
97done
98
Paul Bakker0f90d7d2014-04-30 11:49:44 +020099[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200100scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200101
Jaeden Amero03c60de2019-02-28 11:37:23 +0000102[ $VERBOSE ] && echo "Re-generating programs/test/query_config.c"
Andres Amaya Garcia4c981a02018-10-16 22:13:57 +0100103scripts/generate_query_config.pl
104
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200105[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200106scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200107
108[ $VERBOSE ] && echo "Re-generating visualc files"
109scripts/generate_visualc_files.pl
Simon Butcher768594d2016-05-23 00:22:58 +0100110