From 26e277b27b07df3a2603328fda8ffdeb8aca2de9 Mon Sep 17 00:00:00 2001 From: Ondřej Nosek Date: Apr 25 2019 12:54:42 +0000 Subject: Backport patch for RPM after rhbz#1693751 Signed-off-by: Ondřej Nosek --- diff --git a/0002-Handle-data-from-python-RPM-binding-as-UTF-8-string.patch b/0002-Handle-data-from-python-RPM-binding-as-UTF-8-string.patch new file mode 100644 index 0000000..473d9f1 --- /dev/null +++ b/0002-Handle-data-from-python-RPM-binding-as-UTF-8-string.patch @@ -0,0 +1,52 @@ +From 7f3f4b607948f1babb154b7946813fa6f8edb8fe Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= +Date: Mon, 22 Apr 2019 16:13:24 +0200 +Subject: [PATCH] Handle data from python RPM binding as UTF-8 string +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The RPM python3 bindings return ALL string data as surrogate-escaped +utf-8 string objects. +See: https://bugzilla.redhat.com/show_bug.cgi?id=1693751 + +Signed-off-by: Robert-André Mauchin +--- + pyrpkg/__init__.py | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py +index 8fe4ed0..23b1ed7 100644 +--- a/pyrpkg/__init__.py ++++ b/pyrpkg/__init__.py +@@ -1248,8 +1248,11 @@ class Commands(object): + archlist = [pkg.header['arch'] for pkg in hdr.packages] + if not archlist: + raise rpkgError('No compatible build arches found in %s' % spec) +- if hasattr(archlist[0], 'decode'): +- return [arch.decode('utf-8') for arch in archlist] ++ if six.PY3: ++ return [str(arch, encoding='utf-8') ++ if not isinstance(arch, six.string_types) ++ else arch ++ for arch in archlist] + else: + return archlist + +@@ -1339,10 +1342,10 @@ class Commands(object): + hdr = koji.get_rpm_header(srpm) + name = hdr[rpm.RPMTAG_NAME] + contents = hdr[rpm.RPMTAG_FILENAMES] +- if hasattr(name, 'decode'): ++ if six.PY3 and not isinstance(name, six.string_types): + # RPM before rhbz#1693751 returned bytes +- name = name.decode('utf-8') +- contents = [filename.decode('utf-8') ++ name = str(name, encoding='utf-8') ++ contents = [str(filename, encoding='utf-8') + for filename in contents] + except Exception as e: + raise rpkgError('Error querying srpm: {0}'.format(str(e))) +-- +2.20.1 + diff --git a/rpkg.spec b/rpkg.spec index ff9b164..9eac3e2 100644 --- a/rpkg.spec +++ b/rpkg.spec @@ -4,7 +4,7 @@ Name: rpkg Version: 1.57 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Python library for interacting with rpm+git License: GPLv2+ and LGPLv2 @@ -28,6 +28,9 @@ Patch0001: 0001-Upload-.crate-files-to-lookaside-cache.patch # https://pagure.io/rpkg/pull-request/439 Patch0002: 0001-srpm_import-be-compatible-with-rhbz-1693751.patch +# https://pagure.io/rpkg/pull-request/440 +Patch0003: 0002-Handle-data-from-python-RPM-binding-as-UTF-8-string.patch + %if 0%{?fedora} || 0%{?rhel} > 7 # Enable python3 build by default %global with_python3 1 @@ -263,6 +266,9 @@ nosetests tests %changelog +* Thu Apr 25 2019 Ondřej Nosek - 1.57-9 +- yet another compat fix with RPM after rhbz#1693751 + * Fri Apr 19 2019 Pavel Raiskup - 1.57-8 - compat fix with RPM after rhbz#1693751