Merge topic 'cpack-per-component-extra-control-file'

3e6b2ab6 CPack/DEB: component version of PACKAGE_CONTROL_EXTRA
506f6bc0 CPack/DEB: Remove duplicate string(TOUPPER) calls
32e9276a Tests/RunCMake/CPack/DEB: add verifyDebControl
47d1f118 Tests/RunCMake/CPack: found files should be preserved
This commit is contained in:
Brad King 2015-07-17 10:36:15 -04:00 committed by CMake Topic Stage
commit 536b6c7519
7 changed files with 73 additions and 8 deletions

View File

@ -272,6 +272,7 @@
#
#
# .. variable:: CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# CPACK_DEBIAN_<COMPONENT>_PACKAGE_CONTROL_EXTRA
#
# This variable allow advanced user to add custom script to the
# control.tar.gz.
@ -498,7 +499,6 @@ function(cpack_deb_prepare_package_vars)
# if per-component dependency, overrides the global CPACK_DEBIAN_PACKAGE_DEPENDS
# automatic dependency discovery will be performed afterwards.
if(CPACK_DEB_PACKAGE_COMPONENT)
string(TOUPPER "${CPACK_DEB_PACKAGE_COMPONENT}" _local_component_name)
set(_component_depends_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_DEPENDS")
# if set, overrides the global dependency
@ -542,7 +542,6 @@ function(cpack_deb_prepare_package_vars)
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
endif()
else()
string(TOUPPER ${CPACK_DEB_PACKAGE_COMPONENT} _local_component_name)
set(component_description_var CPACK_COMPONENT_${_local_component_name}_DESCRIPTION)
# component description overrides package description
@ -584,13 +583,20 @@ function(cpack_deb_prepare_package_vars)
# - conffiles
# - postinst
# - postrm
# - prerm"
# - prerm
# Usage:
# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
# Are we packaging components ?
if(CPACK_DEB_PACKAGE_COMPONENT)
# override values with per component version if set
foreach(VAR_NAME_ "PACKAGE_CONTROL_EXTRA")
if(CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_})
set(CPACK_DEBIAN_${VAR_NAME_} "${CPACK_DEBIAN_${_local_component_name}_${VAR_NAME_}}")
endif()
endforeach()
set(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "-${CPACK_DEB_PACKAGE_COMPONENT}")
string(TOLOWER "${CPACK_PACKAGE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
else()

View File

@ -0,0 +1,9 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "deb_extra-*-foo.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "deb_extra-*-bar.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_3 "deb_extra-*-bas.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$")

View File

@ -0,0 +1,11 @@
set(foo_preinst "^echo default_preinst$")
set(foo_prerm "^echo default_prerm$")
verifyDebControl("${FOUND_FILE_1}" "foo" "preinst;prerm")
set(bar_preinst "^echo bar_preinst$")
set(bar_prerm "^echo bar_prerm$")
verifyDebControl("${FOUND_FILE_2}" "bar" "preinst;prerm")
set(bas_preinst "^echo default_preinst$")
set(bas_prerm "^echo default_prerm$")
verifyDebControl("${FOUND_FILE_3}" "bas" "preinst;prerm")

View File

@ -8,3 +8,21 @@ function(getPackageContent FILE RESULT_VAR)
set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
endfunction()
function(verifyDebControl FILE PREFIX VERIFY_FILES)
execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX}
ERROR_VARIABLE err_)
if(err_)
message(FATAL_ERROR "Debian controll verification failed for file: "
"'${FILE}'; error output: '${err_}'")
endif()
foreach(FILE_ IN LISTS VERIFY_FILES)
file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_)
if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}")
message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!"
" Content: '${content_}'")
endif()
endforeach()
endfunction()

View File

@ -0,0 +1,20 @@
install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo)
install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar)
install(FILES CMakeLists.txt DESTINATION bas COMPONENT bas)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/preinst "echo default_preinst")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/prerm "echo default_prerm")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_BINARY_DIR}/preinst;${CMAKE_CURRENT_BINARY_DIR}/prerm")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bar/preinst "echo bar_preinst")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bar/prerm "echo bar_prerm")
set(CPACK_DEBIAN_BAR_PACKAGE_CONTROL_EXTRA
"${CMAKE_CURRENT_BINARY_DIR}/bar/preinst;${CMAKE_CURRENT_BINARY_DIR}/bar/prerm")
set(CPACK_PACKAGE_NAME "deb_extra")
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL ON)

View File

@ -6,3 +6,4 @@ include("${RunCMake_SOURCE_DIR}/CPackTestHelpers.cmake")
# args: TEST_NAME "GENERATORS" RUN_CMAKE_BUILD_STEP
run_cpack_test(MINIMAL "RPM;DEB" false)
run_cpack_test(PARTIALLY_RELOCATABLE_WARNING "RPM" false)
run_cpack_test(DEB_EXTRA "DEB" false)

View File

@ -15,13 +15,13 @@ include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST}-ExpectedFiles.cmake")
if(NOT EXPECTED_FILES_COUNT EQUAL 0)
foreach(file_no_ RANGE 1 ${EXPECTED_FILES_COUNT})
file(GLOB foundFile_ RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}")
set(foundFiles_ "${foundFiles_};${foundFile_}")
list(LENGTH foundFile_ foundFilesCount_)
file(GLOB FOUND_FILE_${file_no_} RELATIVE "${bin_dir}" "${EXPECTED_FILE_${file_no_}}")
set(foundFiles_ "${foundFiles_};${FOUND_FILE_${file_no_}}")
list(LENGTH FOUND_FILE_${file_no_} foundFilesCount_)
if(foundFilesCount_ EQUAL 1)
unset(PACKAGE_CONTENT)
getPackageContent("${bin_dir}/${foundFile_}" "PACKAGE_CONTENT")
getPackageContent("${bin_dir}/${FOUND_FILE_${file_no_}}" "PACKAGE_CONTENT")
string(REGEX MATCH "${EXPECTED_FILE_CONTENT_${file_no_}}"
expected_content_list "${PACKAGE_CONTENT}")
@ -36,7 +36,7 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0)
message(FATAL_ERROR
"Found more than one file for file No. '${file_no_}'!"
" Found files count '${foundFilesCount_}'."
" Files: '${foundFile_}'"
" Files: '${FOUND_FILE_${file_no_}}'"
"${output_error_message}")
endif()
endforeach()