mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
CPack/RPM: Backport "Fix detection of RPM support for weak dependencies"
Backport commit 283a48403f (CPack/RPM: Fix detection of RPM support for
weak dependencies, 2025-02-28, v4.0.0-rc3~8^2) to CMake 3.31.
Fixes: #27373
This commit is contained in:
@@ -815,6 +815,10 @@ function(cpack_rpm_generate_package)
|
||||
message(FATAL_ERROR "RPM package requires rpmbuild executable")
|
||||
endif()
|
||||
|
||||
# rpm is used for fallback queries in some older versions,
|
||||
# but is not required in general.
|
||||
find_program(RPM_EXECUTABLE rpm)
|
||||
|
||||
# Check version of the rpmbuild tool this would be easier to
|
||||
# track bugs with users and CPackRPM debug mode.
|
||||
# We may use RPM version in order to check for available version dependent features
|
||||
@@ -1081,16 +1085,16 @@ function(cpack_rpm_generate_package)
|
||||
# In some versions of RPM, weak dependency tags are present in the --querytags
|
||||
# list, but unsupported by rpmbuild. A different method must be used to check
|
||||
# if they are supported.
|
||||
|
||||
execute_process(
|
||||
COMMAND ${RPM_EXECUTABLE} --suggests
|
||||
ERROR_QUIET
|
||||
RESULT_VARIABLE RPMBUILD_SUGGESTS_RESULT)
|
||||
|
||||
if(NOT RPMBUILD_SUGGESTS_RESULT EQUAL 0)
|
||||
foreach(_WEAK_DEP SUGGESTS RECOMMENDS SUPPLEMENTS ENHANCES)
|
||||
list(REMOVE_ITEM RPMBUILD_TAG_LIST ${_WEAK_DEP})
|
||||
endforeach()
|
||||
if(RPM_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND "${RPM_EXECUTABLE}" --suggests
|
||||
ERROR_QUIET
|
||||
RESULT_VARIABLE RPM_SUGGESTS_RESULT)
|
||||
if(NOT RPM_SUGGESTS_RESULT EQUAL 0)
|
||||
foreach(_WEAK_DEP SUGGESTS RECOMMENDS SUPPLEMENTS ENHANCES)
|
||||
list(REMOVE_ITEM RPMBUILD_TAG_LIST ${_WEAK_DEP})
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CPACK_RPM_PACKAGE_EPOCH)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
execute_process(
|
||||
COMMAND ${RPMBUILD_EXECUTABLE} --nobuild test_suggests.spec
|
||||
ERROR_QUIET
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
RESULT_VARIABLE RPMBUILD_SUGGESTS_RESULT)
|
||||
|
||||
if(RPMBUILD_SUGGESTS_RESULT EQUAL 0)
|
||||
@@ -15,15 +16,20 @@ endif()
|
||||
# that tag and that was already checked by expected files test.
|
||||
if(should_contain_suggests_tag_)
|
||||
execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}"
|
||||
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
|
||||
RESULT_VARIABLE rpm_result_
|
||||
OUTPUT_VARIABLE rpm_output_
|
||||
ERROR_VARIABLE error_variable_
|
||||
OUTPUT_VARIABLE rpm_stdout_
|
||||
ERROR_VARIABLE rpm_stderr_
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(rpm_result_ OR NOT rpm_output_ STREQUAL "libsuggested")
|
||||
message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages"
|
||||
" (result: '${rpm_result_}'; output: '${rpm_output_}';"
|
||||
" error: '${error_variable_}')")
|
||||
if(rpm_result_ OR NOT rpm_stdout_ STREQUAL "libsuggested")
|
||||
string(REPLACE "\n" "\n " rpm_stdout_ "${rpm_stdout_}")
|
||||
string(REPLACE "\n" "\n " rpm_stderr_ "${rpm_stderr_}")
|
||||
message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages\n"
|
||||
"result: ${rpm_result_}\n"
|
||||
"stdout:\n"
|
||||
" ${rpm_stdout_}\n"
|
||||
"stderr:\n"
|
||||
" ${rpm_stderr_}\n"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user