Don't traceback because of a modular SRPM in the repo
This commit is contained in:
parent
bac8cd6071
commit
a73f1a46ce
1
.modulemd-tools.metadata
Normal file
1
.modulemd-tools.metadata
Normal file
@ -0,0 +1 @@
|
|||||||
|
de632f2d9259df3921deeb43b33fae20222cb54f modulemd-tools-0.9.tar.gz
|
@ -0,0 +1,30 @@
|
|||||||
|
From 1188c8215955c14fadb1f17c2b55f4135db2a224 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jakub Kadlcik <frostyx@email.cz>
|
||||||
|
Date: Tue, 2 May 2023 00:12:39 +0200
|
||||||
|
Subject: [PATCH 2/4] repo2module: don't traceback because of a modular SRPM in
|
||||||
|
the repo
|
||||||
|
|
||||||
|
Fix RHBZ 2186223
|
||||||
|
---
|
||||||
|
repo2module/repo2module/cli.py | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/repo2module/repo2module/cli.py b/repo2module/repo2module/cli.py
|
||||||
|
index 1d4ce27..44dd24c 100644
|
||||||
|
--- a/repo2module/repo2module/cli.py
|
||||||
|
+++ b/repo2module/repo2module/cli.py
|
||||||
|
@@ -61,6 +61,11 @@ def get_source_packages(packages):
|
||||||
|
"""
|
||||||
|
source_packages = set()
|
||||||
|
for pkg in packages:
|
||||||
|
+ # In this case, the `pkg` is a SRPM file
|
||||||
|
+ if not pkg.rpm_sourcerpm:
|
||||||
|
+ source_packages.add(pkg.name)
|
||||||
|
+ continue
|
||||||
|
+
|
||||||
|
# Get the source RPM NEVRA without the trailing ".rpm"
|
||||||
|
subject = Subject(pkg.rpm_sourcerpm[:-4])
|
||||||
|
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
133
0003-createrepo-replace-deprecated-LooseVersion.patch
Normal file
133
0003-createrepo-replace-deprecated-LooseVersion.patch
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
From f3435b9a9f5ddff0d4593dbda7c5da592ea31f61 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Marek Kulik <mkulik@redhat.com>
|
||||||
|
Date: Wed, 20 Apr 2022 09:38:51 +0200
|
||||||
|
Subject: [PATCH 3/4] createrepo: replace deprecated LooseVersion
|
||||||
|
|
||||||
|
DeprecationWarning: The distutils package is
|
||||||
|
deprecated and slated for removal in Python 3.12
|
||||||
|
---
|
||||||
|
.../createrepo_mod/createrepo_mod.py | 13 +++++--
|
||||||
|
modulemd_tools/modulemd_tools/yaml.py | 39 +++++++++++++++++++
|
||||||
|
modulemd_tools/tests/test_yaml.py | 9 ++++-
|
||||||
|
3 files changed, 55 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/createrepo_mod/createrepo_mod/createrepo_mod.py b/createrepo_mod/createrepo_mod/createrepo_mod.py
|
||||||
|
index ee078f7..4e0eb71 100755
|
||||||
|
--- a/createrepo_mod/createrepo_mod/createrepo_mod.py
|
||||||
|
+++ b/createrepo_mod/createrepo_mod/createrepo_mod.py
|
||||||
|
@@ -16,11 +16,16 @@ https://docs.fedoraproject.org/en-US/modularity/hosting-modules/
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
+import argparse
|
||||||
|
import os
|
||||||
|
-import sys
|
||||||
|
import subprocess
|
||||||
|
-import argparse
|
||||||
|
-from distutils.version import LooseVersion
|
||||||
|
+import sys
|
||||||
|
+
|
||||||
|
+# python3-packaging in not available in RHEL 8.x
|
||||||
|
+try:
|
||||||
|
+ from packaging.version import Version
|
||||||
|
+except ModuleNotFoundError:
|
||||||
|
+ from distutils.version import LooseVersion as Version
|
||||||
|
|
||||||
|
import gi
|
||||||
|
gi.require_version("Modulemd", "2.0")
|
||||||
|
@@ -99,7 +104,7 @@ def createrepo_c_with_builtin_module_support():
|
||||||
|
"""
|
||||||
|
cmd = ["rpm", "-q", "createrepo_c", "--queryformat", "%{VERSION}"]
|
||||||
|
createrepo_c_version = subprocess.check_output(cmd).decode("utf-8")
|
||||||
|
- return LooseVersion(createrepo_c_version) >= LooseVersion("0.16.1")
|
||||||
|
+ return Version(createrepo_c_version) >= Version("0.16.1")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
diff --git a/modulemd_tools/modulemd_tools/yaml.py b/modulemd_tools/modulemd_tools/yaml.py
|
||||||
|
index 43f314f..ac644b6 100644
|
||||||
|
--- a/modulemd_tools/modulemd_tools/yaml.py
|
||||||
|
+++ b/modulemd_tools/modulemd_tools/yaml.py
|
||||||
|
@@ -8,6 +8,12 @@ import os
|
||||||
|
import gi
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
+# python3-packaging in not available in RHEL 8.x
|
||||||
|
+try:
|
||||||
|
+ from packaging.version import Version
|
||||||
|
+except ModuleNotFoundError:
|
||||||
|
+ from distutils.version import StrictVersion as Version
|
||||||
|
+
|
||||||
|
gi.require_version("Modulemd", "2.0")
|
||||||
|
from gi.repository import Modulemd # noqa: E402
|
||||||
|
|
||||||
|
@@ -307,3 +313,36 @@ def _stream2yaml(mod_stream):
|
||||||
|
return idx.dump_to_string()
|
||||||
|
except gi.repository.GLib.GError as ex:
|
||||||
|
raise RuntimeError(ex.message)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _modulemd_read_packager_string(mod_yaml, name=None, stream=None):
|
||||||
|
+ """
|
||||||
|
+ For the time being we happen to be in a transition state when
|
||||||
|
+ `Modulemd.ModuleStream.read_string` is deprecated and throws warnings on
|
||||||
|
+ Fedora but we still use old libmodulemd (2.9.4) on RHEL8, which doesn't
|
||||||
|
+ provide its replacement in the form of `Modulemd.read_packager_string`.
|
||||||
|
+ """
|
||||||
|
+ if Version(Modulemd.get_version()) < Version("2.11"):
|
||||||
|
+ mod_stream = Modulemd.ModuleStreamV2.new(name, stream)
|
||||||
|
+ mod_stream = mod_stream.read_string(mod_yaml, True, name, stream)
|
||||||
|
+ return mod_stream
|
||||||
|
+
|
||||||
|
+ return Modulemd.read_packager_string(mod_yaml, name, stream)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+def _modulestream_upgrade_ext(mod_stream, version):
|
||||||
|
+ """
|
||||||
|
+ For the time being we happen to be in a transition state when
|
||||||
|
+ `Modulemd.ModuleStream.upgrade` is deprecated and throws warnings on
|
||||||
|
+ Fedora but we still use old libmodulemd (2.9.4) on RHEL8, which doesn't
|
||||||
|
+ provide its replacement in the form of `Modulemd.ModuleStream.upgrade_ext`.
|
||||||
|
+ """
|
||||||
|
+ if Version(Modulemd.get_version()) < Version("2.10"):
|
||||||
|
+ return mod_stream.upgrade(version)
|
||||||
|
+
|
||||||
|
+ mod_upgraded = mod_stream.upgrade_ext(version)
|
||||||
|
+ return mod_upgraded.get_stream_by_NSVCA(
|
||||||
|
+ mod_stream.get_stream_name(),
|
||||||
|
+ mod_stream.get_version(),
|
||||||
|
+ mod_stream.get_context(),
|
||||||
|
+ mod_stream.get_arch())
|
||||||
|
diff --git a/modulemd_tools/tests/test_yaml.py b/modulemd_tools/tests/test_yaml.py
|
||||||
|
index 8090a2b..f51a330 100644
|
||||||
|
--- a/modulemd_tools/tests/test_yaml.py
|
||||||
|
+++ b/modulemd_tools/tests/test_yaml.py
|
||||||
|
@@ -2,10 +2,15 @@ import os
|
||||||
|
import unittest
|
||||||
|
from unittest import mock
|
||||||
|
import yaml
|
||||||
|
-from distutils.version import LooseVersion
|
||||||
|
from modulemd_tools.yaml import (is_valid, validate, create, update, dump,
|
||||||
|
upgrade, _yaml2stream, _stream2yaml)
|
||||||
|
|
||||||
|
+# python3-packaging in not available in RHEL 8.x
|
||||||
|
+try:
|
||||||
|
+ from packaging.version import Version
|
||||||
|
+except ModuleNotFoundError:
|
||||||
|
+ from distutils.version import LooseVersion as Version
|
||||||
|
+
|
||||||
|
import gi
|
||||||
|
gi.require_version("Modulemd", "2.0")
|
||||||
|
from gi.repository import Modulemd # noqa: E402
|
||||||
|
@@ -19,7 +24,7 @@ def old_libmodulemd():
|
||||||
|
skip those few test on EPEL8 until it receives an update.
|
||||||
|
See also `080e2bb`
|
||||||
|
"""
|
||||||
|
- return LooseVersion(Modulemd.get_version()) < LooseVersion("2.11.1")
|
||||||
|
+ return Version(Modulemd.get_version()) < Version("2.11.1")
|
||||||
|
|
||||||
|
|
||||||
|
class TestYaml(unittest.TestCase):
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -0,0 +1,47 @@
|
|||||||
|
From 0407a6af2f0c59e9619418a606d5d00183d40693 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jakub Kadlcik <frostyx@email.cz>
|
||||||
|
Date: Tue, 13 Jun 2023 18:19:15 +0200
|
||||||
|
Subject: [PATCH 4/4] modulemd_tools: fix tests for new libmodulemd version
|
||||||
|
2.15.0
|
||||||
|
|
||||||
|
---
|
||||||
|
modulemd_tools/tests/test_yaml.py | 15 +++++++++++++--
|
||||||
|
1 file changed, 13 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/modulemd_tools/tests/test_yaml.py b/modulemd_tools/tests/test_yaml.py
|
||||||
|
index f51a330..2f8b4d2 100644
|
||||||
|
--- a/modulemd_tools/tests/test_yaml.py
|
||||||
|
+++ b/modulemd_tools/tests/test_yaml.py
|
||||||
|
@@ -27,6 +27,10 @@ def old_libmodulemd():
|
||||||
|
return Version(Modulemd.get_version()) < Version("2.11.1")
|
||||||
|
|
||||||
|
|
||||||
|
+def min_libmodulemd_version(version):
|
||||||
|
+ return Version(Modulemd.get_version()) >= Version(version)
|
||||||
|
+
|
||||||
|
+
|
||||||
|
class TestYaml(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_is_valid(self):
|
||||||
|
@@ -57,9 +61,16 @@ class TestYaml(unittest.TestCase):
|
||||||
|
self.assertEqual(mod1["version"], 2)
|
||||||
|
self.assertEqual(mod1["data"]["name"], "foo")
|
||||||
|
self.assertEqual(mod1["data"]["stream"], "stable")
|
||||||
|
- self.assertEqual(mod1["data"]["summary"], None)
|
||||||
|
self.assertEqual(mod1["data"]["description"], "")
|
||||||
|
- self.assertEqual(mod1["data"]["license"]["module"], [None])
|
||||||
|
+
|
||||||
|
+ # Between libmodulemd version 2.14.0 and 2.15.0 a change in `None`
|
||||||
|
+ # vs empty string happened
|
||||||
|
+ if min_libmodulemd_version("2.15.0"):
|
||||||
|
+ self.assertEqual(mod1["data"]["summary"], "")
|
||||||
|
+ self.assertEqual(mod1["data"]["license"]["module"], [""])
|
||||||
|
+ else:
|
||||||
|
+ self.assertEqual(mod1["data"]["summary"], None)
|
||||||
|
+ self.assertEqual(mod1["data"]["license"]["module"], [None])
|
||||||
|
|
||||||
|
def test_update_after_build(self):
|
||||||
|
"""
|
||||||
|
--
|
||||||
|
2.41.0
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
Name: modulemd-tools
|
Name: modulemd-tools
|
||||||
Version: 0.9
|
Version: 0.9
|
||||||
Release: 4%{?dist}
|
Release: 5%{?dist}
|
||||||
Summary: Collection of tools for parsing and generating modulemd YAML files
|
Summary: Collection of tools for parsing and generating modulemd YAML files
|
||||||
License: MIT
|
License: MIT
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
@ -11,6 +11,14 @@ Source0: https://github.com/rpm-software-management/modulemd-tools/archive/%{ver
|
|||||||
# https://github.com/rpm-software-management/modulemd-tools/commit/195df77
|
# https://github.com/rpm-software-management/modulemd-tools/commit/195df77
|
||||||
Patch0: 0001-dir2module-generate-also-profiles-and-modulemd-defau.patch
|
Patch0: 0001-dir2module-generate-also-profiles-and-modulemd-defau.patch
|
||||||
|
|
||||||
|
# https://github.com/rpm-software-management/modulemd-tools/commit/0d718ca
|
||||||
|
Patch1: 0002-repo2module-don-t-traceback-because-of-a-modular-SRP.patch
|
||||||
|
|
||||||
|
# https://github.com/rpm-software-management/modulemd-tools/commit/cd04198
|
||||||
|
Patch2: 0003-createrepo-replace-deprecated-LooseVersion.patch
|
||||||
|
|
||||||
|
# https://github.com/rpm-software-management/modulemd-tools/commit/ac3b173
|
||||||
|
Patch3: 0004-modulemd_tools-fix-tests-for-new-libmodulemd-version.patch
|
||||||
|
|
||||||
BuildRequires: createrepo_c
|
BuildRequires: createrepo_c
|
||||||
BuildRequires: argparse-manpage
|
BuildRequires: argparse-manpage
|
||||||
@ -160,6 +168,12 @@ cd ..
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Sun Jul 30 2023 Jakub Kadlcik <jkadlcik@redhat.com> - 0.9-5
|
||||||
|
- Don't traceback because of a modular SRPM in the repo
|
||||||
|
Related: rhbz#2227436
|
||||||
|
- Replace deprecated LooseVersion
|
||||||
|
- Fix tests for new libmodulemd version 2.15.0
|
||||||
|
|
||||||
* Fri Jul 21 2023 Jakub Kadlcik <jkadlcik@redhat.com> - 0.9-4
|
* Fri Jul 21 2023 Jakub Kadlcik <jkadlcik@redhat.com> - 0.9-4
|
||||||
- Generate profiles section and modulemd-defaults file
|
- Generate profiles section and modulemd-defaults file
|
||||||
Related: rhbz#1801747
|
Related: rhbz#1801747
|
||||||
|
Loading…
Reference in New Issue
Block a user