[neon/extras/kraft/Neon/release] debian: fix build from sources without git/.git
Pino Toscano
null at kde.org
Wed Oct 4 11:17:06 BST 2023
Git commit d278dd4b8008cb85578903358328281c16a4e7a0 by Pino Toscano.
Committed on 17/09/2023 at 04:26.
Pushed by jriddell into branch 'Neon/release'.
fix build from sources without git/.git
M +5 -0 debian/changelog
A +18 -0 debian/patches/cmake-fix-empty-replace.diff
A +32 -0 debian/patches/cmake-fix-without-git.diff
M +2 -0 debian/patches/series
https://invent.kde.org/neon/extras/kraft/-/commit/d278dd4b8008cb85578903358328281c16a4e7a0
diff --git a/debian/changelog b/debian/changelog
index 01566aa..d945cfb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,11 @@ kraft (1.1-0r1) UNRELEASED; urgency=medium
- bump cmake to 3.16.0
* Pass -DAKONADI_LEGACY_BUILD=ON to cmake to build with Akonadi older than
23.04 (i.e. what currently available in Debian unstable).
+ * Fix source build without git or a .git directory around:
+ - properly handle empty inputs for string(REPLACE); patch
+ cmake-fix-empty-replace.diff
+ - do not try to get git branch information if there is no .git directory;
+ patch cmake-fix-without-git.diff
-- Debian KDE Extras Team <pkg-kde-extras at lists.alioth.debian.org> Sun, 17 Sep 2023 03:50:07 +0200
diff --git a/debian/patches/cmake-fix-empty-replace.diff b/debian/patches/cmake-fix-empty-replace.diff
new file mode 100644
index 0000000..2b4bac9
--- /dev/null
+++ b/debian/patches/cmake-fix-empty-replace.diff
@@ -0,0 +1,18 @@
+Author: Pino Toscano <pino at debian.org>
+Description: Fix cmake string(REPLACE) in case of e.g. empty input string
+ Properly quote the input string to replace, so the input parameter is properly
+ handled as single parameter in case of e.g. empty value or space inside it.
+Last-Update: 2023-09-17
+Forwarded: no
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -26,7 +26,7 @@ get_git_head_revision(GIT_REFSPEC GIT_SH
+ # via git-archive.
+ if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFOUND")
+ file(READ ${CMAKE_SOURCE_DIR}/.tag sha1_candidate)
+- string(REPLACE "\n" "" sha1_candidate ${sha1_candidate})
++ string(REPLACE "\n" "" sha1_candidate "${sha1_candidate}")
+ if (NOT ${sha1_candidate} STREQUAL "$Format:%H$")
+ message("${sha1_candidate}")
+ set (GIT_SHA1 "${sha1_candidate}")
diff --git a/debian/patches/cmake-fix-without-git.diff b/debian/patches/cmake-fix-without-git.diff
new file mode 100644
index 0000000..c662f36
--- /dev/null
+++ b/debian/patches/cmake-fix-without-git.diff
@@ -0,0 +1,32 @@
+Author: Pino Toscano <pino at debian.org>
+Description: Avoid invoking git(1) when no git directory is found
+Last-Update: 2023-09-17
+Forwarded: no
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -31,17 +31,18 @@ if ("${GIT_SHA1}" STREQUAL "GITDIR-NOTFO
+ message("${sha1_candidate}")
+ set (GIT_SHA1 "${sha1_candidate}")
+ endif()
++else()
++ execute_process(
++ COMMAND git rev-parse --abbrev-ref HEAD
++ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
++ OUTPUT_VARIABLE GIT_BRANCH
++ OUTPUT_STRIP_TRAILING_WHITESPACE
++ )
+ endif()
+
+ message(STATUS "Git dynamic information")
+ message("GIT_SHA1: ${GIT_SHA1}")
+
+-execute_process(
+- COMMAND git rev-parse --abbrev-ref HEAD
+- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+- OUTPUT_VARIABLE GIT_BRANCH
+- OUTPUT_STRIP_TRAILING_WHITESPACE
+-)
+ message("GIT_BRANCH: ${GIT_BRANCH}")
+
+ cmake_host_system_information(RESULT BUILD_HOST_NAME QUERY HOSTNAME)
diff --git a/debian/patches/series b/debian/patches/series
index 869843d..b61db1d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
tests-skip-t_defaultprovider.diff
+cmake-fix-empty-replace.diff
+cmake-fix-without-git.diff
More information about the Neon-commits
mailing list