CPackDeb: preventing md5sum on symlinks
- Direct call to cmSystemTools::ComputeFileMD5 - Avoiding hashing symlinks - Tests
This commit is contained in:
parent
e3ace61212
commit
7c7874c86e
|
@ -524,21 +524,24 @@ int cmCPackDebGenerator::createDeb()
|
||||||
packageFiles.begin();
|
packageFiles.begin();
|
||||||
fileIt != packageFiles.end(); ++ fileIt )
|
fileIt != packageFiles.end(); ++ fileIt )
|
||||||
{
|
{
|
||||||
std::string cmd = "\"";
|
// hash only regular files
|
||||||
cmd += cmSystemTools::GetCMakeCommand();
|
if( cmSystemTools::FileIsDirectory(*fileIt)
|
||||||
cmd += "\" -E md5sum \"";
|
|| cmSystemTools::FileIsSymlink(*fileIt))
|
||||||
cmd += *fileIt;
|
|
||||||
cmd += "\"";
|
|
||||||
|
|
||||||
std::string output;
|
|
||||||
int retval = -1;
|
|
||||||
int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &output,
|
|
||||||
&retval, toplevel.c_str(), this->GeneratorVerbose, 0);
|
|
||||||
if ( !res || retval )
|
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running cmake -E md5sum "
|
continue;
|
||||||
<< cmd << std::endl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:
|
// debian md5sums entries are like this:
|
||||||
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
|
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake
|
||||||
// thus strip the full path (with the trailing slash)
|
// thus strip the full path (with the trailing slash)
|
||||||
|
|
|
@ -99,6 +99,25 @@ if(CHMOD_PROG)
|
||||||
set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
|
set(CPACK_DEBIAN_APPLICATIONS_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
|
||||||
endif()
|
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
|
# We may use the CPack specific config file in order
|
||||||
# to tailor CPack behavior on a CPack generator specific way
|
# to tailor CPack behavior on a CPack generator specific way
|
||||||
# (Behavior would be different for RPM or TGZ or DEB ...)
|
# (Behavior would be different for RPM or TGZ or DEB ...)
|
||||||
|
|
|
@ -36,7 +36,7 @@ find_program(LINTIAN_EXECUTABLE lintian)
|
||||||
if(LINTIAN_EXECUTABLE)
|
if(LINTIAN_EXECUTABLE)
|
||||||
set(lintian_output_errors_all "")
|
set(lintian_output_errors_all "")
|
||||||
foreach(_f IN LISTS actual_output)
|
foreach(_f IN LISTS actual_output)
|
||||||
set(STRINGS_TO_AVOID "E:([^\r\n]*)control-file-has-bad-permissions")
|
set(STRINGS_TO_AVOID "E:([^\r\n]*)control-file-has-bad-permissions" "E:([^\r\n]*)md5sums-lists-nonexistent-file")
|
||||||
lintian_check_specific_errors(lintian_output_errors
|
lintian_check_specific_errors(lintian_output_errors
|
||||||
FILENAME "${_f}"
|
FILENAME "${_f}"
|
||||||
ERROR_REGEX_STRINGS "${STRINGS_TO_AVOID}")
|
ERROR_REGEX_STRINGS "${STRINGS_TO_AVOID}")
|
||||||
|
|
|
@ -137,6 +137,8 @@ endfunction()
|
||||||
|
|
||||||
|
|
||||||
# This function runs dpkg-deb on a .deb and returns its output
|
# This function runs dpkg-deb on a .deb and returns its output
|
||||||
|
# the default behaviour it to run "--info" on the specified Debian package
|
||||||
|
# ACTION is one of the option accepted by dpkg-deb
|
||||||
function(run_dpkgdeb dpkg_deb_output)
|
function(run_dpkgdeb dpkg_deb_output)
|
||||||
set(${dpkg_deb_output} "" PARENT_SCOPE)
|
set(${dpkg_deb_output} "" PARENT_SCOPE)
|
||||||
|
|
||||||
|
@ -144,7 +146,7 @@ function(run_dpkgdeb dpkg_deb_output)
|
||||||
if(DPKGDEB_EXECUTABLE)
|
if(DPKGDEB_EXECUTABLE)
|
||||||
|
|
||||||
set(options "")
|
set(options "")
|
||||||
set(oneValueArgs "FILENAME")
|
set(oneValueArgs "FILENAME" "ACTION")
|
||||||
set(multiValueArgs "")
|
set(multiValueArgs "")
|
||||||
cmake_parse_arguments(run_dpkgdeb_deb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
cmake_parse_arguments(run_dpkgdeb_deb "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||||
|
|
||||||
|
@ -153,8 +155,12 @@ function(run_dpkgdeb dpkg_deb_output)
|
||||||
message(FATAL_ERROR "error: run_dpkgdeb needs FILENAME to be set")
|
message(FATAL_ERROR "error: run_dpkgdeb needs FILENAME to be set")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# run lintian
|
if(NOT run_dpkgdeb_deb_ACTION)
|
||||||
execute_process(COMMAND ${DPKGDEB_EXECUTABLE} -I ${run_dpkgdeb_deb_FILENAME}
|
set(run_dpkgdeb_deb_ACTION "--info")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# run dpkg-deb
|
||||||
|
execute_process(COMMAND ${DPKGDEB_EXECUTABLE} ${run_dpkgdeb_deb_ACTION} ${run_dpkgdeb_deb_FILENAME}
|
||||||
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
|
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
|
||||||
OUTPUT_VARIABLE DPKGDEB_OUTPUT
|
OUTPUT_VARIABLE DPKGDEB_OUTPUT
|
||||||
RESULT_VARIABLE DPKGDEB_RESULT
|
RESULT_VARIABLE DPKGDEB_RESULT
|
||||||
|
|
Loading…
Reference in New Issue