From 6ba842163c9060f15156627c19b77aa7fd9838cd Mon Sep 17 00:00:00 2001 From: Jonathan Verner Date: Wed, 27 May 2020 10:53:06 -0400 Subject: CPack-deb: don't add a line with a dot to pkg desc Currently, if the package description ends with a newline (typically if it is read from a file) cpack -deb adds a single line with a dot at the end which leads to a violation of the `extended-description-contains-empty-paragraph` debian policy. This commit fixes the above behaviour. Fixes: #20763 --- Modules/Internal/CPack/CPackDeb.cmake | 10 ++++++++++ .../MyLibCPackConfig-components-description1.cmake.in | 2 +- .../RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake | 12 +----------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index 14bb104..db35e3a 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -83,6 +83,16 @@ function(cpack_deb_format_package_description TEXT OUTPUT_VAR) string(REPLACE "\n" ";" _lines "${_text}") list(POP_FRONT _lines _summary) + # If the description ends with a newline (e.g. typically if it was read + # from a file) the last line will be empty. We drop it here, otherwise + # it would be replaced by a `.` which would lead to the package violating + # the extended-description-contains-empty-paragraph debian policy + list(POP_BACK _lines _last_line) + string(STRIP "${_last_line}" _last_line_strip) + if(_last_line_strip) + list(APPEND _lines "${_last_line_strip}") + endif() + # Check if reformatting required cpack_deb_check_description("${_summary}" "${_lines}" _result) if(_result) diff --git a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in index 67b108b..fb973ad 100644 --- a/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in +++ b/Tests/CPackComponentsDEB/MyLibCPackConfig-components-description1.cmake.in @@ -16,7 +16,7 @@ set(CPACK_COMPONENTS_IGNORE_GROUPS 1) # overriding previous descriptions set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "main description") # This become a summary line (the first one) of all descriptions -set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description") +set(CPACK_COMPONENT_APPLICATIONS_DESCRIPTION "applications_description\n") set(CPACK_COMPONENT_HEADERS_DESCRIPTION "headers_description") # libraries does not have any description and should inherit from CPACK_PACKAGE_DESCRIPTION_SUMMARY # plus content of the `CPACK_PACKAGE_DESCRIPTION_FILE`. diff --git a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake index bfe2059..70ad48b 100644 --- a/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/DEB_DESCRIPTION/VerifyResult.cmake @@ -46,17 +46,7 @@ set(_expected_description [[ Description: This is the summary line . See also: https://www.debian.org/doc/debian-policy/ch-controlfields.html#description]]) -# ATTENTION The code in `cmCPackGenerator.cxx` to read `CPACK_PACKAGE_DESCRIPTION_FILE` -# has a BUG: it appends the `\n` character to every line of the -# input, even if there was no EOL (e.g. at the last line of the file). -# That is WHY for this sub-test the one more pre-formatted "empty" -# line required! -# NOTE For component based installers content of the file gonna read by -# `CPackDeb` module and the `file(READ...)` command so no the mentioned -# 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") +if(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_NO_PACKAGE_DESCRIPTION") set(_expected_description [[ Description: This is the summary line]]) elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "CPACK_COMPONENT_COMP_DESCRIPTION") set(_expected_description [[ Description: One line description]]) -- cgit v0.12