Add support for 'buildorder' to Packager documents

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2021-01-14 21:22:21 -05:00
parent d64a094808
commit 1647405f05
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11
5 changed files with 7 additions and 190 deletions

1
.gitignore vendored
View File

@ -55,3 +55,4 @@
/modulemd-2.11.0.tar.xz
/modulemd-2.11.1.tar.xz
/modulemd-2.11.2.tar.xz
/modulemd-2.12.0.tar.xz

View File

@ -1,31 +0,0 @@
From d8722735c4c5198a0a11ddaebf011034f677aa7f Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Mon, 11 Jan 2021 15:25:03 -0500
Subject: [PATCH 1/2] Add missing @staticmethod for python2
Fixes: https://github.com/fedora-modularity/libmodulemd/issues/537
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
bindings/python/gi/overrides/Modulemd.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/bindings/python/gi/overrides/Modulemd.py b/bindings/python/gi/overrides/Modulemd.py
index 9e6d1c212e663c4d1392ce9c8d4ea66abbc9f7ac..23d5218cbe37c9d08f9d88debb541f6467b68404 100644
--- a/bindings/python/gi/overrides/Modulemd.py
+++ b/bindings/python/gi/overrides/Modulemd.py
@@ -26,10 +26,11 @@ Modulemd = get_introspection_module("Modulemd")
__all__ = []
class ModulemdUtil(object):
+ @staticmethod
def strip_gtype(method):
@functools.wraps(method)
def wrapped(*args, **kwargs):
ret = method(*args, **kwargs)
if len(ret) == 2:
--
2.29.2

View File

@ -1,154 +0,0 @@
From 8606b0c341a9a3b13add67e7b42c57ef36ad3fec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Tue, 12 Jan 2021 09:55:39 +0100
Subject: [PATCH 2/2] When adding obsoletes ensure index has stream mdversion
at least 2
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
modulemd/modulemd-module-index.c | 13 +++++
modulemd/tests/test-modulemd-merger.c | 83 +++++++++++++++++++++++++++
2 files changed, 96 insertions(+)
diff --git a/modulemd/modulemd-module-index.c b/modulemd/modulemd-module-index.c
index 82ae1e168d2443c7c54bb94d39b233ad62ef887b..dd5a777e0f30deec1c42e6e3eaaab661ba97ff92 100644
--- a/modulemd/modulemd-module-index.c
+++ b/modulemd/modulemd-module-index.c
@@ -1288,15 +1288,28 @@ modulemd_module_index_add_obsoletes (ModulemdModuleIndex *self,
GError **error)
{
g_autoptr (GError) nested_error = NULL;
g_return_val_if_fail (MODULEMD_IS_MODULE_INDEX (self), FALSE);
+ g_return_val_if_fail (MODULEMD_IS_OBSOLETES (obsoletes), FALSE);
modulemd_module_add_obsoletes (
get_or_create_module (self,
modulemd_obsoletes_get_module_name (obsoletes)),
obsoletes);
+
+ /* Obsoletes need at least MD_MODULESTREAM_VERSION_TWO */
+ if (self->stream_mdversion < MD_MODULESTREAM_VERSION_TWO)
+ {
+ if (!modulemd_module_index_upgrade_streams (
+ self, MD_MODULESTREAM_VERSION_TWO, &nested_error))
+ {
+ g_propagate_error (error, g_steal_pointer (&nested_error));
+ return FALSE;
+ }
+ }
+
return TRUE;
}
GHashTable *
diff --git a/modulemd/tests/test-modulemd-merger.c b/modulemd/tests/test-modulemd-merger.c
index 34b14e75ef60e037d9cef371e0ae033874e62a70..cd5379838832ec3c9d487e96b81b2259d97649fa 100644
--- a/modulemd/tests/test-modulemd-merger.c
+++ b/modulemd/tests/test-modulemd-merger.c
@@ -774,10 +774,90 @@ merger_test_obsoletes_incompatible (void)
GPtrArray *obsoletes = NULL;
obsoletes = modulemd_module_get_obsoletes (module);
g_assert_cmpint (obsoletes->len, ==, 1);
}
+static void
+merger_test_obsoletes_lone_obsolete (void)
+{
+ // clang-format off
+ g_autofree gchar *obsolete_str = g_strdup(
+"---\n"
+"document: modulemd-obsoletes\n"
+"version: 1\n"
+"data:\n"
+" modified: 2020-05-01T00:00Z\n"
+" module: nodejs\n"
+" context: 6c81f848\n"
+" stream: 5\n"
+" message: \"obsoleting obsoletes\"\n"
+" obsoleted_by:\n"
+" module: nodejs\n"
+" stream: 10\n"
+"...\n");
+ // clang-format on
+
+ // clang-format off
+ g_autofree gchar *stream_str = g_strdup(
+"---\n"
+"document: modulemd\n"
+"version: 2\n"
+"data:\n"
+" name: nodejs\n"
+" stream: 5\n"
+" version: 99\n"
+" context: 6c81f848\n"
+" arch: x86_64\n"
+" summary: Javascript runtime\n"
+" description: >-\n"
+" Node.js is a platform built on Chrome''s JavaScript runtime.\n"
+" license:\n"
+" module:\n"
+" - MIT\n"
+"...\n");
+ // clang-format on
+
+ g_autoptr (GPtrArray) failures = NULL;
+ g_autoptr (GError) error = NULL;
+ g_autoptr (ModulemdModuleIndex) obsolete_idx = modulemd_module_index_new ();
+ g_autoptr (ModulemdModuleIndex) stream_idx = modulemd_module_index_new ();
+ g_autoptr (ModulemdModuleIndex) merged_idx = NULL;
+ g_autoptr (ModulemdModuleIndexMerger) merger =
+ modulemd_module_index_merger_new ();
+ gboolean ret;
+
+ ret = modulemd_module_index_update_from_string (
+ obsolete_idx, obsolete_str, TRUE, &failures, &error);
+ modulemd_subdocument_info_debug_dump_failures (failures);
+ g_assert_no_error (error);
+ g_assert_true (ret);
+
+ ret = modulemd_module_index_update_from_string (
+ stream_idx, stream_str, TRUE, &failures, &error);
+ modulemd_subdocument_info_debug_dump_failures (failures);
+ g_assert_no_error (error);
+ g_assert_true (ret);
+
+ modulemd_module_index_merger_associate_index (merger, obsolete_idx, 0);
+ modulemd_module_index_merger_associate_index (merger, stream_idx, 0);
+ merged_idx = modulemd_module_index_merger_resolve (merger, &error);
+
+ g_assert_nonnull (merged_idx);
+ g_assert_no_error (error);
+
+ g_autoptr (ModulemdModuleStream) stream = NULL;
+ stream = g_object_ref (modulemd_module_get_stream_by_NSVCA (
+ modulemd_module_index_get_module (merged_idx, "nodejs"),
+ "5",
+ 99,
+ NULL,
+ NULL,
+ &error));
+ g_assert_nonnull (stream);
+ g_assert_no_error (error);
+}
+
int
main (int argc, char *argv[])
{
setlocale (LC_ALL, "");
@@ -819,7 +899,10 @@ main (int argc, char *argv[])
merger_test_obsoletes_priority);
g_test_add_func ("/modulemd/module/index/merger/obsoletes/incompatibility",
merger_test_obsoletes_incompatible);
+ g_test_add_func ("/modulemd/module/index/merger/obsoletes/lone_obsolete",
+ merger_test_obsoletes_lone_obsolete);
+
return g_test_run ();
}
--
2.29.2

