From ac437b4983e2023a2a4ba204e9d9ac0e18918d4c Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Jan 11 2019 15:58:24 +0000 Subject: Fix issue reading modified value for defaults from YAML streams Signed-off-by: Stephen Gallagher --- diff --git a/0001-Include-modified-value-when-copying-Defaults-objects.patch b/0001-Include-modified-value-when-copying-Defaults-objects.patch new file mode 100644 index 0000000..ad3ee96 --- /dev/null +++ b/0001-Include-modified-value-when-copying-Defaults-objects.patch @@ -0,0 +1,106 @@ +From f66d185dd5c2c1750b3626c2e0bdfeab63e427b6 Mon Sep 17 00:00:00 2001 +From: Stephen Gallagher +Date: Fri, 11 Jan 2019 08:36:11 -0500 +Subject: [PATCH] Include modified value when copying Defaults objects + +The symptom of this was that any defaults object read from a YAML +stream would end up stored in the ModuleIndex with the a zero for +the modified value. + +Signed-off-by: Stephen Gallagher +--- + modulemd/v2/modulemd-defaults.c | 7 ++++-- + modulemd/v2/tests/ModulemdTests/defaults.py | 25 +++++++++++++++++++++ + 2 files changed, 30 insertions(+), 2 deletions(-) + +diff --git a/modulemd/v2/modulemd-defaults.c b/modulemd/v2/modulemd-defaults.c +index 9e5c31b499704ae7a8543c91b9ea3bbf0dbf981d..c577d4a0c3db45319c8e0582b4cc07f3943836fa 100644 +--- a/modulemd/v2/modulemd-defaults.c ++++ b/modulemd/v2/modulemd-defaults.c +@@ -91,14 +91,18 @@ modulemd_defaults_copy (ModulemdDefaults *self) + + + static ModulemdDefaults * + modulemd_defaults_default_copy (ModulemdDefaults *self) + { ++ g_autoptr (ModulemdDefaults) copy = NULL; + g_return_val_if_fail (MODULEMD_IS_DEFAULTS (self), NULL); + +- return modulemd_defaults_new (modulemd_defaults_get_mdversion (self), ++ copy = modulemd_defaults_new (modulemd_defaults_get_mdversion (self), + modulemd_defaults_get_module_name (self)); ++ modulemd_defaults_set_modified (copy, modulemd_defaults_get_modified (self)); ++ ++ return g_steal_pointer (©); + } + + + gboolean + modulemd_defaults_validate (ModulemdDefaults *self, GError **error) +@@ -214,11 +218,10 @@ modulemd_defaults_set_modified (ModulemdDefaults *self, guint64 modified) + { + g_return_if_fail (MODULEMD_IS_DEFAULTS (self)); + + ModulemdDefaultsPrivate *priv = + modulemd_defaults_get_instance_private (self); +- + priv->modified = modified; + } + + + guint64 +diff --git a/modulemd/v2/tests/ModulemdTests/defaults.py b/modulemd/v2/tests/ModulemdTests/defaults.py +index ddac23bbed573b3725feb8cb0090fb878a1f4f22..9a783d25617fc53f59448bc32a68c6e2755dd034 100644 +--- a/modulemd/v2/tests/ModulemdTests/defaults.py ++++ b/modulemd/v2/tests/ModulemdTests/defaults.py +@@ -10,11 +10,13 @@ + # This program is free software. + # For more information on the license, see COPYING. + # For more information on free software, see + # . + ++import os + import sys ++ + try: + import unittest + import gi + gi.require_version('Modulemd', '2.0') + from gi.repository import Modulemd +@@ -92,10 +94,33 @@ class TestDefaults(TestBase): + + # Ensure we cannot set the module_name + with self.expect_signal(): + defs.props.module_name = None + ++ def test_modified(self): ++ defs = Modulemd.Defaults.new( ++ Modulemd.DefaultsVersionEnum.LATEST, 'foo') ++ self.assertIsNotNone(defs) ++ ++ self.assertEqual(defs.get_modified(), 0) ++ ++ defs.set_modified(201901110830) ++ ++ self.assertEqual(defs.get_modified(), 201901110830) ++ ++ # Load a defaults object into an Index ++ index = Modulemd.ModuleIndex.new() ++ index.update_from_file("%s/mod-defaults/spec.v1.yaml" % ( ++ os.getenv('MESON_SOURCE_ROOT')), True) ++ module_names = index.get_module_names() ++ self.assertEqual(len(module_names), 1) ++ ++ defs = index.get_module(index.get_module_names()[0]).get_defaults() ++ self.assertIsNotNone(defs) ++ ++ self.assertEqual(defs.get_modified(), 201812071200) ++ + def test_validate(self): + defs = Modulemd.Defaults.new( + Modulemd.DefaultsVersionEnum.LATEST, 'foo') + assert defs + +-- +2.20.1 + diff --git a/0001-Properly-write-out-the-ref-for-module-components.patch b/0001-Properly-write-out-the-ref-for-module-components.patch deleted file mode 100644 index e9723cf..0000000 --- a/0001-Properly-write-out-the-ref-for-module-components.patch +++ /dev/null @@ -1,116 +0,0 @@ -From b873aca640964389935d88a90a657abba89421e3 Mon Sep 17 00:00:00 2001 -From: Stephen Gallagher -Date: Thu, 6 Sep 2018 11:17:41 -0400 -Subject: [PATCH 1/2] Properly write out the ref for module components - -Fixes: https://github.com/fedora-modularity/libmodulemd/issues/85 - -Signed-off-by: Stephen Gallagher ---- - modulemd/v1/modulemd-yaml-emitter-modulemd.c | 2 +- - modulemd/v1/tests/test-modulemd-python.py | 50 +++++++++++++++++++ - modulemd/v1/tests/test-modulemd-translation.c | 2 +- - 3 files changed, 52 insertions(+), 2 deletions(-) - -diff --git a/modulemd/v1/modulemd-yaml-emitter-modulemd.c b/modulemd/v1/modulemd-yaml-emitter-modulemd.c -index 87093813e28f5dd42ab014265874ce2148372c8a..7b0fbfafe1cdb4651f2f9b7147f9c082eb76ee2a 100644 ---- a/modulemd/v1/modulemd-yaml-emitter-modulemd.c -+++ b/modulemd/v1/modulemd-yaml-emitter-modulemd.c -@@ -1353,11 +1353,11 @@ _emit_modulemd_module_components (yaml_emitter_t *emitter, - MMD_YAML_EMIT_STR_STR_DICT ( - &event, name, value, YAML_PLAIN_SCALAR_STYLE); - } - - /* Ref */ -- value = modulemd_component_module_dup_repository (module_component); -+ value = modulemd_component_module_dup_ref (module_component); - if (value) - { - name = g_strdup ("ref"); - MMD_YAML_EMIT_STR_STR_DICT ( - &event, name, value, YAML_PLAIN_SCALAR_STYLE); -diff --git a/modulemd/v1/tests/test-modulemd-python.py b/modulemd/v1/tests/test-modulemd-python.py -index 07823213de9c7f16e16719efe0eccf155117cfa5..596665a6df2e367d0817c08b0bfc651cecd14e6a 100755 ---- a/modulemd/v1/tests/test-modulemd-python.py -+++ b/modulemd/v1/tests/test-modulemd-python.py -@@ -214,10 +214,60 @@ class TestIssues(unittest.TestCase): - yaml_output = mmd_translation.dumps() - except GLib.GError as err: - # A proper exception is expected here - pass - -+ def test_issue85(self): -+ """ -+ Component module refs are lost when dumping to YAML -+ """ -+ mmd = Modulemd.Module().new_from_string(""" -+document: modulemd -+version: 1 -+data: -+ summary: A test module in all its beautiful beauty. -+ description: This module demonstrates how to write simple modulemd files And can be used for testing the build and release pipeline. -+ license: -+ module: [ MIT ] -+ dependencies: -+ buildrequires: -+ platform: el8 -+ requires: -+ platform: el8 -+ references: -+ community: https://fedoraproject.org/wiki/Modularity -+ documentation: https://fedoraproject.org/wiki/Fedora_Packaging_Guidelines_for_Modules -+ tracker: https://taiga.fedorainfracloud.org/project/modularity -+ profiles: -+ default: -+ rpms: -+ - acl -+ api: -+ rpms: -+ - acl -+ components: -+ rpms: -+ acl: -+ rationale: needed -+ ref: rhel-8.0 -+ modules: -+ testmodule: -+ ref: private-x -+ rationale: Testing module inclusion. -+ buildorder: 10 -+""") -+ assert mmd.get_module_components( -+ )['testmodule'].peek_ref() == 'private-x' -+ -+ mmd2 = Modulemd.Module.copy(mmd) -+ assert mmd2.get_module_components( -+ )['testmodule'].peek_ref() == 'private-x' -+ -+ mmd3 = Modulemd.Module.new_from_string(mmd.dumps()) -+ assert mmd3.get_module_components( -+ )['testmodule'].peek_ref() == 'private-x' -+ - - class TestIntent(unittest.TestCase): - - def test_basic(self): - intent = Modulemd.Intent.new("intent_name") -diff --git a/modulemd/v1/tests/test-modulemd-translation.c b/modulemd/v1/tests/test-modulemd-translation.c -index a85ba5131db562aa9be3255fae3db13e9ee66508..dfa07f48d5ada811a5c82f14e7bcf52c7b258b94 100644 ---- a/modulemd/v1/tests/test-modulemd-translation.c -+++ b/modulemd/v1/tests/test-modulemd-translation.c -@@ -350,11 +350,11 @@ modulemd_translation_test_index (TranslationFixture *fixture, - "demonstrates arches and multilib.\n arches: [i686, x86_64]\n " - " multilib: [x86_64]\n xyz:\n rationale: xyz is a bundled " - "dependency of xxx.\n buildorder: 10\n modules:\n " - "includedmodule:\n rationale: Included in the stack, just " - "because.\n repository: https://pagure.io/includedmodule.git\n " -- " ref: https://pagure.io/includedmodule.git\n buildorder: 100\n " -+ " ref: somecoolbranchname\n buildorder: 100\n " - "artifacts:\n rpms:\n - bar-0:1.23-1.module_deadbeef.x86_64\n - " - "bar-devel-0:1.23-1.module_deadbeef.x86_64\n - " - "bar-extras-0:1.23-1.module_deadbeef.x86_64\n - " - "baz-0:42-42.module_deadbeef.x86_64\n - " - "xxx-0:1-1.module_deadbeef.i686\n - xxx-0:1-1.module_deadbeef.x86_64\n " --- -2.19.0.rc0 - diff --git a/0002-Use-decimal-version-in-NSVC.patch b/0002-Use-decimal-version-in-NSVC.patch deleted file mode 100644 index 26f1541..0000000 --- a/0002-Use-decimal-version-in-NSVC.patch +++ /dev/null @@ -1,35 +0,0 @@ -From e69860136a11441a9f952ac97da1040a3219b4d6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= -Date: Wed, 5 Sep 2018 12:20:36 +0200 -Subject: [PATCH 2/2] Use decimal version in NSVC - -Fixes: #82 ---- - modulemd/v1/modulemd-modulestream.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/modulemd/v1/modulemd-modulestream.c b/modulemd/v1/modulemd-modulestream.c -index 1ee6e1cffc5cecd19439ca47afc4425e9808aaa4..58317c17564301f85984f7608356002afeb29921 100644 ---- a/modulemd/v1/modulemd-modulestream.c -+++ b/modulemd/v1/modulemd-modulestream.c -@@ -1796,15 +1796,15 @@ modulemd_modulestream_get_nsvc (ModulemdModuleStream *self) - } - - if (context) - { - nsvc = g_strdup_printf ( -- "%s:%s:%" PRIx64 ":%s", name, stream, version, context); -+ "%s:%s:%" PRIu64 ":%s", name, stream, version, context); - } - else - { -- nsvc = g_strdup_printf ("%s:%s:%" PRIx64, name, stream, version); -+ nsvc = g_strdup_printf ("%s:%s:%" PRIu64, name, stream, version); - } - - return nsvc; - } - --- -2.19.0.rc0 - diff --git a/libmodulemd.spec b/libmodulemd.spec index 93bdfe0..a4dc681 100644 --- a/libmodulemd.spec +++ b/libmodulemd.spec @@ -3,7 +3,7 @@ Name: libmodulemd Version: %{libmodulemd_version} -Release: 1%{?dist} +Release: 2%{?dist} Summary: Module metadata manipulation library License: MIT @@ -28,7 +28,7 @@ Obsoletes: python2-modulemd < 1.3.4 Obsoletes: python3-modulemd < 1.3.4 # Patches - +Patch0001: 0001-Include-modified-value-when-copying-Defaults-objects.patch %description C Library for manipulating module metadata files. @@ -171,6 +171,9 @@ ln -s libmodulemd.so.%{libmodulemd_v1_version} \ %{_datadir}/gtk-doc/html/modulemd-1.0/ %changelog +* Fri Jan 11 2019 Stephen Gallagher - 2.0.0-2 +- Fix issue reading modified value for defaults from YAML streams + * Thu Dec 13 2018 Stephen Gallagher - 2.0.0-1 - Update to 2.0.0 final - Assorted fixes for validation