Compare commits

..

No commits in common. "c8-beta" and "c9s" have entirely different histories.
c8-beta ... c9s

10 changed files with 452 additions and 9374 deletions

10
.gitignore vendored
View File

@ -1 +1,9 @@
SOURCES/modulemd-tools-0.7.tar.gz
/dir2module-0.1.tar.gz
/modulemd-tools-0.1.tar.gz
/modulemd-tools-0.3.tar.gz
/modulemd-tools-0.4.tar.gz
/modulemd-tools-0.5.tar.gz
/modulemd-tools-0.6.tar.gz
/modulemd-tools-0.7.tar.gz
/modulemd-tools-0.8.tar.gz
/modulemd-tools-0.9.tar.gz

View File

@ -1 +1 @@
20c992eeb765a8651210d9151248bd09b97ac127 SOURCES/modulemd-tools-0.7.tar.gz
de632f2d9259df3921deeb43b33fae20222cb54f modulemd-tools-0.9.tar.gz

View File

@ -0,0 +1,193 @@
From 908b48d28cf68946dfe2f309d73f3f2a12efe021 Mon Sep 17 00:00:00 2001
From: Jakub Kadlcik <frostyx@email.cz>
Date: Thu, 19 Aug 2021 00:33:59 +0200
Subject: [PATCH] dir2module: generate also profiles and modulemd-defaults file
---
dir2module/dir2module/dir2module.py | 102 ++++++++++++++++++++++++----
dir2module/tests/conftest.py | 2 +-
2 files changed, 90 insertions(+), 14 deletions(-)
diff --git a/dir2module/dir2module/dir2module.py b/dir2module/dir2module/dir2module.py
index 9902aec..6643a83 100755
--- a/dir2module/dir2module/dir2module.py
+++ b/dir2module/dir2module/dir2module.py
@@ -20,13 +20,13 @@ gi.require_version("Modulemd", "2.0")
from gi.repository import Modulemd # noqa: E402
-class Module(object):
+class ModuleBase:
"""
- Provide a high-level interface for representing modules and yaml generation
- based on their values.
+ Base class for modulemd things
"""
+
def __init__(self, name, stream, version, context, arch, summary,
- description, module_license, licenses, package_nevras, requires):
+ description, module_license, licenses, packages, requires):
self.name = name
self.stream = stream
self.version = version
@@ -36,18 +36,69 @@ class Module(object):
self.description = description
self.module_license = module_license
self.licenses = licenses
- self.package_nevras = package_nevras
+ self.packages = packages
self.requires = requires
+ @property
+ def filename_format(self):
+ """
+ String format for the modulemd filename. It can contain the following
+ variables:
+ {N} - Module name
+ {S} - Module stream name
+ {V} - Module version
+ {C} - Module context
+ {A} - Module architecture
+ """
+ raise NotImplementedError
+
+ def dumps(self):
+ """
+ Generate YAML based on input parameters and return it as a string
+ """
+ raise NotImplementedError
+
@property
def filename(self):
"""
Generate filename for a module yaml
"""
- return "{N}:{S}:{V}:{C}:{A}.modulemd.yaml".format(
+ return self.filename_format.format(
N=self.name, S=self.stream, V=self.version,
C=self.context, A=self.arch)
+ def dump(self):
+ """
+ Generate modulemd yaml based on input parameters write it into file
+ """
+ with open(self.filename, "w") as moduleyaml:
+ moduleyaml.write(self.dumps())
+
+ @property
+ def package_names(self):
+ """
+ Return the list of unique package names within this module
+ """
+ return {package.header.name for package in self.packages}
+
+ @property
+ def package_nevras(self):
+ """
+ Return the list of unique package NEVRAs within this module
+ """
+ return {package.nevra for package in self.packages}
+
+
+class Module(ModuleBase):
+ """
+ Provide a high-level interface for representing modules and yaml generation
+ based on their values.
+ """
+
+ @property
+ def filename_format(self):
+ return "{N}:{S}:{V}:{C}:{A}.modulemd.yaml"
+
def dumps(self):
"""
Generate modulemd yaml based on input parameters and return it as a string
@@ -70,16 +121,37 @@ class Module(object):
dependencies.add_runtime_stream(depname, depstream)
mod_stream.add_dependencies(dependencies)
+ profile = Modulemd.Profile.new("common")
+ for pkgname in self.package_names:
+ profile.add_rpm(pkgname)
+ mod_stream.add_profile(profile)
+
index = Modulemd.ModuleIndex.new()
index.add_module_stream(mod_stream)
return index.dump_to_string()
- def dump(self):
+
+class ModuleDefaults(ModuleBase):
+ """
+ Provide a high-level interface for representing modulemd defaults files
+ """
+
+ @property
+ def filename_format(self):
+ return "{N}:{S}:{V}:{C}:{A}.modulemd-defaults.yaml"
+
+ def dumps(self):
"""
- Generate modulemd yaml based on input parameters write it into file
+ Generate modulemd_defaults yaml based on input parameters and return it
+ as a string
"""
- with open(self.filename, "w") as moduleyaml:
- moduleyaml.write(self.dumps())
+ mod_defaults = Modulemd.DefaultsV1.new(self.name)
+ mod_defaults.set_default_stream(self.stream)
+ mod_defaults.add_default_profile_for_stream(self.stream, "common")
+
+ index = Modulemd.ModuleIndex.new()
+ index.add_defaults(mod_defaults)
+ return index.dump_to_string()
class Package(object):
@@ -220,7 +292,6 @@ def main():
packages = [Package(package) for package in packages]
licenses = {package.license for package in packages}
- nevras = {package.nevra for package in packages}
requires = parse_dependencies(args.requires)
description = args.description \
@@ -238,8 +309,10 @@ def main():
raise RuntimeError("All packages need to contain the `modularitylabel` header. "
"To suppress this constraint, use `--force` parameter")
- module = Module(name, stream, version, context, arch, args.summary,
- description, args.license, licenses, nevras, requires)
+ modargs = [name, stream, version, context, arch, args.summary, description,
+ args.license, licenses, packages, requires]
+ module = Module(*modargs)
+ module_defaults = ModuleDefaults(*modargs)
if args.stdout:
print(module.dumps())
@@ -247,6 +320,9 @@ def main():
module.dump()
print("Created {0}".format(module.filename))
+ module_defaults.dump()
+ print("Created {0}".format(module_defaults.filename))
+
if __name__ == "__main__":
try:
diff --git a/dir2module/tests/conftest.py b/dir2module/tests/conftest.py
index 9309b44..c6956cb 100644
--- a/dir2module/tests/conftest.py
+++ b/dir2module/tests/conftest.py
@@ -15,7 +15,7 @@ def dummy_module():
'description': 'One dummy module for your tests',
'module_license': 'No License',
'licenses': [],
- 'package_nevras': [],
+ 'packages': [],
'requires': {}
}
--
2.41.0

View File

@ -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

View 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

View File

@ -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

File diff suppressed because it is too large Load Diff

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional}

View File

@ -1,15 +1,27 @@
Name: modulemd-tools
Version: 0.7
Release: 8%{?dist}
Version: 0.9
Release: 5%{?dist}
Summary: Collection of tools for parsing and generating modulemd YAML files
License: MIT
BuildArch: noarch
URL: https://github.com/rpm-software-management/modulemd-tools
Source0: https://github.com/rpm-software-management/modulemd-tools/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: modulemd-tools-0.7-1-to-modulemd-tools-0.7-8.patch
# https://github.com/rpm-software-management/modulemd-tools/commit/195df77
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: argparse-manpage
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-libmodulemd >= 2.9.3
@ -48,12 +60,9 @@ modulemd-generate-macros - Generate module-build-macros SRPM package, which is
a central piece for building modules. It should be present in the buildroot
before any other module packages are submitted to be built.
bld2repo - Simple tool for dowloading build required RPMs of a modular build from koji.
%prep
%setup -q
%patch0 -p1
%autosetup -p1
%build
@ -77,6 +86,8 @@ cd modulemd_tools
%py3_build
cd ..
PYTHONPATH=./modulemd_tools ./man/generate-manpages.sh
%install
cd repo2module
@ -154,46 +165,26 @@ cd ..
%{_mandir}/man1/createrepo_mod.1*
%{_mandir}/man1/modulemd-merge.1*
%{_mandir}/man1/modulemd-generate-macros.1.*
%{_mandir}/man1/bld2repo.1.*
%changelog
* Tue Jul 18 2023 Jakub Kadlcik <jkadlcik@redhat.com> 0.7-8
- modulemd_tools: fix tests for new libmodulemd version 2.15.0
(frostyx@email.cz)
- createrepo: replace deprecated LooseVersion (mkulik@redhat.com)
* 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
* Thu Jun 29 2023 Jakub Kadlcik <jkadlcik@redhat.com> 0.7-7
- repo2module: don't traceback because of a modular SRPM in the repo
* Fri Jul 21 2023 Jakub Kadlcik <jkadlcik@redhat.com> - 0.9-4
- Generate profiles section and modulemd-defaults file
Related: rhbz#1801747
- Use autosetup to automatically apply patches
* Fri Aug 27 2021 Jakub Kadlcik <jkadlcik@redhat.com> 0.7-6
- Do not install bld2repo as RHEL8 doesn't have python3-koji
(jkadlcik@redhat.com)
- Drop the Patch1 and make the change directly in this repository
(jkadlcik@redhat.com)
- Use UpstreamBuilder instead of DistributionBuilder (jkadlcik@redhat.com)
- Skip some tests because they require binary files (jkadlcik@redhat.com)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 0.9-3
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Thu Aug 26 2021 Jakub Kadlcik <jkadlcik@redhat.com> 0.7-5
- Update to new upstream version
* Mon Aug 23 2021 Jakub Kadlcik <frostyx@email.cz> 0.11-1
- modulemd_tools: compatibility for upgrade_ext on EPEL8 (frostyx@email.cz)
- modulemd_tools: compatibility for read_packager_string on EPEL8
(frostyx@email.cz)
- dir2module: generate also profiles and modulemd-defaults file
(frostyx@email.cz)
- modulemd_tools: use upgrade_ext instead of upgrade (frostyx@email.cz)
- modulemd_tools: use read_packager_string instead of read_string
(frostyx@email.cz)
- Add installation instructions (frostyx@email.cz)
- bld2repo: do not create empty repos when --result-dir is used
(kdudka@redhat.com)
- bld2repo: print status in a more intuitive format (kdudka@redhat.com)
- tito: stop releasing for Fedora 32 (frostyx@email.cz)
* Mon Jun 14 2021 Jakub Kadlcik <frostyx@email.cz> 0.10-1
- Added bld2repo (mcurlej@redhat.com)
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 0.9-2
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Fri Apr 09 2021 Jakub Kadlcik <frostyx@email.cz> 0.9-1
- repo2module: drop python-click dependency (frostyx@email.cz)
@ -205,17 +196,6 @@ cd ..
- Add createrepo_mod tests (fvalder@redhat.com)
- Replace master in fedora releaser to rawhide (frostyx@email.cz)
* Tue Mar 02 2021 Jakub Kadlčík <jkadlcik@redhat.com> - 0.7-4
- Rebuild for 8.5.0
* Thu Feb 11 2021 Jakub Kadlčík <jkadlcik@redhat.com> - 0.7-3
- Bump spec to rebuild with gating enabled
* Tue Feb 09 2021 Jakub Kadlčík <jkadlcik@redhat.com> - 0.7-2
- Do not generate manpages on the fly
- Drop python-parameterized dependency
- Fix python3 macro for running tests
* Tue Feb 09 2021 Jakub Kadlcik <frostyx@email.cz> 0.7-1
- Generate manpages on the fly
- Automated test builds incl. Docker/Travis

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (modulemd-tools-0.9.tar.gz) = cf4c92f381933d0c57ecb79a95dcd66bfb19926e968bf304870284686a3120fe4a6c384f32bcc1548bd3b1179804ef9cb8c6ff5f5ae2f336eebc34aeead2a36d