lpapicache: remove fallback_arch from getBinaries

Even for 'all' arch binaries, there are separate BPPHs per arch,
so we should index them properly by actual arch.
This commit is contained in:
Dan Streetman 2020-02-07 06:56:44 -05:00
parent 5838fa39ff
commit 5553d98e47

View File

@ -806,20 +806,12 @@ class SourcePackagePublishingHistory(BaseWrapper):
if not arch: if not arch:
raise RuntimeError("Must specify arch") raise RuntimeError("Must specify arch")
# debs with arch 'all' have to be categorized as a specific arch
# so use requested arch if not 'all', or system arch
fallback_arch = arch
if fallback_arch == 'all':
fallback_arch = host_architecture()
if self.status in ["Pending", "Published"]: if self.status in ["Pending", "Published"]:
# Published, great! Directly query the list of binaries # Published, great! Directly query the list of binaries
binaries = map(BinaryPackagePublishingHistory, binaries = map(BinaryPackagePublishingHistory,
self._lpobject.getPublishedBinaries()) self._lpobject.getPublishedBinaries())
for b in binaries: for b in binaries:
a = b.arch a = b.arch
if a == 'all':
a = fallback_arch
if a not in self._binaries: if a not in self._binaries:
self._binaries[a] = {} self._binaries[a] = {}
self._binaries[a][b.binary_package_name] = b self._binaries[a][b.binary_package_name] = b
@ -835,10 +827,12 @@ class SourcePackagePublishingHistory(BaseWrapper):
(pkgname, _, e) = filename.rpartition('.') (pkgname, _, e) = filename.rpartition('.')
# split into name, version, arch # split into name, version, arch
(n, v, a) = pkgname.rsplit('_', 2) (n, v, a) = pkgname.rsplit('_', 2)
# arch 'all' has separate bpph for each real arch,
# but all point to the same binary url
if a == 'all': if a == 'all':
a = fallback_arch a = arch or host_architecture()
# Only check the arch requested - saves time # Only check the arch requested - saves time
if arch != 'all' and arch != a: if arch and arch != a:
continue continue
# Only check the name requested - saves time # Only check the name requested - saves time
if name and not re.match(name, n): if name and not re.match(name, n):
@ -864,12 +858,12 @@ class SourcePackagePublishingHistory(BaseWrapper):
self._binaries[a] = {} self._binaries[a] = {}
self._binaries[a][n] = bpph self._binaries[a][n] = bpph
bpphs = [] if not arch:
if arch == 'all': bpphs = [b for a in self._binaries.values() for b in a.values()]
for a in self._binaries.values():
bpphs += a.values()
elif arch in self._binaries: elif arch in self._binaries:
bpphs = self._binaries[arch].copy().values() bpphs = list(self._binaries[arch].values())
else:
return []
if name: if name:
bpphs = [b for b in bpphs if re.match(name, b.binary_package_name)] bpphs = [b for b in bpphs if re.match(name, b.binary_package_name)]