diff --git a/packaging/linux/build-deb.sh b/packaging/linux/build-deb.sh index 58d598a..a582483 100755 --- a/packaging/linux/build-deb.sh +++ b/packaging/linux/build-deb.sh @@ -17,6 +17,11 @@ mkdir -p "$DIST_DIR" rm -rf "$STAGE_DIR" mkdir -p "$PKG_ROOT/DEBIAN" +# Read VERSION only after the build (which reconfigures CMakeCache.txt if +# CMakeLists.txt changed since the build dir was last configured) -- +# reading it beforehand risks packaging a stale version string. +cmake --build "$BUILD_DIR" -j + VERSION="$(sed -n 's/^CMAKE_PROJECT_VERSION:STATIC=//p' "$BUILD_DIR/CMakeCache.txt" | head -n1)" ARCH="$(dpkg --print-architecture)" @@ -25,7 +30,6 @@ if [[ -z "$VERSION" ]]; then exit 1 fi -cmake --build "$BUILD_DIR" -j cmake --install "$BUILD_DIR" --prefix "$PKG_ROOT/usr" cat > "$PKG_ROOT/DEBIAN/control" <&2 - exit 1 -fi - MACDEPLOYQT="$(brew --prefix qt@6)/bin/macdeployqt" if [[ ! -x "$MACDEPLOYQT" ]]; then echo "macdeployqt not found at $MACDEPLOYQT" >&2 @@ -31,7 +25,17 @@ mkdir -p "$DIST_DIR" rm -rf "$STAGE_DIR" "$INSTALL_PREFIX" mkdir -p "$STAGE_DIR" +# Read VERSION only after the build (which reconfigures CMakeCache.txt if +# CMakeLists.txt changed since the build dir was last configured) -- +# reading it beforehand risks packaging a stale version string. cmake --build "$BUILD_DIR" -j + +VERSION="$(sed -n 's/^CMAKE_PROJECT_VERSION:STATIC=//p' "$BUILD_DIR/CMakeCache.txt" | head -n1)" +if [[ -z "$VERSION" ]]; then + echo "Unable to determine project version from $BUILD_DIR/CMakeCache.txt" >&2 + exit 1 +fi + cmake --install "$BUILD_DIR" --prefix "$INSTALL_PREFIX" if [[ ! -d "$INSTALL_PREFIX/$APP_BUNDLE" ]]; then