From 1ef92d645da2eafa2e39b09e7ce9c6f104075713 Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Sun, 12 Apr 2026 06:11:41 +0400 Subject: [PATCH] CPack/DEB: fix `md5sums` paths in dbgsym packages The Debian `lintian` tool reported the dbgsym package issue as `md5sums-lists-nonexistent-file`. The DEB generator writes `md5sums` entries by stripping a top-level prefix from each packaged file path. That used `CPACK_TEMPORARY_DIRECTORY`, which works for regular debs but not for dbgsym packages. Dbgsym package files are collected from `GEN_DBGSYMDIR` and passed to `DebGenerator` with `WorkDir` rooted there. Because the `md5sums` writer stripped `TemporaryDir` instead, the prefix did not match and absolute staging paths leaked into `md5sums`. Strip `WorkDir` instead. That is the actual root of `PackageFiles` for both regular deb and dbgsym package generation, so `md5sums` entries stay relative in both cases. --- Source/CPack/cmCPackDebGenerator.cxx | 2 +- .../CPack/tests/DEBUGINFO/VerifyResult.cmake | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/CPack/tests/DEBUGINFO/VerifyResult.cmake diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index d94e52151d..63e58a4ed9 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -302,7 +302,7 @@ std::string DebGenerator::generateMD5File() const cmGeneratedFileStream out; out.Open(md5filename, false, true); - std::string topLevelWithTrailingSlash = cmStrCat(this->TemporaryDir, '/'); + std::string topLevelWithTrailingSlash = cmStrCat(this->WorkDir, '/'); for (std::string const& file : this->PackageFiles) { // hash only regular files if (cmSystemTools::FileIsDirectory(file) || diff --git a/Tests/RunCMake/CPack/tests/DEBUGINFO/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEBUGINFO/VerifyResult.cmake new file mode 100644 index 0000000000..5ef05a30e6 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEBUGINFO/VerifyResult.cmake @@ -0,0 +1,19 @@ +if(NOT GENERATOR_TYPE STREQUAL "DEB") + return() +endif() + +set(whitespaces_ "[\t\n\r ]*") +set(hashsyms_ "[a-f0-9]+") + +set(dbgsym_md5sums_md5sums + "^(${hashsyms_} usr/lib/debug/\\.build-id/[^/\r\n]+/[^/\r\n]+\\.debug${whitespaces_})+$") +set(dbgsym_md5sums_md5sums_permissions "-rw-r--r--") + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + verifyDebControl("${FOUND_FILE_4}" "dbgsym_md5sums" "md5sums") + verifyDebControl("${FOUND_FILE_5}" "dbgsym_md5sums" "md5sums") + +elseif(PACKAGING_TYPE STREQUAL "MONOLITHIC") + verifyDebControl("${FOUND_FILE_2}" "dbgsym_md5sums" "md5sums") + +endif()