Skip to content

Commit a5b69b9

Browse files
praiskupxsuchy
authored andcommitted
buildroot_lock: better error reporting
I've observed that we frequently encounter `annobin-docs.noarch` being reported as the missed package, presumably due to it being the first one alphabetically. Let's modify the reporting to list all the missing packages instead. Relates: rpm-software-management/dnf5#1673
1 parent 8640f35 commit a5b69b9

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

mock/py/mockbuild/installed_packages.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@ def query_packages_location(packages, chrootpath=None,
132132
arch = basename.split(".")[-2]
133133
location_map[f"{name}.{arch}"] = url
134134

135+
failed_packages = []
135136
for package in packages:
136137
name_arch = f"{package['name']}.{package['arch']}"
137138
try:
138139
package["url"] = location_map[name_arch]
139-
except KeyError as exc:
140-
raise mockbuild.exception.Error(f"Can't get location for {name_arch}") from exc
140+
except KeyError:
141+
failed_packages.append(package)
142+
143+
if failed_packages:
144+
failed_str = ", ".join([f"{p['name']}-{p['version']}-{p['release']}.{p['arch']}"
145+
for p in failed_packages])
146+
raise mockbuild.exception.Error(f"Can't get location for {failed_str}")

mock/tests/test_buildroot_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def test_nonexisting_file_in_repo():
129129
try:
130130
_call_method(plugins, buildroot)
131131
except mockbuild.exception.Error as e:
132-
assert e.msg == "Can't get location for cyrus-sasl-lib.x86_64"
132+
assert e.msg == "Can't get location for cyrus-sasl-lib-2.1.27-21.el9.x86_64"
133133
raised = True
134134
assert raised
135135

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The buildroot_lock plugin's error reporting has been improved to display all the
2+
package NVRAs that are not found in the configured DNF repositories.

0 commit comments

Comments
 (0)