File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11cmake_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
59include (GNUInstallDirs )
610
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ project(log4cpp-demo)
8282add_executable(demo main.cpp)
8383
8484include(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 )
8686FetchContent_MakeAvailable(log4cpp)
8787target_link_libraries(demo log4cpp)
8888```
@@ -561,11 +561,14 @@ Build RPM:
561561
562562``` shell
563563rpmdev-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
566567rpmbuild -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
571574This project provides a build script ` build-rpm.sh ` and ` build-deb.sh ` to build RPM and DEB packages
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ project(log4cpp-demo)
7777add_executable(demo main.cpp)
7878
7979include(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 )
8181FetchContent_MakeAvailable(log4cpp)
8282target_link_libraries(demo log4cpp)
8383```
@@ -550,11 +550,14 @@ DEB_BUILD_OPTIONS="noddebs" dpkg-buildpackage -us -uc -b -j$(nproc)
550550
551551``` shell
552552rpmdev-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
555556rpmbuild -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 软件包
Original file line number Diff line number Diff line change 1+ 4.0.6
Original file line number Diff line number Diff line change 4444echo " ==> Setting up rpmbuild tree..."
4545rpmdev-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} )..."
4851cd ..
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
5457echo " ==> Building RPM package..."
5558rpmbuild -ba ~ /rpmbuild/SPECS/liblog4cpp.spec
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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
44Name: liblog4cpp
55Version: %{_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
You can’t perform that action at this time.
0 commit comments