Skip to content

Commit 28cf8d8

Browse files
author
sandro
committed
package: unify version numbers
1 parent d917b48 commit 28cf8d8

7 files changed

Lines changed: 29 additions & 15 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
project(log4cpp VERSION 4.0.5 LANGUAGES CXX)
3+
# Single source of truth for release version (also used by packaging scripts).
4+
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" _log4cpp_version_raw)
5+
string(STRIP "${_log4cpp_version_raw}" _log4cpp_version)
6+
7+
project(log4cpp VERSION ${_log4cpp_version} LANGUAGES CXX)
48

59
include(GNUInstallDirs)
610

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ project(log4cpp-demo)
8282
add_executable(demo main.cpp)
8383
8484
include(FetchContent)
85-
FetchContent_Declare(log4cpp GIT_REPOSITORY https://github.com/lwhttpdorg/log4cpp.git GIT_TAG v4.0.5)
85+
FetchContent_Declare(log4cpp GIT_REPOSITORY https://github.com/lwhttpdorg/log4cpp.git GIT_TAG v4.0.6)
8686
FetchContent_MakeAvailable(log4cpp)
8787
target_link_libraries(demo log4cpp)
8888
```
@@ -561,11 +561,14 @@ Build RPM:
561561

562562
```shell
563563
rpmdev-setuptree
564-
tar -czf ~/rpmbuild/SOURCES/liblog4cpp-4.0.5.tar.gz log4cpp/
565-
cp log4cpp/liblog4cpp.spec rpmbuild/SPECS/
564+
VERSION=$(sed -n 's/^project(log4cpp VERSION \([0-9.]*\).*/\1/p' log4cpp/CMakeLists.txt)
565+
tar -czf ~/rpmbuild/SOURCES/liblog4cpp-${VERSION}.tar.gz log4cpp/
566+
sed "s/@VERSION@/${VERSION}/g" log4cpp/liblog4cpp.spec.in > ~/rpmbuild/SPECS/liblog4cpp.spec
566567
rpmbuild -ba ~/rpmbuild/SPECS/liblog4cpp.spec
567568
```
568569

570+
The tarball name and spec `Version` come from `liblog4cpp.spec.in` after substituting `@VERSION@`; that value should match `project(log4cpp VERSION …)` in `CMakeLists.txt` (see `build-rpm.sh`).
571+
569572
#### 4.4.2. Using build script
570573

571574
This project provides a build script `build-rpm.sh` and `build-deb.sh` to build RPM and DEB packages

README_ZH.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ project(log4cpp-demo)
7777
add_executable(demo main.cpp)
7878
7979
include(FetchContent)
80-
FetchContent_Declare(log4cpp GIT_REPOSITORY https://github.com/lwhttpdorg/log4cpp.git GIT_TAG v4.0.5)
80+
FetchContent_Declare(log4cpp GIT_REPOSITORY https://github.com/lwhttpdorg/log4cpp.git GIT_TAG v4.0.6)
8181
FetchContent_MakeAvailable(log4cpp)
8282
target_link_libraries(demo log4cpp)
8383
```
@@ -550,11 +550,14 @@ DEB_BUILD_OPTIONS="noddebs" dpkg-buildpackage -us -uc -b -j$(nproc)
550550

551551
```shell
552552
rpmdev-setuptree
553-
tar -czf ~/rpmbuild/SOURCES/liblog4cpp-4.0.5.tar.gz log4cpp/
554-
cp log4cpp/liblog4cpp.spec rpmbuild/SPECS/
553+
VERSION=$(sed -n 's/^project(log4cpp VERSION \([0-9.]*\).*/\1/p' log4cpp/CMakeLists.txt)
554+
tar -czf ~/rpmbuild/SOURCES/liblog4cpp-${VERSION}.tar.gz log4cpp/
555+
sed "s/@VERSION@/${VERSION}/g" log4cpp/liblog4cpp.spec.in > ~/rpmbuild/SPECS/liblog4cpp.spec
555556
rpmbuild -ba ~/rpmbuild/SPECS/liblog4cpp.spec
556557
```
557558

559+
源码包与 spec 中的版本由 `liblog4cpp.spec.in``@VERSION@` 替换得到,应与 `CMakeLists.txt``project(log4cpp VERSION …)` 一致(亦可直接用 `build-rpm.sh`)。
560+
558561
#### 4.4.2. 使用构建脚本
559562

560563
本项目提供了构建脚本`build-rpm.sh``build-deb.sh`, 用于构建 RPM 和 DEB 软件包

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.0.6

build-rpm.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ fi
4444
echo "==> Setting up rpmbuild tree..."
4545
rpmdev-setuptree
4646

47-
echo "==> Creating source tarball..."
47+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
48+
VERSION="$(tr -d '\r\n' < "${SCRIPT_DIR}/VERSION")"
49+
50+
echo "==> Creating source tarball (version ${VERSION})..."
4851
cd ..
49-
tar -czf ~/rpmbuild/SOURCES/liblog4cpp-4.0.5.tar.gz log4cpp/
52+
tar -czf "${HOME}/rpmbuild/SOURCES/liblog4cpp-${VERSION}.tar.gz" log4cpp/
5053

51-
echo "==> Copying spec file..."
52-
cp log4cpp/liblog4cpp.spec ~/rpmbuild/SPECS/
54+
echo "==> Writing spec with VERSION from ${SCRIPT_DIR}/VERSION..."
55+
sed "s/^%define _version .*/%define _version ${VERSION}/" log4cpp/liblog4cpp.spec > "${HOME}/rpmbuild/SPECS/liblog4cpp.spec"
5356

5457
echo "==> Building RPM package..."
5558
rpmbuild -ba ~/rpmbuild/SPECS/liblog4cpp.spec

debian/changelog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
liblog4cpp (4.0.5) stable; urgency=low
1+
liblog4cpp (4.0.6) stable; urgency=low
22

33
* Fix: Avoid exceptions from std::filesystem::exists when checking config file access
44

liblog4cpp.spec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Define the version once to ensure consistency
2-
%define _version 4.0.5
1+
# Must match the first line of ../VERSION (build-rpm.sh overwrites this when building).
2+
%define _version 4.0.6
33

44
Name: liblog4cpp
55
Version: %{_version}
@@ -61,7 +61,7 @@ developing applications that use %{name}.
6161
%{_libdir}/pkgconfig/log4cpp.pc
6262

6363
%changelog
64-
* Mon Jan 19 2026 Developer <developer@log4cpp.org> - 4.0.5-1
64+
* Mon Jan 19 2026 Developer <developer@log4cpp.org> - 4.0.6-1
6565
- Initial native RPM release
6666
- Internalized nlohmann-json dependency to hide implementation details
6767
- Unified include path to /usr/include/log4cpp for standard API usage

0 commit comments

Comments
 (0)