From 53991e62daf819a91b7c89f4d4899d0f94c7fd12 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 14 Oct 2023 23:21:34 +0200 Subject: CPack/RPM: Append .rpm to CPACK_RPM_FILE_NAME if missing Previously we issued an error when the `.rpm` suffix is missing. Instead, append the suffix automatically. This matches the behavior of `CPACK_ARCHIVE_FILE_NAME`, to which the archive format suffix is automatically appended. With this change, developers can simply do set(CPACK_RPM_comp_FILE_NAME "${CPACK_ARCHIVE_comp_FILE_NAME}") --- Help/cpack_gen/rpm.rst | 9 +++++++-- Help/release/dev/cpack-auto-suffixes.rst | 4 ++++ Modules/Internal/CPack/CPackRPM.cmake | 2 +- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 +- Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/ExpectedFiles.cmake | 2 +- Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/test.cmake | 3 ++- 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Help/cpack_gen/rpm.rst b/Help/cpack_gen/rpm.rst index ebdb721..4a2ce5f 100644 --- a/Help/cpack_gen/rpm.rst +++ b/Help/cpack_gen/rpm.rst @@ -89,8 +89,13 @@ List of CPack RPM generator specific variables: ``RPM-DEFAULT`` Tell ``rpmbuild`` to automatically generate the package file name. - ``.rpm`` - Use the given file name. The ``.rpm`` suffix is required. + ``[.rpm]`` + Use the given file name. + + .. versionchanged:: 3.29 + + The ``.rpm`` suffix will be automatically added if missing. + Previously the suffix was required. .. note:: diff --git a/Help/release/dev/cpack-auto-suffixes.rst b/Help/release/dev/cpack-auto-suffixes.rst index 678e3f6..f3fd2af 100644 --- a/Help/release/dev/cpack-auto-suffixes.rst +++ b/Help/release/dev/cpack-auto-suffixes.rst @@ -4,3 +4,7 @@ cpack-auto-suffixes * The :cpack_gen:`CPack DEB Generator` :variable:`CPACK_DEBIAN_FILE_NAME` variable may now be set without any suffix, and the ``.deb`` suffix will be added automatically. + +* The :cpack_gen:`CPack RPM Generator` :variable:`CPACK_RPM_FILE_NAME` + variable may now be set without any suffix, and the ``.rpm`` suffix + will be added automatically. diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 36c0a3f..bc1e082 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1563,7 +1563,7 @@ ${TMP_DEBUGINFO_ADDITIONAL_SOURCES} if(NOT CPACK_RPM_FILE_NAME STREQUAL "RPM-DEFAULT") if(CPACK_RPM_FILE_NAME) if(NOT CPACK_RPM_FILE_NAME MATCHES ".*\\.rpm") - message(FATAL_ERROR "'${CPACK_RPM_FILE_NAME}' is not a valid RPM package file name as it must end with '.rpm'!") + set(CPACK_RPM_FILE_NAME "${CPACK_RPM_FILE_NAME}.rpm") endif() else() # old file name format for back compatibility diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 522e463..a829c3f 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -978,6 +978,7 @@ set(cpack_tests DEB.DEB_DESCRIPTION DEB.PROJECT_META + RPM.AUTO_SUFFIXES RPM.CUSTOM_BINARY_SPEC_FILE RPM.CUSTOM_NAMES RPM.DEBUGINFO diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 90c0cce..8ad01e5 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -9,7 +9,7 @@ find_program(DEBUGEDIT debugedit) # run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" run_cpack_test(CUSTOM_BINARY_SPEC_FILE "RPM.CUSTOM_BINARY_SPEC_FILE" false "MONOLITHIC;COMPONENT") run_cpack_test(CUSTOM_NAMES "RPM.CUSTOM_NAMES;DEB.CUSTOM_NAMES;TGZ;DragNDrop" true "COMPONENT") -run_cpack_test(AUTO_SUFFIXES "DEB.AUTO_SUFFIXES" false "MONOLITHIC") +run_cpack_test(AUTO_SUFFIXES "RPM.AUTO_SUFFIXES;DEB.AUTO_SUFFIXES" false "MONOLITHIC") run_cpack_test(DEBUGINFO "DEB.DEBUGINFO" true "COMPONENT") if(NOT "${DEBUGEDIT}" STREQUAL "DEBUGEDIT-NOTFOUND") run_cpack_test(DEBUGINFO "RPM.DEBUGINFO" true "COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/ExpectedFiles.cmake index a531c04..1ca48d8 100644 --- a/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/ExpectedFiles.cmake @@ -2,7 +2,7 @@ set(EXPECTED_FILES_COUNT "1") set(EXPECTED_FILES_NAME_GENERATOR_SPECIFIC_FORMAT TRUE) set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") -if(GENERATOR_TYPE STREQUAL "DEB") +if(GENERATOR_TYPE STREQUAL "DEB" OR GENERATOR_TYPE STREQUAL "RPM") string(TOLOWER "${GENERATOR_TYPE}" file_extension_) set(EXPECTED_FILE_1 "autosuffixpackage.${file_extension_}") endif() diff --git a/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/test.cmake b/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/test.cmake index 5c29b2d..84c9bec 100644 --- a/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/test.cmake +++ b/Tests/RunCMake/CPack/tests/AUTO_SUFFIXES/test.cmake @@ -1,4 +1,5 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) -# if the filename doesn't have the expected deb suffix, test that it is appended automatically +# if the filename doesn't have the expected deb/rpm suffix, test that it is appended automatically set(CPACK_DEBIAN_FILE_NAME "autosuffixpackage") +set(CPACK_RPM_FILE_NAME "autosuffixpackage") -- cgit v0.12