Repository: osbuild/osbuild
Pull request #1769 (2024-04-30 17:46:40)

spec: Install osbuild-depsolve-dnf not dnf5
On Fedora 40 we switched to dnf5 too early. There is going to be a new version in Fedora 41 soon, with breaking API changes, so in order to reduce the number of things we need to support, switch back to using libdnf on Fedora 40 (and 41 until dnf5 version 5.2.0 is available, see #1768)


Patch:
diff --git a/osbuild.spec b/osbuild.spec
index 8e9c4a35..c94bb8a9 100644
--- a/osbuild.spec
+++ b/osbuild.spec
@@ -137,12 +137,7 @@ manifests and osbuild.
 Summary:        Dependency solving support for DNF
 Requires:       %{name} = %{version}-%{release}
 
-# Fedora 40 and later use libdnf5, RHEL and Fedora < 40 use libdnf
-%if 0%{?fedora} >= 40
-Requires: python3-libdnf5 >= 5.1.1
-%else
 Requires: python3-libdnf
-%endif
 
 %description    depsolve-dnf
 Contains depsolving capabilities for package managers.
@@ -213,12 +208,7 @@ install -p -m 0755 data/10-osbuild-inhibitor.rules %{buildroot}%{_udevrulesdir}
 
 # Install `osbuild-depsolve-dnf` into libexec
 mkdir -p %{buildroot}%{_libexecdir}
-# Fedora 40 and later use dnf5-json, RHEL and Fedora < 40 use dnf-json
-%if 0%{?fedora} >= 40
-install -p -m 0755 tools/osbuild-depsolve-dnf5 %{buildroot}%{_libexecdir}/osbuild-depsolve-dnf
-%else
 install -p -m 0755 tools/osbuild-depsolve-dnf %{buildroot}%{_libexecdir}/osbuild-depsolve-dnf
-%endif
 
 %check
 exit 0
diff --git a/stages/org.osbuild.skopeo b/stages/org.osbuild.skopeo
index ec62c595..45bb98db 100755
--- a/stages/org.osbuild.skopeo
+++ b/stages/org.osbuild.skopeo
@@ -13,7 +13,7 @@ def main(inputs, output, options):
 
     destination = options["destination"]
     dest_type = destination["type"]
-    remove_signatures = destination.get("remove-signatures")
+    remove_signatures = options.get("remove-signatures")
 
     for image in images.values():
         with containers.container_source(image) as (image_name, image_source):


Test patch:
diff --git a/stages/test/test_skopeo.py b/stages/test/test_skopeo.py
index 119e9ad4..13f897c0 100644
--- a/stages/test/test_skopeo.py
+++ b/stages/test/test_skopeo.py
@@ -118,3 +118,28 @@ def test_skopeo_copy_oci(tmp_path, stage_module):
     data_digest = data["manifests"][0]["digest"].split(':')
     manifest_file = result_path / "blobs" / data_digest[0] / data_digest[1]
     assert_manifest_file(manifest_file)
+
+
+@pytest.mark.parametrize("remove_signatures", [True, False])
+def test_skopeo_copy_remove_signatures(tmp_path, stage_module, remove_signatures):
+    # We are completely faking everything here, because we mock out skopeo
+    fake_oci_path = tmp_path / "fake-container"
+    inputs = make_fake_images_inputs(fake_oci_path, "some-name")
+
+    with testutil.mock_command("skopeo", "") as args:
+        options = {
+            "destination": {
+                "type": "oci",
+                "path": "/tmp/test-output-skopeo-dir",
+            },
+            "remove-signatures": remove_signatures,
+        }
+        output_dir = tmp_path / "output"
+        stage_module.main(inputs, output_dir, options)
+
+        if remove_signatures:
+            # Check that skopeo has --remove-signatures right after the copy subcommand
+            assert args.call_args_list[0][0:2] == ["copy", "--remove-signatures"]
+        else:
+            # Check that --remove-signatures is not present in the skopeo command
+            assert "--remove-signatures" not in args.call_args_list[0]