diff --git a/SOURCES/0001-Dont-print-empty-requires.patch b/SOURCES/0001-Dont-print-empty-requires.patch new file mode 100644 index 0000000..acdd2cd --- /dev/null +++ b/SOURCES/0001-Dont-print-empty-requires.patch @@ -0,0 +1,46 @@ +From 7c999e57303d9b0afffde7354742988388fade3f Mon Sep 17 00:00:00 2001 +From: Aleš Matěj +Date: Thu, 15 Apr 2021 09:35:06 +0200 +Subject: [PATCH] Don't print empty requires + +The function `comps_object_tostr` used to get the string returns either +a valid value or if there is none it returns allocated "0" char. + +Closes: https://github.com/rpm-software-management/libcomps/issues/23 +--- + libcomps/src/comps_docpackage.c | 5 +++-- + libcomps/src/python/tests/__test.py | 2 +- + 2 files changed, 4 insertions(+), 3 deletions(-) + +diff --git a/libcomps/src/comps_docpackage.c b/libcomps/src/comps_docpackage.c +index 07cc30a..331036e 100644 +--- a/libcomps/src/comps_docpackage.c ++++ b/libcomps/src/comps_docpackage.c +@@ -169,8 +169,9 @@ signed char comps_docpackage_xml(COMPS_DocGroupPackage *pkg, + + if (pkg->requires) { + str = comps_object_tostr((COMPS_Object*)pkg->requires); +- ret = xmlTextWriterWriteAttribute(writer, (xmlChar*) "requires", +- BAD_CAST str); ++ if (str && *str) { ++ ret = xmlTextWriterWriteAttribute(writer, (xmlChar*) "requires", BAD_CAST str); ++ } + free(str); + } + COMPS_XMLRET_CHECK() +diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py +index 2b321e3..35a41f7 100644 +--- a/libcomps/src/python/tests/__test.py ++++ b/libcomps/src/python/tests/__test.py +@@ -626,7 +626,7 @@ class PackageTest(unittest.TestCase): + self.comps.groups[0].packages.append(libcomps.Package("kernel", libcomps.PACKAGE_TYPE_MANDATORY)) + + out = self.comps.xml_str() +- self.assertTrue("kernel" in out) ++ self.assertTrue("kernel" in out) + + #@unittest.skip("skip") + class DictTest(unittest.TestCase): +-- +libgit2 1.0.1 + diff --git a/SPECS/libcomps.spec b/SPECS/libcomps.spec index 38ca348..281f2c3 100644 --- a/SPECS/libcomps.spec +++ b/SPECS/libcomps.spec @@ -2,12 +2,13 @@ Name: libcomps Version: 0.1.16 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Comps XML file manipulation library License: GPLv2+ URL: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz +Patch1: 0001-Dont-print-empty-requires.patch BuildRequires: gcc-c++ BuildRequires: cmake @@ -114,6 +115,9 @@ popd %{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info %changelog +* Fri May 21 2021 Pavla Kratochvilova - 0.1.16-2 +- Backport patch: Don't print empty requires + * Fri Apr 30 2021 Pavla Kratochvilova - 0.1.16-1 - Update to 0.1.16 - Make inline function __comps_objmrtree_all also static (RhBug:1793424)