CPack/RPM: Fix weak dep support
RPM 4.11.3 for el7 contains backported support for the RPM weak dep tags. It only supports querying those tags, but rpmbuild can not make use of them. Since CPack relies on rpmbuild --querytags to check for support, this commit switches to rpm --suggests to check for support of weak dependencies. Fixes: #22350
This commit is contained in:
parent
fb02657b6a
commit
9b53eca317
@ -394,8 +394,10 @@ List of CPack RPM generator specific variables:
|
||||
* Mandatory : NO
|
||||
* Default : -
|
||||
|
||||
May be used to set weak RPM dependencies (suggests). Note that you must
|
||||
enclose the complete requires string between quotes.
|
||||
May be used to set weak RPM dependencies (suggests). If ``rpmbuild`` doesn't
|
||||
support the ``Suggests`` tag, CPack will emit a warning and ignore this
|
||||
variable. Note that you must enclose the complete requires string between
|
||||
quotes.
|
||||
|
||||
.. variable:: CPACK_RPM_PACKAGE_PROVIDES
|
||||
CPACK_RPM_<component>_PACKAGE_PROVIDES
|
||||
|
@ -1074,6 +1074,21 @@ function(cpack_rpm_generate_package)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE "\n" ";" RPMBUILD_TAG_LIST "${RPMBUILD_TAG_LIST}")
|
||||
|
||||
# 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()
|
||||
endif()
|
||||
|
||||
if(CPACK_RPM_PACKAGE_EPOCH)
|
||||
set(TMP_RPM_EPOCH "Epoch: ${CPACK_RPM_PACKAGE_EPOCH}")
|
||||
endif()
|
||||
|
@ -1,15 +1,13 @@
|
||||
execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags
|
||||
OUTPUT_VARIABLE RPMBUILD_CAPS
|
||||
RESULT_VARIABLE RPMBUILD_CAPS_RESULT)
|
||||
# CPack uses `rpm --suggests` to check if rpmbuild supports the "Suggests:" tag.
|
||||
# This test intentionally uses a different method (build a test .spec) so any
|
||||
# problems will be caught early if functionality should change in the future.
|
||||
execute_process(
|
||||
COMMAND ${RPMBUILD_EXECUTABLE} --nobuild test_suggests.spec
|
||||
ERROR_QUIET
|
||||
RESULT_VARIABLE RPMBUILD_SUGGESTS_RESULT)
|
||||
|
||||
if(NOT RPMBUILD_CAPS_RESULT)
|
||||
string(REPLACE "\n" ";" RPMBUILD_CAPS "${RPMBUILD_CAPS}")
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
if(SUGGESTS IN_LIST RPMBUILD_CAPS)
|
||||
set(should_contain_suggests_tag_ true)
|
||||
endif()
|
||||
cmake_policy(POP)
|
||||
if(RPMBUILD_SUGGESTS_RESULT EQUAL 0)
|
||||
set(should_contain_suggests_tag_ true)
|
||||
endif()
|
||||
|
||||
# Only verify that suggests tag is present only if that tag is supported.
|
||||
|
22
Tests/RunCMake/CPack/tests/SUGGESTS/test_suggests.spec
Normal file
22
Tests/RunCMake/CPack/tests/SUGGESTS/test_suggests.spec
Normal file
@ -0,0 +1,22 @@
|
||||
# This spec file is used to check if the provided version of rpmbuild supports the "Suggests:" tag
|
||||
|
||||
Name: test
|
||||
Version: 0
|
||||
Release: 1
|
||||
Summary: test
|
||||
License: test
|
||||
|
||||
Suggests: suggested_package
|
||||
|
||||
%description
|
||||
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
%configure
|
||||
%install
|
||||
%clean
|
||||
%files
|
||||
%doc
|
||||
%changelog
|
Loading…
Reference in New Issue
Block a user