diff --git a/SOURCES/0003-Do-not-skip-type-mandatory-in-xml-output-and-test-it-RhBu1771224.patch b/SOURCES/0003-Do-not-skip-type-mandatory-in-xml-output-and-test-it-RhBu1771224.patch new file mode 100644 index 0000000..5b74ab4 --- /dev/null +++ b/SOURCES/0003-Do-not-skip-type-mandatory-in-xml-output-and-test-it-RhBu1771224.patch @@ -0,0 +1,64 @@ +From be21c727509e252859d7850f7d7ec06c51ba15b3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= +Date: Mon, 6 Jan 2020 12:08:00 +0100 +Subject: [PATCH] Do not skip type=mandatory in xml output and test it + (RhBug:1771224) + +The mandatory type is used when no other configuration and no other +type is specified but since this behavior can be overridden with passed +configuration it doesn't make sense to always skip outputting the type +mandatory. +The user can specify for example optional type as default and then +the knowledge that some specific were mandatory would be +lost. + +https://bugzilla.redhat.com/show_bug.cgi?id=1771224 +--- + libcomps/src/comps_docpackage.c | 5 +++-- + libcomps/src/python/tests/__test.py | 10 +++++++++- + 2 files changed, 12 insertions(+), 3 deletions(-) + +diff --git a/libcomps/src/comps_docpackage.c b/libcomps/src/comps_docpackage.c +index 25d8564..f2d6bae 100644 +--- a/libcomps/src/comps_docpackage.c ++++ b/libcomps/src/comps_docpackage.c +@@ -164,8 +164,9 @@ signed char comps_docpackage_xml(COMPS_DocGroupPackage *pkg, + str = "conditional"; + else + str = "default"; +- if (pkg->type != COMPS_PACKAGE_MANDATORY) +- ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST str); ++ ++ ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST str); ++ + if (pkg->requires) { + str = comps_object_tostr((COMPS_Object*)pkg->requires); + ret = xmlTextWriterWriteAttribute(writer, (xmlChar*) "requires", +diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py +index c7529f3..9cb957a 100644 +--- a/libcomps/src/python/tests/__test.py ++++ b/libcomps/src/python/tests/__test.py +@@ -620,6 +620,14 @@ def test_hash(self): + self.assertTrue(hash(pkg2) != hash(pkg3)) + self.assertTrue(len(set([pkg1,pkg2,pkg3])) == 2) + ++ def test_mandatory_in_xml_out(self): ++ self.comps = libcomps.Comps() ++ self.comps.groups.append(libcomps.Group("g1", "group1", "group desc", 0, 0, 0, "en")) ++ self.comps.groups[0].packages.append(libcomps.Package("kernel", libcomps.PACKAGE_TYPE_MANDATORY)) ++ ++ out = self.comps.xml_str() ++ self.assertTrue("kernel" in out) ++ + #@unittest.skip("skip") + class DictTest(unittest.TestCase): + def test_dict(self): +@@ -998,7 +1006,7 @@ def test_xml_options(self): + self.assertEqual(len(comps2.groups), 0) + self.assertEqual(len(comps2.categories), 0) + self.assertEqual(len(comps2.environments), 0) +- ++ + s = comps.toxml_str(xml_options={"empty_groups": True, + "empty_categories": True, + "empty_environments": True}) diff --git a/SPECS/libcomps.spec b/SPECS/libcomps.spec index f2d6496..856a014 100644 --- a/SPECS/libcomps.spec +++ b/SPECS/libcomps.spec @@ -14,7 +14,7 @@ Name: libcomps Version: 0.1.11 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Comps XML file manipulation library License: GPLv2+ @@ -22,6 +22,7 @@ URL: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{name}-%{version}/%{name}-%{version}.tar.gz Patch0: 0001-Fix-order-of-asserts-in-unit-test-RhBug1713220.patch Patch1: 0002-Empty-dict-created-by-_by_lang-in-python-api-causes-segfault.patch +Patch2: 0003-Do-not-skip-type-mandatory-in-xml-output-and-test-it-RhBu1771224.patch BuildRequires: gcc-c++ BuildRequires: cmake @@ -191,6 +192,9 @@ popd %endif %changelog +* Mon Jan 13 2020 Ales Matej - 0.1.11-4 +- Do not skip type=mandatory in xml output (RhBug:1771224) + * Wed Nov 13 2019 Ales Matej - 0.1.11-3 - Fix segfault caused by empty dict created by *_by_lang in python api (RhBug:1757959)