| |
@@ -158,14 +158,13 @@
|
| |
_download_metadata_files(repo_definition)
|
| |
_download_bootstrap_modulemd()
|
| |
|
| |
- _SRPM_REVERSE_LOOKUP = {} # SRPM name : module name
|
| |
- _RPM_REVERSE_LOOKUP = {} # RPM name : module name
|
| |
- _BETTER_SRPM_REVERSE_LOOKUP = {} # SRPM name : [module names]
|
| |
- _BETTER_RPM_REVERSE_LOOKUP = {} # RPM name : [module names]
|
| |
- _BOOTSTRAP_REVERSE_LOOKUP = {}
|
| |
+ _SRPM_REVERSE_LOOKUP = {} # SRPM name : [module names]
|
| |
+ _RPM_REVERSE_LOOKUP = {} # RPM name : [module names]
|
| |
+ _BOOTSTRAP_COMPONENTS = set()
|
| |
_MODULE_FORWARD_LOOKUP = {}
|
| |
def _populate_module_reverse_lookup():
|
| |
- # TODO: Cache the reverse mapping as a JSON file, as with _BOOTSTRAP_REVERSE_LOOKUP_CACHE
|
| |
+ # TODO: Construct and cache the reverse mapping as a JSON file as part of
|
| |
+ # download_repo_metadata(), as with _BOOTSTRAP_REVERSE_LOOKUP_CACHE
|
| |
if _RPM_REVERSE_LOOKUP:
|
| |
return
|
| |
metadata_dir = os.path.join(_x86_64_MODULE_INFO.local_cache_path)
|
| |
@@ -190,29 +189,19 @@
|
| |
for module in modules:
|
| |
_MODULE_FORWARD_LOOKUP[module.name] = module
|
| |
for srpmname in module.components.rpms:
|
| |
- # This isn't entirely valid, as it doesn't account for multiple
|
| |
- # modules that include the same source RPM with different output
|
| |
- # filters (e.g. python3-ecosystem vs python2-ecosystem)
|
| |
- _SRPM_REVERSE_LOOKUP[srpmname] = module.name
|
| |
- if srpmname not in _BETTER_SRPM_REVERSE_LOOKUP:
|
| |
- _BETTER_SRPM_REVERSE_LOOKUP[srpmname] = []
|
| |
- _BETTER_SRPM_REVERSE_LOOKUP[srpmname].append(module.name)
|
| |
+ srpm_entry = _SRPM_REVERSE_LOOKUP.setdefault(srpmname, [])
|
| |
+ srpm_entry.append(module.name)
|
| |
for rpmname in module.artifacts.rpms:
|
| |
- # This is only valid for module sets that are guaranteed to be
|
| |
- # fully coinstallable, and hence only allow any given RPM to be
|
| |
- # published by at most one module
|
| |
rpmprefix = rpmname.split(":", 1)[0].rsplit("-", 1)[0]
|
| |
- _RPM_REVERSE_LOOKUP[rpmprefix] = module.name
|
| |
- if rpmprefix not in _BETTER_RPM_REVERSE_LOOKUP:
|
| |
- _BETTER_RPM_REVERSE_LOOKUP[rpmprefix] = []
|
| |
- _BETTER_RPM_REVERSE_LOOKUP[rpmprefix].append(module.name)
|
| |
+ rpm_entry = _RPM_REVERSE_LOOKUP.setdefault(rpmprefix, [])
|
| |
+ rpm_entry.append(module.name)
|
| |
# Read the extra RPM bootstrap metadata
|
| |
if not os.path.exists(_BOOTSTRAP_REVERSE_LOOKUP_CACHE):
|
| |
msg = (f"{_BOOTSTRAP_REVERSE_LOOKUP_CACHE!r} does not exist. "
|
| |
"Try running `fedmod fetch-metadata` again.")
|
| |
raise MissingMetadata(msg)
|
| |
with open(_BOOTSTRAP_REVERSE_LOOKUP_CACHE, "r") as cachefile:
|
| |
- _BOOTSTRAP_REVERSE_LOOKUP.update(json.load(cachefile))
|
| |
+ _BOOTSTRAP_COMPONENTS.update(json.load(cachefile))
|
| |
|
| |
def list_modules():
|
| |
return _MODULE_FORWARD_LOOKUP.keys()
|
| |
@@ -223,17 +212,21 @@
|
| |
return set()
|
| |
|
| |
def get_modules_for_rpm(rpm_name):
|
| |
- result = _BETTER_RPM_REVERSE_LOOKUP.get(rpm_name)
|
| |
+ result = _RPM_REVERSE_LOOKUP.get(rpm_name)
|
| |
return result
|
| |
|
| |
def get_module_for_rpm(rpm_name, *, allow_bootstrap=False):
|
| |
result = _RPM_REVERSE_LOOKUP.get(rpm_name)
|
| |
- if allow_bootstrap and result is None:
|
| |
- _BOOTSTRAP_REVERSE_LOOKUP.get(rpm_name)
|
| |
+ if result is not None:
|
| |
+ if len(result) > 1:
|
| |
+ log.warn(f"Multiple modules found for {rpm_name!r}: {','.join(result)}")
|
| |
+ result = result[0]
|
| |
+ elif allow_bootstrap and rpm_name in _BOOTSTRAP_COMPONENTS:
|
| |
+ result = "bootstrap"
|
| |
return result
|
| |
|
| |
def get_rpm_reverse_lookup():
|
| |
- return _BETTER_RPM_REVERSE_LOOKUP
|
| |
+ return _RPM_REVERSE_LOOKUP
|
| |
|
| |
class Repo(object):
|
| |
def __init__(self, name, metadata_path):
|
| |