1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-16 22:37:30 +08:00

CPack/DEB: Append .deb to CPACK_DEBIAN_FILE_NAME if missing

Previously we issued an error when the `.deb` or `.ipk` suffix
is missing. Instead, append the suffix `.deb` automatically.
This matches the behavior of `CPACK_ARCHIVE_FILE_NAME`, to
which the archive format suffix is automatically appended.
This commit is contained in:
Alex Neundorf
2023-10-26 23:29:27 +02:00
committed by Brad King
parent 907d4db558
commit f2a6d423da
7 changed files with 28 additions and 3 deletions

View File

@@ -82,8 +82,13 @@ List of CPack DEB generator specific variables:
Duplicate files get overwritten and it is up to the packager to set Duplicate files get overwritten and it is up to the packager to set
the variables in a manner that will prevent such errors. the variables in a manner that will prevent such errors.
``<file-name>.deb`` ``<file-name>[.deb]``
Use the given file name. The ``.deb`` suffix is required. Use the given file name.
.. versionchanged:: 3.29
The ``.deb`` suffix will be automatically added if the file name does
not end in ``.deb`` or ``.ipk``. Previously the suffix was required.
``<file-name>.ipk`` ``<file-name>.ipk``
.. versionadded:: 3.10 .. versionadded:: 3.10

View File

@@ -0,0 +1,6 @@
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.

View File

@@ -710,7 +710,7 @@ function(cpack_deb_prepare_package_vars)
"${CPACK_DEBIAN_PACKAGE_NAME}-dbgsym_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ddeb") "${CPACK_DEBIAN_PACKAGE_NAME}-dbgsym_${CPACK_DEBIAN_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.ddeb")
else() else()
if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)") if(NOT CPACK_DEBIAN_FILE_NAME MATCHES ".*\\.(deb|ipk)")
message(FATAL_ERROR "'${CPACK_DEBIAN_FILE_NAME}' is not a valid DEB package file name as it must end with '.deb' or '.ipk'!") set(CPACK_DEBIAN_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}.deb")
endif() endif()
set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}") set(CPACK_OUTPUT_FILE_NAME "${CPACK_DEBIAN_FILE_NAME}")

View File

@@ -959,6 +959,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
endif() endif()
set(cpack_tests set(cpack_tests
DEB.AUTO_SUFFIXES
DEB.CUSTOM_NAMES DEB.CUSTOM_NAMES
DEB.DEBUGINFO DEB.DEBUGINFO
DEB.DEFAULT_PERMISSIONS DEB.DEFAULT_PERMISSIONS

View File

@@ -9,6 +9,7 @@ find_program(DEBUGEDIT debugedit)
# run_cpack_test args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP "PACKAGING_TYPES" # 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_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(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(DEBUGINFO "DEB.DEBUGINFO" true "COMPONENT") run_cpack_test(DEBUGINFO "DEB.DEBUGINFO" true "COMPONENT")
if(NOT "${DEBUGEDIT}" STREQUAL "DEBUGEDIT-NOTFOUND") if(NOT "${DEBUGEDIT}" STREQUAL "DEBUGEDIT-NOTFOUND")
run_cpack_test(DEBUGINFO "RPM.DEBUGINFO" true "COMPONENT") run_cpack_test(DEBUGINFO "RPM.DEBUGINFO" true "COMPONENT")

View File

@@ -0,0 +1,8 @@
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")
string(TOLOWER "${GENERATOR_TYPE}" file_extension_)
set(EXPECTED_FILE_1 "autosuffixpackage.${file_extension_}")
endif()

View File

@@ -0,0 +1,4 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT test)
# if the filename doesn't have the expected deb suffix, test that it is appended automatically
set(CPACK_DEBIAN_FILE_NAME "autosuffixpackage")