Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new RPMTAG_MODULARITYLABEL to identify modular RPMs #1368

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/pulp_rpm/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,7 @@

# used in profiler for applicability
VIRTUAL_MODULEMDS = ['platform']

# Id of the tag which is used to analyze RPM headers at upload or download time.
# It's availiable in rpm package in F30+ and Centos8+.
RPMTAG_MODULARITYLABEL = 5096

This comment was marked as outdated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind

17 changes: 10 additions & 7 deletions plugins/pulp_rpm/plugins/importers/yum/parse/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_package_xml(pkg_path, sumtype=util.TYPE_SHA256):
# https://bugzilla.redhat.com/show_bug.cgi?id=1290021
sumtype_as_str = str(sumtype)
po = yumbased.CreateRepoPackage(ts, pkg_path, sumtype=sumtype_as_str)
except Exception, e:
except Exception as e:
# I hate this, but yum doesn't use reasonable exceptions like IOError
# and ValueError.
_LOGGER.error(str(e))
Expand Down Expand Up @@ -186,8 +186,8 @@ def filter_signature(unit, config):
if allowed_keys:
allowed_keys = [key.lower() for key in allowed_keys]
if signing_key and signing_key not in allowed_keys:
raise PulpCodedException(error_code=error_codes.RPM1014, key=signing_key,
package=unit.filename, allowed=allowed_keys)
raise PulpCodedException(error_code=error_codes.RPM1014, key=signing_key,
package=unit.filename, allowed=allowed_keys)


def nevra(name):
Expand Down Expand Up @@ -330,14 +330,17 @@ def get_package_modular_flag(headers):
Look at package headers and decide if a package is modular or not.

DISTTAG tag should contain 'module(...)' substring for package to be a modular one.
DISTTAG is no longer used, new tag MODULARITYLABEL is introduced for the purpose
of labeling modular RPMs. We should support both since old content still might be around.

:param headers: package headers
:type headers: rpm.hdr

:return: True, if package is a modular one
:rtype: boolean
"""
modular_flag = headers[rpm_module.RPMTAG_DISTTAG]
if modular_flag is None:
return False
return bool(re.match(r'module\(.*?\)', modular_flag))
disttag = bool(re.match(r'module\(.*?\)', headers[rpm_module.RPMTAG_DISTTAG] or ''))
modularitylabel = headers[constants.RPMTAG_MODULARITYLABEL]
if modularitylabel or disttag:
return True
return False