Update to 0.14.1

This commit is contained in:
Pavla Kratochvilova 2019-05-24 10:52:23 +02:00
parent d141b953ab
commit a7a8466ff1
4 changed files with 10 additions and 239 deletions

1
.gitignore vendored
View File

@ -45,3 +45,4 @@
/createrepo_c-0.12.1.tar.gz
/createrepo_c-0.12.2.tar.gz
/createrepo_c-0.13.2.tar.gz
/createrepo_c-0.14.1.tar.gz

View File

@ -1,234 +0,0 @@
From 60ca8fe3db7d2032a815f19a8299a86ee63c5267 Mon Sep 17 00:00:00 2001
From: Aleš Matěj <amatej@redhat.com>
Date: Thu, 9 May 2019 08:48:32 +0200
Subject: [PATCH] Fix crash when dumping updateinfo and module is ommited (RhBug:1707981)
---
src/xml_dump_updateinfo.c | 23 +++++++++++++----------
tests/python/tests/test_updateinfo.py | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 192 insertions(+), 10 deletions(-)
diff --git a/src/xml_dump_updateinfo.c b/src/xml_dump_updateinfo.c
index d5ae96f..fafe686 100644
--- a/src/xml_dump_updateinfo.c
+++ b/src/xml_dump_updateinfo.c
@@ -68,16 +68,19 @@ cr_xml_dump_updatecollectionpackages(xmlNodePtr collection, GSList *packages)
void
cr_xml_dump_updatecollectionmodule(xmlNodePtr collection, cr_UpdateCollectionModule *module)
{
- xmlNodePtr xml_module;
- xml_module = xmlNewChild(collection, NULL, BAD_CAST "module", NULL);
-
- cr_xmlNewProp_c(xml_module, BAD_CAST "name", BAD_CAST module->name);
- cr_xmlNewProp_c(xml_module, BAD_CAST "stream", BAD_CAST module->stream);
- gchar buf[21]; //20 + '\0' is max number of chars of guint64: G_MAXUINT64 (= 18,446,744,073,709,551,615)
- snprintf(buf, 21, "%" G_GUINT64_FORMAT, module->version);
- cr_xmlNewProp_c(xml_module, BAD_CAST "version", BAD_CAST buf);
- cr_xmlNewProp_c(xml_module, BAD_CAST "context", BAD_CAST module->context);
- cr_xmlNewProp_c(xml_module, BAD_CAST "arch", BAD_CAST module->arch);
+ if (!module)
+ return;
+
+ xmlNodePtr xml_module;
+ xml_module = xmlNewChild(collection, NULL, BAD_CAST "module", NULL);
+
+ cr_xmlNewProp_c(xml_module, BAD_CAST "name", BAD_CAST module->name);
+ cr_xmlNewProp_c(xml_module, BAD_CAST "stream", BAD_CAST module->stream);
+ gchar buf[21]; //20 + '\0' is max number of chars of guint64: G_MAXUINT64 (= 18,446,744,073,709,551,615)
+ snprintf(buf, 21, "%" G_GUINT64_FORMAT, module->version);
+ cr_xmlNewProp_c(xml_module, BAD_CAST "version", BAD_CAST buf);
+ cr_xmlNewProp_c(xml_module, BAD_CAST "context", BAD_CAST module->context);
+ cr_xmlNewProp_c(xml_module, BAD_CAST "arch", BAD_CAST module->arch);
}
void
diff --git a/tests/python/tests/test_updateinfo.py b/tests/python/tests/test_updateinfo.py
index e89f1a8..727b707 100644
--- a/tests/python/tests/test_updateinfo.py
+++ b/tests/python/tests/test_updateinfo.py
@@ -210,3 +210,182 @@ class TestCaseUpdateInfo(unittest.TestCase):
</update>
</updates>
""" % {"now": now.strftime("%Y-%m-%d %H:%M:%S")})
+
+ def test_updateinfo_xml_dump_04(self):
+ now = datetime.now()
+ # Microseconds are always 0 in updateinfo
+ now = datetime(now.year, now.month, now.day, now.hour, now.minute,
+ now.second, 0)
+
+ pkg = cr.UpdateCollectionPackage()
+ pkg.name = "foo"
+ pkg.version = "1.2"
+ pkg.release = "3"
+ pkg.epoch = "0"
+ pkg.arch = "x86"
+ pkg.src = "foo.src.rpm"
+ pkg.filename = "foo.rpm"
+ pkg.sum = "abcdef"
+ pkg.sum_type = cr.SHA1
+ pkg.reboot_suggested = True
+
+ # Collection without module
+ col = cr.UpdateCollection()
+ col.shortname = "short name"
+ col.name = "long name"
+ col.append(pkg)
+
+ ref = cr.UpdateReference()
+ ref.href = "href"
+ ref.id = "id"
+ ref.type = "type"
+ ref.title = "title"
+
+ rec = cr.UpdateRecord()
+ rec.fromstr = "from"
+ rec.status = "status"
+ rec.type = "type"
+ rec.version = "version"
+ rec.id = "id"
+ rec.title = "title"
+ rec.issued_date = now
+ rec.updated_date = now
+ rec.rights = "rights"
+ rec.release = "release"
+ rec.pushcount = "pushcount"
+ rec.severity = "severity"
+ rec.summary = "summary"
+ rec.description = "description"
+ rec.solution = "solution"
+ rec.append_collection(col)
+ rec.append_reference(ref)
+
+ ui = cr.UpdateInfo()
+ ui.append(rec)
+
+ xml = ui.xml_dump()
+
+ self.assertEqual(xml,
+"""<?xml version="1.0" encoding="UTF-8"?>
+<updates>
+ <update from="from" status="status" type="type" version="version">
+ <id>id</id>
+ <title>title</title>
+ <issued date="%(now)s"/>
+ <updated date="%(now)s"/>
+ <rights>rights</rights>
+ <release>release</release>
+ <pushcount>pushcount</pushcount>
+ <severity>severity</severity>
+ <summary>summary</summary>
+ <description>description</description>
+ <solution>solution</solution>
+ <references>
+ <reference href="href" id="id" type="type" title="title"/>
+ </references>
+ <pkglist>
+ <collection short="short name">
+ <name>long name</name>
+ <package name="foo" version="1.2" release="3" epoch="0" arch="x86" src="foo.src.rpm">
+ <filename>foo.rpm</filename>
+ <sum type="sha1">abcdef</sum>
+ <reboot_suggested/>
+ </package>
+ </collection>
+ </pkglist>
+ </update>
+</updates>
+""" % {"now": now.strftime("%Y-%m-%d %H:%M:%S")})
+
+ def test_updateinfo_xml_dump_05(self):
+ now = datetime.now()
+ # Microseconds are always 0 in updateinfo
+ now = datetime(now.year, now.month, now.day, now.hour, now.minute,
+ now.second, 0)
+
+ # Collection module with unset fields
+ mod = cr.UpdateCollectionModule()
+ mod.version = 18446744073709551615
+ mod.context = "deadbeef"
+ mod.arch = "x86"
+
+ pkg = cr.UpdateCollectionPackage()
+ pkg.name = "foo"
+ pkg.version = "1.2"
+ pkg.release = "3"
+ pkg.epoch = "0"
+ pkg.arch = "x86"
+ pkg.src = "foo.src.rpm"
+ pkg.filename = "foo.rpm"
+ pkg.sum = "abcdef"
+ pkg.sum_type = cr.SHA1
+ pkg.reboot_suggested = True
+
+ col = cr.UpdateCollection()
+ col.shortname = "short name"
+ col.name = "long name"
+ col.module = mod
+ col.append(pkg)
+
+ ref = cr.UpdateReference()
+ ref.href = "href"
+ ref.id = "id"
+ ref.type = "type"
+ ref.title = "title"
+
+ rec = cr.UpdateRecord()
+ rec.fromstr = "from"
+ rec.status = "status"
+ rec.type = "type"
+ rec.version = "version"
+ rec.id = "id"
+ rec.title = "title"
+ rec.issued_date = now
+ rec.updated_date = now
+ rec.rights = "rights"
+ rec.release = "release"
+ rec.pushcount = "pushcount"
+ rec.severity = "severity"
+ rec.summary = "summary"
+ rec.description = "description"
+ rec.solution = "solution"
+ rec.append_collection(col)
+ rec.append_reference(ref)
+
+ ui = cr.UpdateInfo()
+ ui.append(rec)
+
+ xml = ui.xml_dump()
+
+ self.assertEqual(xml,
+"""<?xml version="1.0" encoding="UTF-8"?>
+<updates>
+ <update from="from" status="status" type="type" version="version">
+ <id>id</id>
+ <title>title</title>
+ <issued date="%(now)s"/>
+ <updated date="%(now)s"/>
+ <rights>rights</rights>
+ <release>release</release>
+ <pushcount>pushcount</pushcount>
+ <severity>severity</severity>
+ <summary>summary</summary>
+ <description>description</description>
+ <solution>solution</solution>
+ <references>
+ <reference href="href" id="id" type="type" title="title"/>
+ </references>
+ <pkglist>
+ <collection short="short name">
+ <name>long name</name>
+ <module version="18446744073709551615" context="deadbeef" arch="x86"/>
+ <package name="foo" version="1.2" release="3" epoch="0" arch="x86" src="foo.src.rpm">
+ <filename>foo.rpm</filename>
+ <sum type="sha1">abcdef</sum>
+ <reboot_suggested/>
+ </package>
+ </collection>
+ </pkglist>
+ </update>
+</updates>
+""" % {"now": now.strftime("%Y-%m-%d %H:%M:%S")})
--
libgit2 0.27.7

View File

@ -33,13 +33,11 @@
Summary: Creates a common metadata repository
Name: createrepo_c
Version: 0.13.2
Release: 2%{?dist}
Version: 0.14.1
Release: 1%{?dist}
License: GPLv2+
URL: https://github.com/rpm-software-management/createrepo_c
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
# https://bugzilla.redhat.com/show_bug.cgi?id=1707981
Patch0: 0001-Fix-crash-when-dumping-updateinfo-and-module-is-ommited-RhBug1707981.patch
BuildRequires: cmake
BuildRequires: gcc
@ -258,6 +256,12 @@ ln -sr %{buildroot}%{_bindir}/modifyrepo_c %{buildroot}%{_bindir}/modifyrepo
%endif
%changelog
* Fri May 24 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 0.14.1-1
- Update to 0.14.1
- Add --pkgorigins mode for Koji
- Correct pkg count in headers if there were invalid pkgs (RhBug:1596211)
- Prevent exiting with 0 if errors occur while finalizing repodata.
* Mon May 20 2019 Pavla Kratochvilova <pkratoch@redhat.com> - 0.13.2-2
- Backport patch to fix crash when dumping updateinfo and module is ommited (RhBug:1707981)

View File

@ -1 +1 @@
SHA512 (createrepo_c-0.13.2.tar.gz) = 071372d8df02d5a103c00e9ec99a1e4482337afdf49fe17f7643293060fe8b794d2efd12992f3afef281ad796ed21b3c6dd3a610cdd4ea229a45a7b482764201
SHA512 (createrepo_c-0.14.1.tar.gz) = 40a7b4c46b7eda4bde8a6082c06e3b5e2ace8c80d288c3d47e431a7f2402a8bf8f4d1ea666dc207f995ace37a134576f0d70fe93e9066374b1ead79abd7622b6