PR#965: check rpm headers support directly
Merges #965 https://pagure.io/koji/pull-request/965 Fixes: #931 https://pagure.io/koji/issue/931 Koji hub will not render weak dependencies on an EL7.5 host, even though host rpm can read them
This commit is contained in:
commit
ef998c6418
3 changed files with 15 additions and 15 deletions
|
|
@ -111,13 +111,17 @@ RPM_FILEDIGESTALGO_IDS = {
|
|||
11: 'SHA224'
|
||||
}
|
||||
|
||||
# rpm 4.12 introduces optional deps
|
||||
try:
|
||||
RPM_SUPPORTS_OPTIONAL_DEPS = int(rpm.__version_info__[0]) > 4 or \
|
||||
(int(rpm.__version_info__[0]) == 4 and int(rpm.__version_info__[1]) >= 12)
|
||||
except AttributeError:
|
||||
# older versions don't even have __version_info__
|
||||
RPM_SUPPORTS_OPTIONAL_DEPS = False
|
||||
# rpm 4.12 introduces optional deps, but they can also be backported in some
|
||||
# rpm installations. So, we need to check their real support, not only rpm
|
||||
# version.
|
||||
SUPPORTED_OPT_DEP_HDRS = {}
|
||||
for h in (
|
||||
'SUGGESTNAME', 'SUGGESTVERSION', 'SUGGESTFLAGS',
|
||||
'ENHANCENAME', 'ENHANCEVERSION', 'ENHANCEFLAGS',
|
||||
'SUPPLEMENTNAME', 'SUPPLEMENTVERSION', 'SUPPLEMENTFLAGS',
|
||||
'RECOMMENDNAME', 'RECOMMENDVERSION', 'RECOMMENDFLAGS'):
|
||||
SUPPORTED_OPT_DEP_HDRS[h] = hasattr(rpm, 'RPMTAG_%s' % h)
|
||||
|
||||
|
||||
class Enum(dict):
|
||||
"""A simple class to track our enumerated constants
|
||||
|
|
@ -893,12 +897,8 @@ def get_rpm_header(f, ts=None):
|
|||
def get_header_field(hdr, name, src_arch=False):
|
||||
"""Extract named field from an rpm header"""
|
||||
name = name.upper()
|
||||
opt_dep_hdrs = (
|
||||
'SUGGESTNAME', 'SUGGESTVERSION', 'SUGGESTFLAGS',
|
||||
'ENHANCENAME', 'ENHANCEVERSION', 'ENHANCEFLAGS',
|
||||
'SUPPLEMENTNAME', 'SUPPLEMENTVERSION', 'SUPPLEMENTFLAGS',
|
||||
'RECOMMENDNAME', 'RECOMMENDVERSION', 'RECOMMENDFLAGS')
|
||||
if not RPM_SUPPORTS_OPTIONAL_DEPS and name in opt_dep_hdrs:
|
||||
# if field is not supported by host's rpm (>4.12), return empty list
|
||||
if not SUPPORTED_OPT_DEP_HDRS.get(name, True):
|
||||
return []
|
||||
|
||||
if (src_arch and name == "ARCH"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class TestGetRPMDeps(unittest.TestCase):
|
|||
getRPMDeps = kojihub.RootExports().getRPMDeps
|
||||
res = getRPMDeps('')
|
||||
# limit test for rpm < 4.12
|
||||
if koji.RPM_SUPPORTS_OPTIONAL_DEPS:
|
||||
if any(koji.SUPPORTED_OPT_DEP_HDRS.values()):
|
||||
self.assertEqual(len(res), 22)
|
||||
types = set([x['type'] for x in res])
|
||||
self.assertEqual(set([koji.DEP_REQUIRE,
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class HeaderTestCase(unittest.TestCase):
|
|||
|
||||
@mock.patch('rpm.RPMTAG_NOSOURCE', new=None)
|
||||
@mock.patch('rpm.RPMTAG_NOPATCH', new=None)
|
||||
@mock.patch('koji.RPM_SUPPORTS_OPTIONAL_DEPS', new=False)
|
||||
@mock.patch('koji.SUPPORTED_OPT_DEP_HDRS', new={'SUGGESTNAME': False})
|
||||
def test_get_header_field_workarounds(self):
|
||||
srpm0 = os.path.join(self.rpmdir, 'test-src-1-1.fc24.src.rpm')
|
||||
srpm1 = os.path.join(self.rpmdir, 'test-nosrc-1-1.fc24.nosrc.rpm')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue