repos: Better heuristics for repo 64-bitness

This commit is contained in:
Ivan A. Melnikov 2023-07-24 17:46:24 +04:00
parent 4469729bc1
commit e39256876e

View File

@ -137,14 +137,11 @@ class Binary:
class Repository:
def __init__(self, repo_name, sources, binaries, bits=None):
def __init__(self, repo_name, sources, binaries, bits):
self.name = repo_name
self.sources = sources
self.binaries = binaries
if bits is not None:
self.bits = bits
else:
self.bits = 64 if ('64' in self.name) else 32
self.bits = bits
self.reverse_prov = {} # name -> [(provide, binary)]
self.update_indexes()
@ -165,6 +162,8 @@ class Repository:
def load(cls, repo_name, path, arch, components=('classic',)):
src_list, bin_list = lists.read_pkglist_heders_for_repo(
path, arch, components)
# xxx: not the very best heuristics
bits = 64 if any('64' in a for a in arch) else 32
sources = {}
for header in src_list:
name = header[rpm.RPMTAG_NAME]
@ -179,7 +178,7 @@ class Repository:
else:
LOG.warning('Duplicate binaries: %s %s', found,
header.format('%{NAME}-%{EVR}:%{DISTTAG})'))
return cls(repo_name, sources, binaries)
return cls(repo_name, sources, binaries, bits=bits)
@classmethod
def load_from_config(cls, repo_name, config):