Hi Brad and Domen and others,
Please find attached a patch on CPackDeb
- which calls the internal function for md5sum computation
- which prevents the hash of the symlinks
I believe this fixes the issue (partially or totally)
https://public.kitware.com/Bug/view.php?id=13386
It is based on my previous patch.
Thanks,
Raffi
From 780a58a38d0445d1b4b58363b734a262a07a879e Mon Sep 17 00:00:00 2001
From: Raffi Enficiaud
Date: Mon, 14 Sep 2015 14:45:12 +0200
Subject: [PATCH] CPackDeb: preventing md5sum on symlinks
- Direct call to cmSystemTools::ComputeFileMD5
- Avoiding hashing symlinks
- Tests
---
Source/CPack/cmCPackDebGenerator.cxx | 42 --
Tests/CPackComponentsDEB/CMakeLists.txt| 20 +++
...yResult-components-lintian-dpkgdeb-checks.cmake | 34 ++
.../CPackComponentsDEB/RunCPackVerifyResult.cmake | 12 +--
4 files changed, 86 insertions(+), 22 deletions(-)
diff --git a/Source/CPack/cmCPackDebGenerator.cxx
b/Source/CPack/cmCPackDebGenerator.cxx
index 981d86d..090c076 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -526,27 +526,31 @@ int cmCPackDebGenerator::createDeb()
packageFiles.begin();
fileIt != packageFiles.end(); ++ fileIt )
{
- std::string cmd = "\"";
- cmd += cmSystemTools::GetCMakeCommand();
- cmd += "\" -E md5sum \"";
- cmd += *fileIt;
- cmd += "\"";
-
- std::string output;
- int retval = -1;
- int res = cmSystemTools::RunSingleCommand(cmd.c_str(), , ,
- , toplevel.c_str(), this->GeneratorVerbose, 0);
- if ( !res || retval )
+
+// hash only regular files
+if( cmSystemTools::FileIsDirectory(*fileIt)
+ || cmSystemTools::FileIsSymlink(*fileIt))
{
-cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running cmake -E md5sum "
- << cmd << std::endl);
+ continue;
}
- // debian md5sums entries are like this:
- // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
- // thus strip the full path (with the trailing slash)
- cmSystemTools::ReplaceString(output,
- topLevelWithTrailingSlash.c_str(), "");
- out << output;
+
+char md5sum[33];
+if(!cmSystemTools::ComputeFileMD5(*fileIt, md5sum))
+{
+ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
+<< *fileIt << std::endl);
+}
+
+md5sum[32] = 0;
+
+std::string output(md5sum);
+output += " " + *fileIt + "\n";
+// debian md5sums entries are like this:
+// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
+// thus strip the full path (with the trailing slash)
+cmSystemTools::ReplaceString(output,
+ topLevelWithTrailingSlash.c_str(), "");
+out << output;
}
// each line contains a eol.
// Do not end the md5sum file with yet another (invalid)
diff --git a/Tests/CPackComponentsDEB/CMakeLists.txt
b/Tests/CPackComponentsDEB/CMakeLists.txt
index c25e33a..8ed81ac 100644
--- a/Tests/CPackComponentsDEB/CMakeLists.txt
+++ b/Tests/CPackComponentsDEB/CMakeLists.txt
@@ -93,6 +93,26 @@ if(CHMOD_PROG)
"${CMAKE_CURRENT_BINARY_DIR}/preinst;${CMAKE_CURRENT_BINARY_DIR}/prerm")
endif()
+# creates a symbolic link and a directory. Those should not be hashed.
+# warning: relocation of the symlink is not supported (symlinks with relative
+# paths)
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink mylibapp symtest)
+install(FILES ${CPackComponentsDEB_BINARY_DIR}/symtest
+DESTINATION bin
+COMPONENT applications)
+
+if(EXISTS "./dirtest")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ./dirtest)
+endif()
+execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ./dirtest)
+# BUG: apparently cannot add an empty directory
+execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ../mylibapp
./dirtest/symtest)
+# NOTE: we should not add the trailing "/" to dirtest
+install(DIRECTORY ${CPackComponentsDEB_BINARY_DIR}/dirtest
+DESTINATION bin/
+COMPONENT applications)
+
+
# We may use the CPack specific config file in order
# to tailor CPack behavior on a CPack generator specific way
diff --git
a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
index 5460b1a..c2b2417 100644
---
a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
+++
b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-lintian-dpkgdeb-checks.cmake
@@ -42,6 +42,13 @@ if(LINTIAN_EXECUTABLE)
ERROR_REGEX_STRINGS "${STRINGS_TO_AVOID}")
set(lintian_output_errors_all