From 2c96df2d455c81fbe1fac92b09b439f172c65e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 29 Jul 2024 13:59:42 +0200 Subject: [PATCH] Backport upstream fix for unit test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: RHEL-32133 Signed-off-by: Tomáš Hozza --- PR1825.patch | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++ osbuild.spec | 7 +++- 2 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 PR1825.patch diff --git a/PR1825.patch b/PR1825.patch new file mode 100644 index 0000000..66ce787 --- /dev/null +++ b/PR1825.patch @@ -0,0 +1,112 @@ +From 1f628f20d75472e2e629c637dec0dec1d82769eb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= +Date: Mon, 29 Jul 2024 10:17:02 +0200 +Subject: [PATCH 1/2] Test/dnf4.mark: make the test compatible with all dnf + versions +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +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 +Signed-off-by: Tomáš Hozza +--- + test/run/test_stages.py | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/test/run/test_stages.py b/test/run/test_stages.py +index ca224f07..476be949 100644 +--- a/test/run/test_stages.py ++++ b/test/run/test_stages.py +@@ -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": +-- +2.45.2 + + +From 4c4a23e5f628e9553328bc8342212e3272c7ab3f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= +Date: Mon, 29 Jul 2024 10:19:13 +0200 +Subject: [PATCH 2/2] Test/dnf4.mark: make failures to parse dnf output easier + to debug +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The test case still fails on RHEL-10.0 Beta, even when not using dnf5, +with: + +``` + for line in r.stdout.splitlines(): +> package, mark = line.strip().split(",") +E ValueError: not enough values to unpack (expected 2, got 1) +``` + +Make debugging of failures like this easier by printing the line when +the issue happens. + +Signed-off-by: Tomáš Hozza +--- + test/run/test_stages.py | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/test/run/test_stages.py b/test/run/test_stages.py +index 476be949..dc91bf8f 100644 +--- a/test/run/test_stages.py ++++ b/test/run/test_stages.py +@@ -557,7 +557,12 @@ class TestStages(test.TestBase): + # Upstream bug https://github.com/rpm-software-management/dnf5/issues/709 + if not line: + continue +- package, mark = line.strip().split(",") ++ ++ try: ++ package, mark = line.strip().split(",") ++ except ValueError: ++ print(f"Failed to parse line: {line}") ++ raise + + if package == "dnf": + assert mark == "user" +-- +2.45.2 + diff --git a/osbuild.spec b/osbuild.spec index cad94a8..a42b62e 100644 --- a/osbuild.spec +++ b/osbuild.spec @@ -9,7 +9,7 @@ Version: 123 %global pkgdir %{_prefix}/lib/%{pypi_name} Name: %{pypi_name} -Release: 1%{?dist} +Release: 2%{?dist} License: Apache-2.0 URL: %{forgeurl} @@ -20,6 +20,8 @@ Summary: A build system for OS images # https://github.com/osbuild/osbuild/pull/1824 Patch0: PR1824.patch +# https://github.com/osbuild/osbuild/pull/1825 +Patch1: PR1825.patch BuildRequires: make BuildRequires: python3-devel @@ -289,6 +291,9 @@ fi %{_libexecdir}/osbuild-depsolve-dnf %changelog +* Mon Jul 29 2024 Tomáš Hozza +- Backport upstream fix for unit test + * Thu Jul 25 2024 imagebuilder-bot - 123-1 - New upstream release