From 9028195a22514ca008c3aae5de0e58e1a112e34e Mon Sep 17 00:00:00 2001 From: Alexey Rogachevskiy Date: Wed, 30 Jun 2021 15:23:07 +0300 Subject: CPackDeb: sort package files before generating deb file This should make the order in which the files are added to md5sums and archives is stable, thus making package files more reproducible. Fixes: #22361 --- Source/CPack/cmCPackDebGenerator.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 006d66d..db30a0d 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackDebGenerator.h" +#include #include #include #include @@ -525,6 +526,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, return 0; } this->packageFiles = gl.GetFiles(); + // Sort files so that they have a reproducible order + std::sort(this->packageFiles.begin(), this->packageFiles.end()); } int res = this->createDeb(); @@ -551,6 +554,8 @@ int cmCPackDebGenerator::PackageOnePack(std::string const& initialTopLevel, return 0; } this->packageFiles = gl.GetFiles(); + // Sort files so that they have a reproducible order + std::sort(this->packageFiles.begin(), this->packageFiles.end()); res = this->createDbgsymDDeb(); if (res != 1) { @@ -672,6 +677,8 @@ int cmCPackDebGenerator::PackageComponentsAllInOne( return 0; } this->packageFiles = gl.GetFiles(); + // Sort files so that they have a reproducible order + std::sort(this->packageFiles.begin(), this->packageFiles.end()); int res = this->createDeb(); if (res != 1) { -- cgit v0.12 From a0d3494afacc28ec75318470b806cea06e90eb99 Mon Sep 17 00:00:00 2001 From: Alexey Rogachevskiy Date: Wed, 30 Jun 2021 15:24:48 +0300 Subject: Tests: update MD5SUMS test to have several files The test is now updated to check the order of files in the md5sums. --- Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake | 2 +- Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake | 3 ++- Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake index d1a3a5f..f859215 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/ExpectedFiles.cmake @@ -1,2 +1,2 @@ set(EXPECTED_FILES_COUNT "1") -set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") +set(EXPECTED_FILE_CONTENT_1_LIST "/bar;/bar/CMakeLists.txt;/baz;/baz/CMakeLists.txt;/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake index fbdda9c..13af097 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/VerifyResult.cmake @@ -1,3 +1,4 @@ set(whitespaces_ "[\t\n\r ]*") -set(md5sums_md5sums "^.* usr/foo/CMakeLists\.txt${whitespaces_}$") +set(hashsyms_ "[a-f0-9]+") +set(md5sums_md5sums "^${hashsyms_} usr/bar/CMakeLists\.txt${whitespaces_}${hashsyms_} usr/baz/CMakeLists\.txt${whitespaces_}${hashsyms_} usr/foo/CMakeLists\.txt${whitespaces_}$") verifyDebControl("${FOUND_FILE_1}" "md5sums" "md5sums") diff --git a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake index 15c5892..3c922d2 100644 --- a/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake +++ b/Tests/RunCMake/CPack/tests/MD5SUMS/test.cmake @@ -1,4 +1,6 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) +install(FILES CMakeLists.txt DESTINATION bar COMPONENT test) +install(FILES CMakeLists.txt DESTINATION baz COMPONENT test) if(PACKAGING_TYPE STREQUAL "COMPONENT") set(CPACK_COMPONENTS_ALL test) -- cgit v0.12