RunCPackVerifyResult-components-source.cmake 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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.2_*.deb")
  7. set(expected_count 3)
  8. set(config_verbose -V)
  9. set(actual_output)
  10. run_cpack(actual_output
  11. CPack_output
  12. CPack_error
  13. EXPECTED_FILE_MASK "${expected_file_mask}"
  14. CONFIG_ARGS ${config_args}
  15. CONFIG_VERBOSE ${config_verbose})
  16. if(NOT actual_output)
  17. message(STATUS "expected_count='${expected_count}'")
  18. message(STATUS "expected_file_mask='${expected_file_mask}'")
  19. message(STATUS "actual_output_files='${actual_output}'")
  20. message(FATAL_ERROR "error: expected_files do not exist: CPackComponentsDEB test fails. (CPack_output=${CPack_output}, CPack_error=${CPack_error}")
  21. endif()
  22. list(LENGTH actual_output actual_count)
  23. if(NOT actual_count EQUAL expected_count)
  24. message(STATUS "actual_count='${actual_count}'")
  25. 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})")
  26. endif()
  27. # dpkg-deb checks for the summary of the packages
  28. find_program(DPKGDEB_EXECUTABLE dpkg-deb)
  29. if(DPKGDEB_EXECUTABLE)
  30. set(dpkgdeb_output_errors_all "")
  31. foreach(_f IN LISTS actual_output)
  32. # extracts the metadata from the package
  33. run_dpkgdeb(dpkg_output
  34. FILENAME "${_f}"
  35. )
  36. dpkgdeb_return_specific_metaentry(dpkg_package_name
  37. DPKGDEB_OUTPUT "${dpkg_output}"
  38. METAENTRY "Package:")
  39. dpkgdeb_return_specific_metaentry(dpkg_package_source
  40. DPKGDEB_OUTPUT "${dpkg_output}"
  41. METAENTRY "Source:")
  42. message(STATUS "package='${_f}', source='${dpkg_package_source}'")
  43. if(NOT ("${dpkg_package_name}" STREQUAL "mylib-applications"))
  44. if(NOT ("${dpkg_package_source}" STREQUAL "test-source"))
  45. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  46. "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-source'\n")
  47. endif()
  48. else()
  49. if(NOT ("${dpkg_package_source}" STREQUAL "test-other-source"))
  50. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  51. "dpkg-deb: ${_f}: Incorrect source for package '${dpkg_package_name}': '${dpkg_package_source}' instead of 'test-other-source'\n")
  52. endif()
  53. endif()
  54. endforeach()
  55. if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
  56. message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
  57. endif()
  58. else()
  59. message("dpkg-deb executable not found - skipping dpkg-deb test")
  60. endif()