1#!/bin/bash 2 3print_usage() 4{ 5 cat <<EOF 6Usage: $0 [OPTION]... 7Prepare the source tree for a release. 8 9Options: 10 -u Prepare for development (undo the release preparation) 11EOF 12} 13 14# Copyright The Mbed TLS Contributors 15# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 16 17set -eu 18 19if [ $# -ne 0 ] && [ "$1" = "--help" ]; then 20 print_usage 21 exit 22fi 23 24unrelease= # if non-empty, we're in undo-release mode 25while getopts u OPTLET; do 26 case $OPTLET in 27 u) unrelease=1;; 28 \?) 29 echo 1>&2 "$0: unknown option: -$OPTLET" 30 echo 1>&2 "Try '$0 --help' for more information." 31 exit 3;; 32 esac 33done 34 35 36 37#### .gitignore processing #### 38 39GITIGNORES=$(find . -name ".gitignore") 40for GITIGNORE in $GITIGNORES; do 41 if [ -n "$unrelease" ]; then 42 sed -i '/###START_COMMENTED_GENERATED_FILES###/,/###END_COMMENTED_GENERATED_FILES###/s/^# //' $GITIGNORE 43 sed -i 's/###START_COMMENTED_GENERATED_FILES###/###START_GENERATED_FILES###/' $GITIGNORE 44 sed -i 's/###END_COMMENTED_GENERATED_FILES###/###END_GENERATED_FILES###/' $GITIGNORE 45 else 46 sed -i '/###START_GENERATED_FILES###/,/###END_GENERATED_FILES###/s/^/# /' $GITIGNORE 47 sed -i 's/###START_GENERATED_FILES###/###START_COMMENTED_GENERATED_FILES###/' $GITIGNORE 48 sed -i 's/###END_GENERATED_FILES###/###END_COMMENTED_GENERATED_FILES###/' $GITIGNORE 49 fi 50done 51 52 53 54#### Build scripts #### 55 56# GEN_FILES defaults on (non-empty) in development, off (empty) in releases 57if [ -n "$unrelease" ]; then 58 r=' yes' 59else 60 r='' 61fi 62sed -i 's/^\(GEN_FILES[ ?:]*=\)\([^#]*\)/\1'"$r/" Makefile */Makefile 63 64# GEN_FILES defaults on in development, off in releases 65if [ -n "$unrelease" ]; then 66 r='ON' 67else 68 r='OFF' 69fi 70sed -i '/[Oo][Ff][Ff] in development/! s/^\( *option *( *GEN_FILES *"[^"]*" *\)\([A-Za-z0-9][A-Za-z0-9]*\)/\1'"$r/" CMakeLists.txt 71