[python-pgpdump/el6] Patch to support Python2.6 in RHEL6.
Christopher Meng
cicku at fedoraproject.org
Fri Jan 24 03:31:51 UTC 2014
commit 48d7b9c1da834a683693b498aed4bcade29c375f
Author: Christopher Meng <i at cicku.me>
Date: Fri Jan 24 11:31:12 2014 +0800
Patch to support Python2.6 in RHEL6.
python-pgpdump-python2.6-backports.patch | 88 ++++++++++++++++++++++++++++++
python-pgpdump.spec | 50 ++++-------------
2 files changed, 99 insertions(+), 39 deletions(-)
---
diff --git a/python-pgpdump-python2.6-backports.patch b/python-pgpdump-python2.6-backports.patch
new file mode 100644
index 0000000..ad3ffe5
--- /dev/null
+++ b/python-pgpdump-python2.6-backports.patch
@@ -0,0 +1,88 @@
+--- python-pgpdump-1.4.orig/pgpdump/packet.py 2012-10-22 11:14:03.000000000 -0400
++++ python-pgpdump-1.4.orig/pgpdump/packet.py 2014-01-16 17:05:47.831757283 -0500
+@@ -4,7 +4,7 @@
+ from warnings import warn
+
+ from .utils import (PgpdumpException, get_int2, get_int4, get_mpi,
+- get_key_id, get_int_bytes)
++ get_key_id, get_int_bytes, pack_data)
+
+
+ class Packet(object):
+@@ -383,8 +383,8 @@
+ elif self.pubkey_version == 4:
+ sha1 = hashlib.sha1()
+ seed_bytes = (0x99, (self.length >> 8) & 0xff, self.length & 0xff)
+- sha1.update(bytearray(seed_bytes))
+- sha1.update(self.data)
++ sha1.update(pack_data(seed_bytes))
++ sha1.update(pack_data(self.data))
+ self.fingerprint = sha1.hexdigest().upper().encode('ascii')
+ self.key_id = self.fingerprint[24:]
+
+@@ -620,7 +620,7 @@
+ user_re = re.compile(r'^([^<]+)? ?<([^>]*)>?')
+
+ def parse(self):
+- self.user = self.data.decode('utf8', errors='replace')
++ self.user = self.data.decode()
+ matches = self.user_re.match(self.user)
+ if matches:
+ if matches.group(1):
+--- python-pgpdump-1.4.orig/pgpdump/test.py 2012-10-22 11:14:03.000000000 -0400
++++ python-pgpdump-1.4.orig/pgpdump/test.py 2014-01-16 15:52:58.000000000 -0500
+@@ -104,19 +104,23 @@
+ data = fileobj.read()
+ return data
+
++ def assertIsNotNone(self, x):
++ return bool(x is not None)
++
++ def assertIsNone(self, x):
++ return bool(x is None)
++
++
+
+ class ParseTestCase(TestCase, Helper):
+ def test_parse_empty(self):
+- with self.assertRaises(PgpdumpException):
+- BinaryData(None)
++ self.assertRaises(PgpdumpException, BinaryData, None)
+
+ def test_parse_short(self):
+- with self.assertRaises(PgpdumpException):
+- BinaryData([0x00])
++ self.assertRaises(PgpdumpException, BinaryData, [0x00])
+
+ def test_parse_invalid(self):
+- with self.assertRaises(PgpdumpException):
+- BinaryData([0x00, 0x00])
++ self.assertRaises(PgpdumpException, BinaryData, [0x00, 0x00])
+
+ def test_parse_single_sig_packet(self):
+ base64_sig = b"iEYEABECAAYFAk6A4a4ACgkQXC5GoPU6du1ATACgodGyQne3Rb7"\
+--- python-pgpdump-1.4.orig/pgpdump/utils.py 2012-10-22 11:14:03.000000000 -0400
++++ python-pgpdump-1.4.orig/pgpdump/utils.py 2014-01-16 16:58:00.395248375 -0500
+@@ -1,5 +1,5 @@
+ import binascii
+-
++import struct
+
+ class PgpdumpException(Exception):
+ '''Base exception class raised by any parsing errors, etc.'''
+@@ -99,11 +99,14 @@
+ offset += to_process
+ return mpi, offset
+
++def pack_data(data):
++ '''Pack iterable of binary data into a string.'''
++ return struct.pack('%dB' % len(data), *data)
+
+ def get_key_id(data, offset):
+ '''Pull eight bytes from data at offset and return as a 16-byte hex-encoded
+ string.'''
+- key_id = binascii.hexlify(data[offset:offset + 8])
++ key_id = binascii.hexlify(bytes(data[offset:offset + 8]))
+ return key_id.upper()
+
+
diff --git a/python-pgpdump.spec b/python-pgpdump.spec
index 0935f8e..fc215a5 100644
--- a/python-pgpdump.spec
+++ b/python-pgpdump.spec
@@ -2,10 +2,11 @@
Name: python-%{pkgname}
Version: 1.4
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: PGP packet parser library in Python 2.x
URL: http://www.mew.org/~kazu/proj/pgpdump/
Source: https://pypi.python.org/packages/source/p/%{pkgname}/%{pkgname}-%{version}.tar.gz
+Patch0: python-pgpdump-python2.6-backports.patch
License: BSD
BuildArch: noarch
BuildRequires: python2-devel
@@ -23,56 +24,27 @@ Currently supported things include:
* Trust, user ID, and user attribute packets
* ASCII-armor decoding and CRC check
-%package -n python3-%{pkgname}
-Summary: PGP packet parser library in Python 3.x
-BuildRequires: python3-devel
-
-%description -n python3-%{pkgname}
-python-pgpdump is a Python library for parsing PGP packets. The intent here
-is not on completeness, as we don't currently decode every packet type, but
-on being able to do what people actually have to 95% of the time.
-
-Currently supported things include:
-
-* Signature packets
-* Public key packets
-* Secret key packets
-* Trust, user ID, and user attribute packets
-* ASCII-armor decoding and CRC check
-
%prep
%setup -qn %{pkgname}-%{version}
-rm -rf %{py3dir}
-cp -a . %{py3dir}
+%patch0 -p1
%build
-%{__python2} setup.py build
-pushd %{py3dir}
-%{__python3} setup.py build
-popd
+%{__python} setup.py build
%install
-%{__python2} setup.py install --prefix=%{_prefix} -O1 --skip-build --root=%{buildroot}
-pushd %{py3dir}
-%{__python3} setup.py install --prefix=%{_prefix} -O1 --skip-build --root=%{buildroot}
-popd
+%{__python} setup.py install --prefix=%{_prefix} -O1 --skip-build --root=%{buildroot}
%check
-PYTHONPATH=%{buildroot}%{python2_sitelib} %{__python2} pgpdump/test.py
-pushd %{py3dir}
-PYTHONPATH=%{buildroot}%{python3_sitelib} %{__python3} pgpdump/test.py
-popd
+PYTHONPATH=%{buildroot}%{python_sitelib} %{__python} pgpdump/test.py
%files
%doc COPYRIGHT README.md
-%{python2_sitelib}/%{pkgname}-%{version}-py%{python_version}.egg-info
-%{python2_sitelib}/%{pkgname}
-
-%files -n python3-%{pkgname}
-%doc COPYRIGHT README.md
-%{python3_sitelib}/%{pkgname}-%{version}-py%{python3_version}.egg-info
-%{python3_sitelib}/%{pkgname}
+%{python_sitelib}/%{pkgname}-%{version}-py%{python_version}.egg-info
+%{python_sitelib}/%{pkgname}
%changelog
+* Fri Jan 24 2014 Christopher Meng <rpm at cicku.me> - 1.4-2
+- Patch to support EPEL6.
+
* Wed Dec 19 2012 Christopher Meng <rpm at cicku.me> - 1.4-1
- Initial Package.
More information about the scm-commits
mailing list