Backport upstream PR 1780

(cherry picked from commit 94c3195e7398d8f75720216676a87509e2177fc2)
This commit is contained in:
Lubomír Sedlář 2024-08-28 09:42:10 +03:00 committed by Stepan Oksanichenko
parent e9ed4402e6
commit 8334b2f027
2 changed files with 218 additions and 0 deletions

214
1780.patch Normal file
View File

@ -0,0 +1,214 @@
From d351773dab7b3aa8e6de82bbe23058b6b3448dd4 Mon Sep 17 00:00:00 2001
From: Lubomír Sedlář <lsedlar@redhat.com>
Date: Aug 26 2024 06:53:10 +0000
Subject: kiwibuild: Add options for version and repo_releasever
The version follows the same rules as versioning for live media etc.
That means it's always going to be set. The precedence goes like this:
* image specific option
* `kiwibuild_version`
* `global_version`
* `release_version` or `<release_version>_<label_milestone>`.
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
---
diff --git a/doc/configuration.rst b/doc/configuration.rst
index b0a6d5c..c6f936a 100644
--- a/doc/configuration.rst
+++ b/doc/configuration.rst
@@ -1570,6 +1570,13 @@ KiwiBuild Settings
* ``type_attr`` -- (*[str]*) override default attributes for the build type
from description.
* ``bundle_name_format`` -- (*str*) override default bundle format name.
+ * ``version`` -- (*str*) override version. Follows the same rules as
+ described in :ref:`automatic versioning <auto-version>`.
+ * ``repo_releasever`` -- (*str*) Override default releasever of the output
+ image.
+
+ The options can be set either for the specific image, or at the phase level
+ (see below). Version also falls back to ``global_version``.
**kiwibuild_description_scm**
(*str*) -- URL for scm containing the description files
@@ -1586,6 +1593,12 @@ KiwiBuild Settings
**kiwibuild_bundle_name_format**
(*str*) -- override default bundle format name.
+**kiwibuild_version**
+ (*str*) -- overide version for all kiwibuild tasks.
+
+**kiwibuild_repo_releasever**
+ (*str*) -- override releasever for all kiwibuild tasks.
+
OSBuild Composer for building images
====================================
diff --git a/pungi/checks.py b/pungi/checks.py
index dae31f5..bcf23e5 100644
--- a/pungi/checks.py
+++ b/pungi/checks.py
@@ -1212,6 +1212,8 @@ def make_schema():
"type": {"type": "string"},
"type_attr": {"$ref": "#/definitions/list_of_strings"},
"bundle_name_format": {"type": "string"},
+ "version": {"type": "string"},
+ "repo_releasever": {"type": "string"},
},
"required": [
# description_scm and description_path
@@ -1233,6 +1235,8 @@ def make_schema():
"kiwibuild_type": {"type": "string"},
"kiwibuild_type_attr": {"$ref": "#/definitions/list_of_strings"},
"kiwibuild_bundle_name_format": {"type": "string"},
+ "kiwibuild_version": {"type": "string"},
+ "kiwibuild_repo_releasever": {"type": "string"},
"osbuild_target": {"type": "string"},
"osbuild_release": {"$ref": "#/definitions/optional_string"},
"osbuild_version": {"type": "string"},
diff --git a/pungi/phases/kiwibuild.py b/pungi/phases/kiwibuild.py
index fabcce5..7ce3a54 100644
--- a/pungi/phases/kiwibuild.py
+++ b/pungi/phases/kiwibuild.py
@@ -84,6 +84,8 @@ class KiwiBuildPhase(
"bundle_name_format": self.get_config(
image_conf, "bundle_name_format"
),
+ "version": self.get_version(image_conf),
+ "repo_releasever": self.get_config(image_conf, "repo_releasever"),
}
repo = self._get_repo(image_conf, variant)
@@ -144,6 +146,8 @@ class RunKiwiBuildThread(WorkerThread):
result_bundle_name_format=generics["bundle_name_format"],
# this ensures the task won't fail if only failable arches fail
optional_arches=self.failable_arches,
+ version=generics["version"],
+ repo_releasever=generics["repo_releasever"],
)
koji.save_task_id(task_id)
diff --git a/tests/test_kiwibuildphase.py b/tests/test_kiwibuildphase.py
index 237dcaf..50116a2 100644
--- a/tests/test_kiwibuildphase.py
+++ b/tests/test_kiwibuildphase.py
@@ -50,6 +50,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": None,
"type_attr": None,
"bundle_name_format": None,
+ "version": compose.image_version,
+ "repo_releasever": None,
},
[self.topdir + "/compose/Server/$arch/os"],
[], # failable arches
@@ -69,6 +71,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": "custom",
"type_attr": ["foo", "bar"],
"bundle_name_format": "fmt",
+ "version": "Rawhide",
+ "repo_releasever": "41",
},
MINIMAL_CONF,
)
@@ -95,6 +99,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": "custom",
"type_attr": ["foo", "bar"],
"bundle_name_format": "fmt",
+ "version": "Rawhide",
+ "repo_releasever": "41",
},
[
"https://example.com/repo/",
@@ -131,6 +137,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": None,
"type_attr": None,
"bundle_name_format": None,
+ "version": compose.image_version,
+ "repo_releasever": None,
},
[self.topdir + "/compose/Server/$arch/os"],
["x86_64"], # failable arches
@@ -151,6 +159,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"kiwibuild_type": "custom",
"kiwibuild_type_attr": ["foo", "bar"],
"kiwibuild_bundle_name_format": "fmt",
+ "kiwibuild_version": "Rawhide",
+ "kiwibuild_repo_releasever": "41",
},
)
@@ -175,6 +185,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": "custom",
"type_attr": ["foo", "bar"],
"bundle_name_format": "fmt",
+ "version": "Rawhide",
+ "repo_releasever": "41",
},
[self.topdir + "/compose/Server/$arch/os"],
[], # failable arches
@@ -190,6 +202,7 @@ class TestKiwiBuildPhase(PungiTestCase):
"kiwibuild": {"^Server$": [cfg]},
"global_target": "f40",
"global_release": "1234",
+ "global_version": "41",
},
)
@@ -214,6 +227,8 @@ class TestKiwiBuildPhase(PungiTestCase):
"type": None,
"type_attr": None,
"bundle_name_format": None,
+ "version": "41",
+ "repo_releasever": None,
},
[self.topdir + "/compose/Server/$arch/os"],
[], # failable arches
@@ -278,6 +293,8 @@ class TestKiwiBuildThread(PungiTestCase):
"type": "t",
"type_attr": ["ta"],
"bundle_name_format": "fmt",
+ "version": "v",
+ "repo_releasever": "r",
},
[self.repo],
[],
@@ -298,6 +315,8 @@ class TestKiwiBuildThread(PungiTestCase):
type_attr=["ta"],
result_bundle_name_format="fmt",
optional_arches=[],
+ version="v",
+ repo_releasever="r",
)
]
@@ -362,6 +381,8 @@ class TestKiwiBuildThread(PungiTestCase):
"type": None,
"type_attr": None,
"bundle_name_format": None,
+ "version": None,
+ "repo_releasever": None,
},
[self.repo],
[],
@@ -413,6 +434,8 @@ class TestKiwiBuildThread(PungiTestCase):
"type": None,
"type_attr": None,
"bundle_name_format": None,
+ "version": None,
+ "repo_releasever": None,
},
[self.repo],
["amd64"],
@@ -433,6 +456,8 @@ class TestKiwiBuildThread(PungiTestCase):
type_attr=None,
result_bundle_name_format=None,
optional_arches=["amd64"],
+ version=None,
+ repo_releasever=None,
)
]
assert get_image_paths.mock_calls == [mock.call(1234)]

View File

@ -8,6 +8,7 @@ Summary: Distribution compose tool
License: GPL-2.0-only
URL: https://pagure.io/pungi
Source0: %{name}-%{version}.tar.bz2
Patch: https://pagure.io/pungi/pull-request/1780.patch
BuildRequires: make
BuildRequires: python3-pytest
@ -190,6 +191,9 @@ rm %{buildroot}%{_bindir}/pungi
* Thu Sep 05 2024 Stepan Oksanichenko <soksanichenko@almalinux.org> - 4.7.0-2
- Use xorriso as recommended package and genisoimage as required for RHEL8/9 and vice versa for RHEL10
* Wed Aug 28 2024 Lubomír Sedlář <lsedlar@redhat.com> - 4.7.0-2
- Backport patch with kiwibuild options version and repo_releasever
* Thu Aug 22 2024 Lubomír Sedlář <lsedlar@redhat.com> - 4.7.0-1
- kiwibuild: Add support for type, type attr and bundle format (lsedlar)
- createiso: Block reuse if unsigned packages are allowed (lsedlar)