From b06870e5ff03da40ac265b8ba3bd84d5223bcf6b Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Wed, 20 Sep 2017 00:00:42 +0200 Subject: CPack: use a distinct checksum file for each generator Different CPack generators could produce checksum files with the same name which were overwritten by each other since only package name without extensions was used for checksum file name generation. This patch adds package extension to checksum files to prevent collisions. Fixes: #16840 --- Source/CPack/cmCPackGenerator.cxx | 3 +-- Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e72fcc1..f56b5fa 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -999,8 +999,7 @@ int cmCPackGenerator::DoPackage() /* Generate checksum file */ if (crypto.get() != nullptr) { std::string hashFile(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); - hashFile += - "/" + filename.substr(0, filename.rfind(this->GetOutputExtension())); + hashFile += "/" + filename; hashFile += "." + cmSystemTools::LowerCase(algo); cmsys::ofstream outF(hashFile.c_str()); if (!outF) { diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake index e4f9618..2bb4d3f 100644 --- a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -1,8 +1,7 @@ if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) + string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} CHECKSUM_EXTENSION) file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") - file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") - file(STRINGS ${CSUMFILE} CHSUM_VALUE) + file(STRINGS ${PACKAGE}.${CHECKSUM_EXTENSION} CHSUM_VALUE) file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) set(expected_value "${expected_value} ${PACKAGE}") -- cgit v0.12