diff --git a/build.sh b/build.sh index 9c24d4db5..d780a641b 100755 --- a/build.sh +++ b/build.sh @@ -6,10 +6,34 @@ set -eu -o pipefail -VERSION="1.0.3" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RELEASE_DIR="$SCRIPT_DIR/release" +# Derive the release version from configure.ac instead of hardcoding it here. +# A stale literal names the release directories after the wrong version while the +# binaries inside report the real one: this said 1.0.3 while the tree was already +# 1.1.0, so `./build.sh --all-release` would have produced +# release/dragonx-1.0.3-/ full of binaries announcing 1.1.0. +# Mirrors configure.ac's _CLIENT_VERSION_SUFFIX m4 exactly: +# build < 25 -> beta(build+1) build < 50 -> rc(build-24) +# build == 50 -> plain release build > 50 -> point release (build-50) +_acdef() { sed -n "s/^define(_CLIENT_VERSION_$1, *\([0-9]\{1,\}\))/\1/p" "$SCRIPT_DIR/configure.ac"; } +_V_MAJOR="$(_acdef MAJOR)" +_V_MINOR="$(_acdef MINOR)" +_V_REVISION="$(_acdef REVISION)" +_V_BUILD="$(_acdef BUILD)" +if [ -z "$_V_MAJOR" ] || [ -z "$_V_MINOR" ] || [ -z "$_V_REVISION" ] || [ -z "$_V_BUILD" ]; then + echo "ERROR: could not read the version from $SCRIPT_DIR/configure.ac" >&2 + echo " refusing to build a release whose directory name would be wrong." >&2 + exit 1 +fi +if [ "$_V_BUILD" -lt 25 ]; then _V_SUFFIX="$_V_REVISION-beta$((_V_BUILD + 1))" +elif [ "$_V_BUILD" -lt 50 ]; then _V_SUFFIX="$_V_REVISION-rc$((_V_BUILD - 24))" +elif [ "$_V_BUILD" -eq 50 ]; then _V_SUFFIX="$_V_REVISION" +else _V_SUFFIX="$_V_REVISION-$((_V_BUILD - 50))" +fi +VERSION="$_V_MAJOR.$_V_MINOR.$_V_SUFFIX" + # Parse release flags BUILD_LINUX_RELEASE=0 BUILD_WIN_RELEASE=0