import libcomps-0.1.16-2.el8

This commit is contained in:
CentOS Sources 2021-10-06 11:17:25 -04:00 committed by Stepan Oksanichenko
parent e86dbb969b
commit a62914f41c
8 changed files with 68 additions and 410 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/libcomps-0.1.11.tar.gz
SOURCES/libcomps-0.1.16.tar.gz

View File

@ -1 +1 @@
ad66eb33f10da57565fbbf44e30e4d418f0a0a4d SOURCES/libcomps-0.1.11.tar.gz
2837109aca4e610c57e35e43c7cbb0e296cfdaa9 SOURCES/libcomps-0.1.16.tar.gz

View File

@ -0,0 +1,46 @@
From 7c999e57303d9b0afffde7354742988388fade3f Mon Sep 17 00:00:00 2001
From: Aleš Matěj <amatej@redhat.com>
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("<packagereq type=\"mandatory\" requires=\"\">kernel</packagereq>" in out)
+ self.assertTrue("<packagereq type=\"mandatory\">kernel</packagereq>" in out)
#@unittest.skip("skip")
class DictTest(unittest.TestCase):
--
libgit2 1.0.1

View File

@ -1,26 +0,0 @@
From 849ae4a7c7abe72baaeb22214be3e04e4e43eb81 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Wed, 22 May 2019 13:21:19 +0200
Subject: [PATCH] Fix: order of asserts() in unit test (RhBug:1713220)
---
libcomps/src/python/tests/__test.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py
index 40c2e83..c9b4dd4 100644
--- a/libcomps/src/python/tests/__test.py
+++ b/libcomps/src/python/tests/__test.py
@@ -891,8 +891,8 @@ class COMPSTest(unittest.TestCase):
gid1 = libcomps.GroupId("gid1")
gid2 = libcomps.GroupId("gid2", default=False)
gid3 = libcomps.GroupId("gid3", default=True)
- self.assertRaises(TypeError, gid1.__eq__, 1)
self.assertTrue(gid1 != None)
+ self.assertRaises(TypeError, gid1.__eq__, 1)
self.assertTrue(gid1 == gid1)
self.assertTrue(gid1 != "gid2")
self.assertTrue(gid1 != gid2)
--
libgit2 0.28.2

View File

