2023-08-04 15:05:28 +02:00
|
|
|
#!/bin/bash
|
2023-09-08 16:34:01 +02:00
|
|
|
|
2023-09-08 16:49:14 +02:00
|
|
|
print_usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: $0 [OPTION]...
|
|
|
|
Prepare the source tree for a release.
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-u Prepare for development (undo the release preparation)
|
|
|
|
EOF
|
|
|
|
}
|
2023-09-08 16:34:01 +02:00
|
|
|
|
2023-08-04 15:05:28 +02:00
|
|
|
# Copyright The Mbed TLS Contributors
|
2023-11-02 20:47:20 +01:00
|
|
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
2023-08-04 15:05:28 +02:00
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2023-09-08 16:49:14 +02:00
|
|
|
if [ $# -ne 0 ] && [ "$1" = "--help" ]; then
|
2023-08-04 15:05:28 +02:00
|
|
|
print_usage
|
2023-09-08 16:49:14 +02:00
|
|
|
exit
|
2023-08-04 15:05:28 +02:00
|
|
|
fi
|
|
|
|
|
2023-09-08 16:49:14 +02:00
|
|
|
unrelease= # if non-empty, we're in undo-release mode
|
|
|
|
while getopts u OPTLET; do
|
|
|
|
case $OPTLET in
|
|
|
|
u) unrelease=1;;
|
|
|
|
\?)
|
|
|
|
echo 1>&2 "$0: unknown option: -$OPTLET"
|
|
|
|
echo 1>&2 "Try '$0 --help' for more information."
|
|
|
|
exit 3;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### .gitignore processing ####
|
2023-08-04 15:05:28 +02:00
|
|
|
|
|
|
|
GITIGNORES=$(find . -name ".gitignore")
|
|
|
|
for GITIGNORE in $GITIGNORES; do
|
2023-09-08 16:49:14 +02:00
|
|
|
if [ -n "$unrelease" ]; then
|
2023-08-04 15:05:28 +02:00
|
|
|
sed -i '/###START_COMMENTED_GENERATED_FILES###/,/###END_COMMENTED_GENERATED_FILES###/s/^# //' $GITIGNORE
|
|
|
|
sed -i 's/###START_COMMENTED_GENERATED_FILES###/###START_GENERATED_FILES###/' $GITIGNORE
|
|
|
|
sed -i 's/###END_COMMENTED_GENERATED_FILES###/###END_GENERATED_FILES###/' $GITIGNORE
|
|
|
|
else
|
|
|
|
sed -i '/###START_GENERATED_FILES###/,/###END_GENERATED_FILES###/s/^/# /' $GITIGNORE
|
|
|
|
sed -i 's/###START_GENERATED_FILES###/###START_COMMENTED_GENERATED_FILES###/' $GITIGNORE
|
|
|
|
sed -i 's/###END_GENERATED_FILES###/###END_COMMENTED_GENERATED_FILES###/' $GITIGNORE
|
|
|
|
fi
|
|
|
|
done
|
2023-09-08 16:49:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### Build scripts ####
|
|
|
|
|
|
|
|
# GEN_FILES defaults on (non-empty) in development, off (empty) in releases
|
|
|
|
if [ -n "$unrelease" ]; then
|
|
|
|
r=' yes'
|
|
|
|
else
|
|
|
|
r=''
|
|
|
|
fi
|
|
|
|
sed -i 's/^\(GEN_FILES[ ?:]*=\)\([^#]*\)/\1'"$r/" Makefile */Makefile
|
|
|
|
|
|
|
|
# GEN_FILES defaults on in development, off in releases
|
|
|
|
if [ -n "$unrelease" ]; then
|
|
|
|
r='ON'
|
|
|
|
else
|
|
|
|
r='OFF'
|
|
|
|
fi
|
2023-09-09 21:00:30 +02:00
|
|
|
sed -i '/[Oo][Ff][Ff] in development/! s/^\( *option *( *GEN_FILES *"[^"]*" *\)\([A-Za-z0-9][A-Za-z0-9]*\)/\1'"$r/" CMakeLists.txt
|