summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2018-03-18 11:13:33 -0400
committerMichael Orlitzky <mjo@gentoo.org>2018-03-23 19:34:26 -0400
commit4d3fe7a396ce39cfe22c324b03d4b48fd359da77 (patch)
tree5639019837b1f258db2bd6b215f757d463ba41c0 /dev-python
parentmedia-gfx/potrace: drop vulnerable wrt bug #626820 (diff)
downloadgentoo-4d3fe7a396ce39cfe22c324b03d4b48fd359da77.tar.gz
gentoo-4d3fe7a396ce39cfe22c324b03d4b48fd359da77.tar.bz2
gentoo-4d3fe7a396ce39cfe22c324b03d4b48fd359da77.zip
dev-python/pyzor: new revision to fix some open bugs.
Lots of changes all at once: * Update to EAPI=6. * Remove an old pkg_postinst() notice about a relocated executable. * Add IUSE=gdbm to make the gdbm daemon backend optional. * Only require a (gdbm, mysql, redis) backend with USE=pyzord. * Add a patch submitted upstream (by me) to fix a unicode crash. * Require sphinx with USE=doc (bug 636752). * Remove version constraints on redis-py and gevent (bug 643692). * Use HOMEPAGE to make SRC_URI fit on one line. * Add die() to "mv" and "rm" commands in src_install. * Removed seemingly-unnecessary DISTUTILS_IN_SOURCE_BUILD=1. * Added myself to metadata.xml as a maintainer. * Improved the back-end database engine USE flag descriptions. Bug: https://bugs.gentoo.org/636752 Bug: https://bugs.gentoo.org/643692 Package-Manager: Portage-2.3.19, Repoman-2.3.6
Diffstat (limited to 'dev-python')
-rw-r--r--dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch45
-rw-r--r--dev-python/pyzor/metadata.xml22
-rw-r--r--dev-python/pyzor/pyzor-1.0.0-r1.ebuild70
3 files changed, 133 insertions, 4 deletions
diff --git a/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch b/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch
new file mode 100644
index 000000000000..81668e369377
--- /dev/null
+++ b/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch
@@ -0,0 +1,45 @@
+From 6332a429ed415187599ecce7d8a169ee19f0bbe5 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Sun, 4 Mar 2018 17:34:33 -0500
+Subject: [PATCH 1/1] scripts/pyzor: read stdin as binary in _get_input_msg().
+
+Reading stdin in python-3.x is done as text, with a best-guess
+encoding. But this can go awry: for example, if an iso-8859-1 message
+is passed in and if python guesses the "utf-8" encoding, then read()
+will fail with a UnicodeDecodeError on non-ASCII characters. For
+example, the "copyright" symbol is a single byte 0xa9 in iso-8859-1,
+and the utf-8 decoder can't handle it:
+
+ UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9... invalid
+ start byte
+
+Instead -- and as was done in python-2.x -- we can read stdin as
+binary using the new get_binary_stdin() function. Afterwards, we use
+email.message_from_bytes() instead of the email.message_from_file()
+constructor to parse the byte data. The resulting function is able to
+correctly parse these messages.
+
+Closes: https://github.com/SpamExperts/pyzor/issues/64
+---
+ scripts/pyzor | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/pyzor b/scripts/pyzor
+index 567a7f9..1ba632f 100755
+--- a/scripts/pyzor
++++ b/scripts/pyzor
+@@ -171,7 +171,10 @@ def _get_input_digests(dummy):
+
+
+ def _get_input_msg(digester):
+- msg = email.message_from_file(sys.stdin)
++ # Read and process stdin as bytes because we don't know its
++ # encoding. Python-3.x will try to guess -- and can sometimes
++ # guess wrong -- leading to decoding errors in read().
++ msg = email.message_from_bytes(get_binary_stdin().read())
+ digested = digester(msg).value
+ yield digested
+
+--
+2.13.6
+
diff --git a/dev-python/pyzor/metadata.xml b/dev-python/pyzor/metadata.xml
index 601b2a901647..d88c249a89ff 100644
--- a/dev-python/pyzor/metadata.xml
+++ b/dev-python/pyzor/metadata.xml
@@ -1,15 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
+ <maintainer type="person">
+ <email>mjo@gentoo.org</email>
+ </maintainer>
<maintainer type="project">
<email>python@gentoo.org</email>
<name>Python</name>
</maintainer>
<use>
- <flag name="pyzord">enable support for pyzord</flag>
- <flag name="mysql">Enables mysql support</flag>
- <flag name="redis">Enables redis support</flag>
- <flag name="gevent">Enable support for the gevent based handler</flag>
+ <flag name="pyzord">Enable the pyzord server daemon</flag>
+ <flag name="gdbm">
+ Enables the Gdbm back-end database engine for pyzord
+ </flag>
+ <flag name="mysql">
+ Enables the MySQL back-end database engine for pyzord through
+ <pkg>dev-python/mysql-python</pkg>. Only works with python-2.x!
+ </flag>
+ <flag name="redis">
+ Enables the redis back-end database engine for pyzord through
+ <pkg>dev-python/redis-py</pkg>
+ </flag>
+ <flag name="gevent">
+ Use <pkg>dev-python/gevent</pkg> to enable asynchronous operation
+ </flag>
</use>
<upstream>
<remote-id type="github">SpamExperts/pyzor</remote-id>
diff --git a/dev-python/pyzor/pyzor-1.0.0-r1.ebuild b/dev-python/pyzor/pyzor-1.0.0-r1.ebuild
new file mode 100644
index 000000000000..14e1ee840724
--- /dev/null
+++ b/dev-python/pyzor/pyzor-1.0.0-r1.ebuild
@@ -0,0 +1,70 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+PYTHON_COMPAT=( python{2_7,3_4,3_5} )
+
+inherit distutils-r1
+
+MY_PV="1-0-0"
+DESCRIPTION="A distributed, collaborative spam detection and filtering network"
+HOMEPAGE="https://github.com/SpamExperts/pyzor"
+SRC_URI="${HOMEPAGE}/archive/release-${MY_PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~amd64-linux ~x86-linux"
+
+IUSE="doc gdbm gevent mysql pyzord redis test"
+
+# The mysql-python library is always required for the MySQL engine. We
+# depend on it conditionally here because otherwise repoman will balk at
+# the potential conflict between PYTHON_TARGETS and USE=mysql. But as a
+# result, if you try to use the MySQL engine with python-3.x, it just
+# won't work because you'll be missing the library.
+RDEPEND="pyzord? (
+ gdbm? ( $(python_gen_impl_dep 'gdbm') )
+ mysql? ( $(python_gen_cond_dep \
+ 'dev-python/mysql-python[${PYTHON_USEDEP}]' python2_7) )
+ redis? ( dev-python/redis-py[${PYTHON_USEDEP}] )
+ gevent? ( dev-python/gevent[${PYTHON_USEDEP}] )
+)"
+DEPEND="dev-python/setuptools[${PYTHON_USEDEP}]
+ doc? ( dev-python/sphinx[${PYTHON_USEDEP}] )
+ test? ( ${RDEPEND} )"
+
+# TODO: maybe upstream would support skipping tests for which the
+# dependencies are missing?
+REQUIRED_USE="pyzord? ( || ( gdbm mysql redis ) )
+ test? ( gdbm mysql redis )"
+S="${WORKDIR}/${PN}-release-${MY_PV}"
+
+PATCHES=( "${FILESDIR}/read-stdin-as-binary-in-get_input_msg.patch" )
+
+python_test() {
+ # The suite is py2 friendly only
+ if ! python_is_python3; then
+ PYTHONPATH=. "${PYTHON}" ./tests/unit/__init__.py
+ fi
+}
+
+python_compile_all() {
+ use doc && emake -C docs html
+}
+
+python_install_all() {
+ use doc && HTML_DOCS=( docs/.build/html/. )
+ distutils-r1_python_install_all
+}
+
+src_install () {
+ distutils-r1_src_install
+
+ if use pyzord; then
+ dodir /usr/sbin
+ mv "${D}"usr/bin/pyzord* "${ED}usr/sbin" \
+ || die "failed to relocate pyzord"
+ else
+ rm "${D}"usr/bin/pyzord* || die "failed to remove pyzord"
+ fi
+}