RunCPackVerifyResult-components-description2.cmake 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(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. dpkgdeb_return_specific_metaentry(dpkg_description
  39. DPKGDEB_OUTPUT "${dpkg_output}"
  40. METAENTRY "Description:")
  41. message(STATUS "package='${dpkg_package_name}', description='${dpkg_description}'")
  42. if("${dpkg_package_name}" STREQUAL "mylib-applications")
  43. if(NOT "${dpkg_description}" STREQUAL "main description 2")
  44. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  45. "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != applications_description")
  46. endif()
  47. elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
  48. if(NOT "${dpkg_description}" STREQUAL "main description 2")
  49. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  50. "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != headers_description")
  51. endif()
  52. elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
  53. if(NOT "${dpkg_description}" STREQUAL "library description")
  54. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  55. "dpkg-deb: ${_f}: Incorrect description for package ${dpkg_package_name}: ${dpkg_description} != 'main description'")
  56. endif()
  57. else()
  58. set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
  59. "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
  60. endif()
  61. endforeach()
  62. if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
  63. message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
  64. endif()
  65. else()
  66. message("dpkg-deb executable not found - skipping dpkg-deb test")
  67. endif()