@ -1,161 +0,0 @@
From 257df5670310775a9c279f5f34e3d088966759b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 7 Oct 2019 12:14:22 +0200
Subject: [PATCH 1/3] Update couple of tests
- list indices cannot by of type float
- remove unnecessary print
- update print with parenthesis which are now required in python
---
libcomps/src/python/tests/__test.py | 2 +-
libcomps/src/python/tests/test_libcomps.py | 1 -
libcomps/src/python/tests/test_merge_comps.py | 4 ++--
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py
index c9b4dd4..c7529f3 100644
--- a/libcomps/src/python/tests/__test.py
+++ b/libcomps/src/python/tests/__test.py
@@ -225,7 +225,7 @@ def test_union3(self):
def test_hash(self):
s = set()
for x in range(6):
- s.add(self.obj_constructor(**self.obj_data[x/2]))
+ s.add(self.obj_constructor(**self.obj_data[int(x/2)]))
self.assertTrue(len(s) == 3)
self.assertTrue(hash(self.obj_constructor(**self.obj_data[0])) ==\
hash(self.obj_constructor(**self.obj_data[0])))
diff --git a/libcomps/src/python/tests/test_libcomps.py b/libcomps/src/python/tests/test_libcomps.py
index 2a18984..71311ef 100755
--- a/libcomps/src/python/tests/test_libcomps.py
+++ b/libcomps/src/python/tests/test_libcomps.py
@@ -19,7 +19,6 @@
class TestLibcomps(unittest.TestCase):
def setUp(self):
- print (dir(libcomps))
self.comps = libcomps.Comps()
self.comps.fromxml_f("comps/comps-f21.xml")
self.tmp_dir = tempfile.mkdtemp()
diff --git a/libcomps/src/python/tests/test_merge_comps.py b/libcomps/src/python/tests/test_merge_comps.py
index beef2cf..73e743f 100755
--- a/libcomps/src/python/tests/test_merge_comps.py
+++ b/libcomps/src/python/tests/test_merge_comps.py
@@ -7,10 +7,10 @@
try:
import _libpycomps as libcomps
- print "local tests"
+ print("local tests")
except ImportError:
import libcomps
- print "global tests"
+ print("global tests")
class TestMergeComps(unittest.TestCase):
From 1b7add27595b12b9f47e54c3e5f1bda2177da346 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 7 Oct 2019 12:50:21 +0200
Subject: [PATCH 2/3] Fix segfault when converting empty dict to string
(RhBug:1757959)
Handle all elements in single loop consistently, instead of handling
last element separately which caused problems with empty dictionary.
https://bugzilla.redhat.com/show_bug.cgi?id=1757959
---
libcomps/src/python/src/pycomps_dict.c | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/libcomps/src/python/src/pycomps_dict.c b/libcomps/src/python/src/pycomps_dict.c
index 1b42909..4a20cf7 100644
--- a/libcomps/src/python/src/pycomps_dict.c
+++ b/libcomps/src/python/src/pycomps_dict.c
@@ -78,7 +78,7 @@ PyObject* PyCOMPSDict_str(PyObject *self) {
pairlist = comps_objdict_pairs(((PyCOMPS_Dict*)self)->dict);
char *tmpstr;
- for (it = pairlist->first; it != pairlist->last; it = it->next) {
+ for (it = pairlist->first; it != NULL; it = it->next) {
tmp = ret;
tmpkey = __pycomps_lang_decode(((COMPS_ObjRTreePair*)it->data)->key);
if (!tmpkey) {
@@ -99,24 +99,6 @@ PyObject* PyCOMPSDict_str(PyObject *self) {
Py_XDECREF(tmpkey);
Py_XDECREF(tmpval);
}
- tmp = ret;
- tmpkey = __pycomps_lang_decode(((COMPS_RTreePair*)it->data)->key);
- if (!tmpkey) {
- goto out;
- }
- tmpstr = comps_object_tostr(((COMPS_ObjRTreePair*)it->data)->data);
- tmpval = __pycomps_lang_decode(tmpstr);
- free(tmpstr);
- if (!tmpval) {
- //PyErr_SetString(PyExc_TypeError, "val convert error");
- goto out;
- }
- tmp2 = PyUnicode_FromFormat("%U = '%U'", tmpkey, tmpval);
- ret = PyUnicode_Concat(ret, tmp2);
- Py_XDECREF(tmp);
- Py_XDECREF(tmp2);
- Py_XDECREF(tmpkey);
- Py_XDECREF(tmpval);
tmp = ret;
tmp2 = PyUnicode_FromString("}");
From 6b4bffb541e70a1715e91ba06de8172b57cd26f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Mon, 7 Oct 2019 12:52:59 +0200
Subject: [PATCH 3/3] Add test for python API with empty *_by_lang dictionary
input
---
.../python/tests/comps/comps_empty_by_lang_tags.xml | 12 ++++++++++++
libcomps/src/python/tests/test_libcomps.py | 10 ++++++++++
2 files changed, 22 insertions(+)
create mode 100644 libcomps/src/python/tests/comps/comps_empty_by_lang_tags.xml
diff --git a/libcomps/src/python/tests/comps/comps_empty_by_lang_tags.xml b/libcomps/src/python/tests/comps/comps_empty_by_lang_tags.xml
new file mode 100644
index 0000000..2f40a86
--- /dev/null
+++ b/libcomps/src/python/tests/comps/comps_empty_by_lang_tags.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
+<comps>
+ <group>
+ <id>birds</id>
+ <description></description>
+ </group>
+ <category>
+ <id>all</id>
+ <name>all</name>
+ </category>
+</comps>
diff --git a/libcomps/src/python/tests/test_libcomps.py b/libcomps/src/python/tests/test_libcomps.py
index 71311ef..64c2b59 100755
--- a/libcomps/src/python/tests/test_libcomps.py
+++ b/libcomps/src/python/tests/test_libcomps.py
@@ -153,6 +153,16 @@ def test_duplicate_groups(self):
#print self.comps.xml_str()
self.comps.fromxml_str(self.comps.xml_str())
+ def test_empty_by_lang_tags(self):
+ self.comps = libcomps.Comps()
+ self.comps.fromxml_f("comps/comps_empty_by_lang_tags.xml")
+ for group in self.comps.groups:
+ self.assertEqual("{}", str(group.name_by_lang))
+ self.assertEqual("{}", str(group.desc_by_lang))
+
+ for category in self.comps.categories:
+ self.assertEqual("{}", str(category.name_by_lang))
+ self.assertEqual("{}", str(category.desc_by_lang))
if __name__ == "__main__":
unittest.main(testRunner = utest.MyRunner)

View File

@ -1,64 +0,0 @@
From be21c727509e252859d7850f7d7ec06c51ba15b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
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 <packagereq> 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("<packagereq type=\"mandatory\" requires=\"\">kernel</packagereq>" 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})

View File

@ -1,68 +0,0 @@
From 810efc113dc90a60689295ea99de61eee918c46f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
Date: Thu, 22 Oct 2020 13:23:25 +0200
Subject: [PATCH] Use already implemented clear for COMPS_HSList
(RhBug:1888343)
Instead of reimplementing clear for COMPS_HSList use comps_hslist_clear.
The crash was caused by dangling pointers first and last in the
COMPS_HSList (rt->subnodes) struct, function comps_hslist_clear clears
them out properly.
= changelog =
msg: Fix a crash when clearing COMPS_ObjRTree
type: bugfix
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1888343
---
libcomps/src/comps_objradix.c | 15 ++-------------
libcomps/src/python/tests/__test.py | 10 ++++++++++
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/libcomps/src/comps_objradix.c b/libcomps/src/comps_objradix.c
index 840592a..111ddbc 100644
--- a/libcomps/src/comps_objradix.c
+++ b/libcomps/src/comps_objradix.c
@@ -611,20 +611,9 @@ void comps_objrtree_unset(COMPS_ObjRTree * rt, const char * key) {
}
void comps_objrtree_clear(COMPS_ObjRTree * rt) {
- COMPS_HSListItem *it, *oldit;
if (rt==NULL) return;
- if (rt->subnodes == NULL) return;
- oldit = rt->subnodes->first;
- it = (oldit)?oldit->next:NULL;
- for (;it != NULL; it=it->next) {
- comps_object_destroy(oldit->data);
- free(oldit);
- oldit = it;
- }
- if (oldit) {
- comps_object_destroy(oldit->data);
- free(oldit);
- }
+ comps_hslist_clear(rt->subnodes);
+ rt->len = 0;
}
inline COMPS_HSList* __comps_objrtree_all(COMPS_ObjRTree * rt, char keyvalpair) {
diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py
index 9cb957a..2b321e3 100644
--- a/libcomps/src/python/tests/__test.py
+++ b/libcomps/src/python/tests/__test.py
@@ -986,6 +986,16 @@ def test_envs(self):
_f([x.name for x in env.option_ids], option_ids)
+ #@unittest.skip("")
+ def test_clear_for_COMPS_ObjRTree_such_as_group_or_category_namy_by_lang(self):
+ comps = libcomps.Comps()
+ ret = comps.fromxml_f("comps/f21-rawhide-comps.xml")
+
+ env = comps.categories[0].name_by_lang.clear()
+ env = comps.groups[0].name_by_lang.clear()
+
+ self.assertEqual(str(comps.categories[0].name_by_lang), u'{}')
+ self.assertEqual(str(comps.groups[0].name_by_lang), u'{}')
#@unittest.skip("")
def test_xml_options(self):

View File

@ -1,29 +1,14 @@
# Do not build python3 bindings for RHEL <= 7
%if 0%{?rhel} && 0%{?rhel} <= 7
%bcond_with python3
%else
%bcond_without python3
%endif
# Do not build python2 bindings for RHEL > 7 and Fedora > 29
%if 0%{?rhel} > 7 || 0%{?fedora} > 29
%bcond_with python2
%else
%bcond_without python2
%endif
%define __cmake_in_source_build 1
Name: libcomps
Version: 0.1.11
Release: 5%{?dist}
Version: 0.1.16
Release: 2%{?dist}
Summary: Comps XML file manipulation library
License: GPLv2+
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
Patch3: 0004-Use-already-implemented-clear-for-COMPS-HSList-RhBug-1888343.patch
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch1: 0001-Dont-print-empty-requires.patch
BuildRequires: gcc-c++
BuildRequires: cmake
@ -57,32 +42,12 @@ Documentation files for libcomps library.
Summary: Documentation files for python bindings libcomps library
Requires: %{name} = %{version}-%{release}
BuildArch: noarch
%if %{with python3}
BuildRequires: python3-sphinx
%endif
%if %{with python2}
%if 0%{?rhel} && 0%{?rhel} <= 7
BuildRequires: python-sphinx
%else
BuildRequires: python2-sphinx
%endif
%endif
%description -n python-%{name}-doc
Documentation files for python bindings libcomps library.
%if %{with python2}
%package -n python2-%{name}
Summary: Python 2 bindings for libcomps library
%{?python_provide:%python_provide python2-%{name}}
BuildRequires: python2-devel
Requires: %{name}%{?_isa} = %{version}-%{release}
%description -n python2-%{name}
Python 2 bindings for libcomps library.
%endif
%if %{with python3}
%package -n python3-%{name}
Summary: Python 3 bindings for libcomps library
BuildRequires: python3-devel
@ -92,73 +57,35 @@ Obsoletes: platform-python-%{name} < %{version}-%{release}
%description -n python3-%{name}
Python3 bindings for libcomps library.
%endif
%prep
%autosetup -n %{name}-%{name}-%{version} -p1
%autosetup -n %{name}-%{version} -p1
%if %{with python2}
mkdir build-py2
%endif
%if %{with python3}
mkdir build-py3
%endif
mkdir build-doc
%build
%if %{with python2}
pushd build-py2
%cmake ../libcomps/ -DPYTHON_DESIRED:STRING=2
%make_build
popd
%endif
%if %{with python3}
pushd build-py3
%cmake ../libcomps/ -DPYTHON_DESIRED:STRING=3
%cmake ../libcomps/
%make_build
popd
%endif
pushd build-doc
%if %{with python2}
%cmake ../libcomps/ -DPYTHON_DESIRED:STRING=2
%else
%if %{with python3}
%cmake ../libcomps/ -DPYTHON_DESIRED:STRING=3
%endif
%endif
%cmake ../libcomps/
make %{?_smp_mflags} docs
make %{?_smp_mflags} pydocs
popd
%install
%if %{with python2}
pushd build-py2
%make_install
popd
%endif
%if %{with python3}
pushd build-py3
%make_install
popd
%endif
%check
%if %{with python2}
pushd build-py2
make test
make pytest
popd
%endif
%if %{with python3}
pushd build-py3
make test
make pytest
popd
%endif
%if %{undefined ldconfig_scriptlets}
%post -p /sbin/ldconfig
@ -174,6 +101,7 @@ popd
%files devel
%{_libdir}/%{name}.so
%{_libdir}/pkgconfig/%{name}.pc
%{_includedir}/%{name}/
%files doc
@ -182,17 +110,20 @@ popd
%files -n python-%{name}-doc
%doc build-doc/src/python/docs/html
%if %{with python2}
%files -n python2-%{name}
%{python2_sitearch}/%{name}/
%endif
%if %{with python3}
%files -n python3-%{name}
%{python3_sitearch}/%{name}/
%endif
%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info
%changelog
* Fri May 21 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.1.16-2
- Backport patch: Don't print empty requires
* Fri Apr 30 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 0.1.16-1
- Update to 0.1.16
- Make inline function __comps_objmrtree_all also static (RhBug:1793424)
- Fix memory leaks and resource leaks
- Fix: Check result "comps_parse_parsed_init()"
* Thu Jan 14 2021 Nicola Sella <nsella@redhat.com> - 0.1.11-5
- Use already implemented clear for COMPS_HSList (RhBug:1888343)