VerifyResult.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # CPack uses `rpm --recommends` to check if rpmbuild supports the "Recommends:" tag.
  2. # This test intentionally uses a different method (build a test .spec) so any
  3. # problems will be caught early if functionality should change in the future.
  4. execute_process(
  5. COMMAND ${RPMBUILD_EXECUTABLE} --nobuild test_recommends.spec
  6. ERROR_QUIET
  7. WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
  8. RESULT_VARIABLE RPMBUILD_RECOMMENDS_RESULT)
  9. if(RPMBUILD_RECOMMENDS_RESULT EQUAL 0)
  10. set(should_contain_recommends_tag_ true)
  11. endif()
  12. # Only verify that recommends tag is present only if that tag is supported.
  13. # If it is not supported the rpm package was correctly generated by ignoring
  14. # that tag and that was already checked by expected files test.
  15. if(should_contain_recommends_tag_)
  16. execute_process(COMMAND ${RPM_EXECUTABLE} -q --recommends -p "${FOUND_FILE_1}"
  17. RESULT_VARIABLE rpm_result_
  18. OUTPUT_VARIABLE rpm_stdout_
  19. ERROR_VARIABLE rpm_stderr_
  20. OUTPUT_STRIP_TRAILING_WHITESPACE)
  21. if(rpm_result_ OR NOT rpm_stdout_ STREQUAL "librecommended")
  22. string(REPLACE "\n" "\n " rpm_stdout_ "${rpm_stdout_}")
  23. string(REPLACE "\n" "\n " rpm_stderr_ "${rpm_stderr_}")
  24. message(FATAL_ERROR "RPM_RECOMMENDED package error: no recommended packages\n"
  25. "result: ${rpm_result_}\n"
  26. "stdout:\n"
  27. " ${rpm_stdout_}\n"
  28. "stderr:\n"
  29. " ${rpm_stderr_}\n"
  30. )
  31. endif()
  32. endif()