RunCPackVerifyResult-components-description2.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. if(NOT CPackComponentsDEB_SOURCE_DIR)
  2. message(FATAL_ERROR "CPackComponentsDEB_SOURCE_DIR not set")
  3. endif()
  4. include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
  5. # expected results
  6. set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.3_*.deb")
  7. set(expected_count 3)
  8. set(actual_output)
  9. run_cpack(actual_output
  10. CPack_output
  11. CPack_error
  12. EXPECTED_FILE_MASK "${expected_file_mask}"
  13. CONFIG_ARGS ${config_args}
  14. CONFIG_VERBOSE ${config_verbose})
  15. if(NOT actual_output)
  16. message(STATUS "expected_count='${expected_count}'")
  17. message(STATUS "expected_file_mask='${expected_file_mask}'")
  18. message(STATUS "actual_output_files='${actual_output}'")
  19. message(FATAL_ERROR "error: expected_files do not exist: CPackComponentsDEB test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  20. endif()
  21. list(LENGTH actual_output actual_count)
  22. message(STATUS "actual_count='${actual_count}'")
  23. if(NOT actual_count EQUAL expected_count)
  24. message(FATAL_ERROR "error: expected_count=${expected_count} does not match actual_count=${actual_count}: CPackComponents test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error})")
  25. endif()
  26. # dpkg-deb checks for the summary of the packages
  27. find_program(DPKGDEB_EXECUTABLE dpkg-deb)
  28. if(DPKGDEB_EXECUTABLE)
  29. set(dpkgdeb_output_errors_all "")
  30. foreach(_f IN LISTS actual_output)
  31. # extracts the metadata from the package
  32. run_dpkgdeb(dpkg_output
  33. FILENAME ${_f}
  34. )
  35. dpkgdeb_return_specific_metaentry(dpkg_package_name
  36. DPKGDEB_OUTPUT "${dpkg_output}"
  37. METAENTRY "Package:")
  38. get_package_description("${dpkg_output}" dpkg_description)
  39. message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
  40. if(dpkg_package_name STREQUAL "mylib-applications" OR dpkg_package_name STREQUAL "mylib-headers")
  41. if(NOT dpkg_description MATCHES "main description 2\n.*")
  42. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  43. "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` =~ `main description 2`")
  44. endif()
  45. elseif(dpkg_package_name STREQUAL "mylib-libraries")
  46. set(expected_description "main description 2\n library description")
  47. if(NOT dpkg_description STREQUAL expected_description)
  48. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  49. "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: `${dpkg_description}` != `${expected_description}`")
  50. endif()
  51. else()
  52. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  53. "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
  54. endif()
  55. endforeach()
  56. if(NOT dpkgdeb_output_errors_all STREQUAL "")
  57. message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
  58. endif()
  59. else()
  60. message("dpkg-deb executable not found - skipping dpkg-deb test")
  61. endif()