Test/dnf4.mark: make the test compatible with all dnf versions

Let's revert to using plain 'dnf', add an explicit newline in the query
format and skip empty lines when processing the output. This makes the
test case compatible with all DNF versions, even with dnf5 once this
issue gets fixed.

The previous approach didn't work on c9s / el9, because there is no
'/usr/bin/dnf4 -> dnf-3' symlink.

Also see:
https://github.com/osbuild/osbuild/actions/runs/10136827918/job/28026181824

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-07-29 10:17:02 +02:00 committed by Tomáš Hozza
parent 4edbe227d4
commit a8f3a1e834

View file

@ -537,15 +537,12 @@ class TestStages(test.TestBase):
assert os.path.isdir(tree)
# we're going to verify that packages in the tree are marked according to
# Explicitly use 'dnf4' for now, because 'dnf5' contains a breaking change
# in the repoquery --qf output, specifically it does not add a trailing newline.
# We can use plan 'dnf' again once https://github.com/rpm-software-management/dnf5/issues/709 is fixed.
r = subprocess.run(
[
"dnf4",
"dnf",
"--installroot", tree,
"repoquery", "--installed",
"--qf", "%{name},%{reason}"
"--qf", "%{name},%{reason}\n"
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@ -554,6 +551,12 @@ class TestStages(test.TestBase):
)
for line in r.stdout.splitlines():
# 'dnf5' contains a breaking change in the repoquery --qf output, specifically it does not add
# a trailing newline. For this reason, we add it explicitly in the query format above. This however
# means that there are empty lines in the output, if 'dnf' points to 'dnf4'.
# Upstream bug https://github.com/rpm-software-management/dnf5/issues/709
if not line:
continue
package, mark = line.strip().split(",")
if package == "dnf":