RunCPackVerifyResult-components-depend2.cmake 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_depends
  40. DPKGDEB_OUTPUT "${dpkg_output}"
  41. METAENTRY "Depends:")
  42. message(STATUS "package='${dpkg_package_name}', dependencies='${dpkg_depends}'")
  43. if("${dpkg_package_name}" STREQUAL "mylib-applications")
  44. find_program(DPKG_SHLIBDEP_EXECUTABLE dpkg-shlibdeps)
  45. if(DPKG_SHLIBDEP_EXECUTABLE)
  46. string(FIND "${dpkg_depends}" "lib" index_libwhatever)
  47. if(NOT index_libwhatever GREATER "-1")
  48. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  49. "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does not contain any 'lib'\n")
  50. endif()
  51. else()
  52. message("dpkg-shlibdeps executable not found - skipping dpkg-shlibdeps test")
  53. endif()
  54. # should not contain the default
  55. string(FIND "${dpkg_depends}" "depend-default" index_default)
  56. if(index_default GREATER "0")
  57. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  58. "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
  59. endif()
  60. elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
  61. if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
  62. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  63. "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
  64. endif()
  65. elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
  66. if(NOT "${dpkg_depends}" STREQUAL "depend-default")
  67. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  68. "dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-default'\n")
  69. endif()
  70. else()
  71. set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
  72. "dpkg-deb: ${_f}: component name not found: ${dpkg_package_name}\n")
  73. endif()
  74. endforeach()
  75. if(NOT "${dpkgdeb_output_errors_all}" STREQUAL "")
  76. message(FATAL_ERROR "dpkg-deb checks failed:\n${dpkgdeb_output_errors_all}")
  77. endif()
  78. else()
  79. message("dpkg-deb executable not found - skipping dpkg-deb test")
  80. endif()