diff options
author | Brad King <brad.king@kitware.com> | 2020-01-13 15:23:17 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-13 15:23:26 (GMT) |
commit | e61c2ed9acb493d1adca748088a1f34e34f9f726 (patch) | |
tree | 38dd6fa2e5a573ceacbf7911ed6f88b0e8266647 | |
parent | 1d2bead8dd61e4550312dc36a24180ab2f7ff351 (diff) | |
parent | d491f34a5ef303217aef335fdc02a8ff987a6fc8 (diff) | |
download | CMake-e61c2ed9acb493d1adca748088a1f34e34f9f726.zip CMake-e61c2ed9acb493d1adca748088a1f34e34f9f726.tar.gz CMake-e61c2ed9acb493d1adca748088a1f34e34f9f726.tar.bz2 |
Merge topic 'fix-cpack-deb-description-file'
d491f34a5e CPack: Fix regression in DEB generator description
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4204
7 files changed, 28 insertions, 10 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index cbb5323..e4f75d5 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -470,8 +470,10 @@ if(CMAKE_PROJECT_HOMEPAGE_URL) "${CMAKE_PROJECT_HOMEPAGE_URL}") endif() -_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE +set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "${CMAKE_ROOT}/Templates/CPack.GenericDescription.txt") +_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_FILE + "${CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE}") _cpack_set_default(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt") _cpack_set_default(CPACK_RESOURCE_FILE_README diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index fe0fe09..c74c324 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -498,6 +498,11 @@ function(cpack_deb_prepare_package_vars) # Description: (mandatory) # Try package description first + if(CPACK_USED_DEFAULT_PACKAGE_DESCRIPTION_FILE) + set(_desc_fallback) + else() + set(_desc_fallback "CPACK_PACKAGE_DESCRIPTION") + endif() if(CPACK_DEB_PACKAGE_COMPONENT) cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION" "CPACK_DEBIAN_${_local_component_name}_DESCRIPTION" @@ -505,11 +510,13 @@ function(cpack_deb_prepare_package_vars) else() cpack_deb_variable_fallback("CPACK_DEBIAN_PACKAGE_DESCRIPTION" "CPACK_DEBIAN_PACKAGE_DESCRIPTION" - "CPACK_PACKAGE_DESCRIPTION") + ${_desc_fallback}) endif() # Still no description? ... and description file has set ... - if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION AND CPACK_PACKAGE_DESCRIPTION_FILE) + if(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION + AND CPACK_PACKAGE_DESCRIPTION_FILE + AND NOT CPACK_PACKAGE_DESCRIPTION_FILE STREQUAL CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE) # Read `CPACK_PACKAGE_DESCRIPTION_FILE` then... file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_DEBIAN_PACKAGE_DESCRIPTION) endif() diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 6003493..712eb77 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -125,7 +125,7 @@ int cmCPackGenerator::PrepareNames() cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl); const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE"); - if (descFileName) { + if (descFileName && !this->GetOption("CPACK_PACKAGE_DESCRIPTION")) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName << std::endl); if (!cmSystemTools::FileExists(descFileName)) { @@ -149,7 +149,12 @@ int cmCPackGenerator::PrepareNames() while (ifs && cmSystemTools::GetLineFromStream(ifs, line)) { ostr << cmXMLSafe(line) << std::endl; } - this->SetOptionIfNotSet("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str()); + this->SetOption("CPACK_PACKAGE_DESCRIPTION", ostr.str().c_str()); + const char* defFileName = + this->GetOption("CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE"); + if (defFileName && !strcmp(defFileName, descFileName)) { + this->SetOption("CPACK_USED_DEFAULT_PACKAGE_DESCRIPTION_FILE", "ON"); + } } if (!this->GetOption("CPACK_PACKAGE_DESCRIPTION")) { cmCPackLogger( diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake index 86a74b2..f46a575 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description1.cmake @@ -65,9 +65,10 @@ if(DPKGDEB_EXECUTABLE) "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() elseif(dpkg_package_name STREQUAL "mylib-libraries") - if(NOT dpkg_description MATCHES "main description\n.*") + set(expected_description "main description") + if(NOT dpkg_description STREQUAL expected_description) set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` =~ `main description.*`") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() else() set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} diff --git a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake index d53c73d..c00921a 100644 --- a/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake +++ b/Tests/CPackComponentsDEB/RunCPackVerifyResult-components-description2.cmake @@ -53,9 +53,10 @@ if(DPKGDEB_EXECUTABLE) message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'") if(dpkg_package_name STREQUAL "mylib-applications" OR dpkg_package_name STREQUAL "mylib-headers") - if(NOT dpkg_description MATCHES "main description 2\n.*") + set(expected_description "main description 2") + if(NOT dpkg_description STREQUAL expected_description) set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all} - "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` =~ `main description 2`") + "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`") endif() elseif(dpkg_package_name STREQUAL "mylib-libraries") set(expected_description "main description 2\n library description") diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 76d16e1..6e413aa 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -38,7 +38,7 @@ run_cpack_test(DEB_PACKAGE_VERSION_BACK_COMPATIBILITY "DEB.DEB_PACKAGE_VERSION_B run_cpack_test_subtests(EXTERNAL "none;good;good_multi;bad_major;bad_minor;invalid_good;invalid_bad;stage_and_package" "External" false "MONOLITHIC;COMPONENT") run_cpack_test_subtests( DEB_DESCRIPTION - "CPACK_DEBIAN_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION_FILE" + "CPACK_DEBIAN_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION;CPACK_PACKAGE_DESCRIPTION_FILE;CPACK_NO_PACKAGE_DESCRIPTION" "DEB.DEB_DESCRIPTION" false "MONOLITHIC;COMPONENT" diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake index e9ac13a..a8e2e7a 100644 --- a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake @@ -56,6 +56,8 @@ set(_expected_description [[ Description: This is the summary line # workaround required! if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_PACKAGE_DESCRIPTION_FILE" AND PACKAGING_TYPE STREQUAL "MONOLITHIC") string(APPEND _expected_description "\n ." ) +elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_NO_PACKAGE_DESCRIPTION") + set(_expected_description [[ Description: This is the summary line]]) endif() foreach(_file_no RANGE 1 ${EXPECTED_FILES_COUNT}) |