View File

@ -13,8 +13,8 @@
%endif
Name: %{upstream_name}%{?v2_suffix}
Version: 2.11.2
Release: 2%{?dist}
Version: 2.12.0
Release: 1%{?dist}
Summary: Module metadata manipulation library
License: MIT
@ -42,8 +42,6 @@ BuildRequires: help2man
# Patches
Patch0001: 0001-Add-missing-staticmethod-for-python2.patch
Patch0002: 0002-When-adding-obsoletes-ensure-index-has-stream-mdvers.patch
%description
@ -165,6 +163,9 @@ mv %{buildroot}%{_mandir}/man1/modulemd-validator.1 \
%changelog
* Thu Jan 14 2021 Stephen Gallagher <sgallagh@redhat.com> - 2.12.0-1
- Add support for 'buildorder' to Packager documents
* Tue Jan 12 2021 Stephen Gallagher <sgallagh@redhat.com> - 2.11.2-2
- Fix issue with ModuleIndex when input contains only Obsoletes documents
- Fix import issue when built with Python 2 support

View File

@ -1 +1 @@
SHA512 (modulemd-2.11.2.tar.xz) = 1430273a48abea390890871f796f3fe329149d7e404e4508d0486bbebb9cd06edb1136fa639a73ef85dd12002e470c868de05a8d2b816ed8fb5c7ed6be31e785
SHA512 (modulemd-2.12.0.tar.xz) = 8dda8bf92a0e1ad4578bf15099443bc1ef42b4a0609a635b2e7a885c878994ce64c1670ffb75ab566ac6ce08f87e0b2807149d08fe3b701abd0ef4a4a9569f88