diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2018-07-14 21:03:06 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2018-07-14 21:03:06 +0100 |
commit | 8376ef56580626e9c0f796d5b85b53a0a1c7d5f5 (patch) | |
tree | 7681bbd4e8b05407772df40a4bf04cbbc8afc3fa /dev-python/pyzor | |
parent | 30a9caf154332f12ca60756e1b75d2f0e3e1822d (diff) |
gentoo resync : 14.07.2018
Diffstat (limited to 'dev-python/pyzor')
-rw-r--r-- | dev-python/pyzor/Manifest | 5 | ||||
-rw-r--r-- | dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch | 85 | ||||
-rw-r--r-- | dev-python/pyzor/files/unfix-configparser-compat-for-2to3.patch | 41 | ||||
-rw-r--r-- | dev-python/pyzor/metadata.xml | 32 | ||||
-rw-r--r-- | dev-python/pyzor/pyzor-1.0.0-r1.ebuild | 73 |
5 files changed, 236 insertions, 0 deletions
diff --git a/dev-python/pyzor/Manifest b/dev-python/pyzor/Manifest new file mode 100644 index 000000000000..173f1422c4da --- /dev/null +++ b/dev-python/pyzor/Manifest @@ -0,0 +1,5 @@ +AUX read-stdin-as-binary-in-get_input_msg.patch 2751 BLAKE2B c348d28eeb703ff9b257c915ba6c6ac62e95a1f389173ff2fcd034dbcfdf8b9d9fd075365b9033fe13a3f5ec6a24dad5110c468f54dc5417241cf5cb95e5933f SHA512 424d7b640e4f297bde5e98c92b7fec48c79998b07a710f685f786c673ef10981efc71647973fdd05ac84879387ab5eb97d5c734bf5b03827dd998cf292948d5b +AUX unfix-configparser-compat-for-2to3.patch 1210 BLAKE2B 1ad8b2528cbf723d46d18c25163f68738281c48638b86c8809b5dab8f6f3c0058f17b1e2232d7c704b4aa777aaaf43c63170478da95272e75492bbbaec696789 SHA512 d9f5308d1f9280db5a0556fcaf3927e261b6cd1d01ff42c05a912335c6f9343f78096eed645aab5c741c221adf5ece00137aa3ae6f950cafbeb77db1908949b9 +DIST pyzor-1.0.0.tar.gz 126276 BLAKE2B c60f26c53bf118c88dacbc49ddd414473748af1868b383a9c937ecf3cfe426ecdd60f64388fe7e555bd4641ef445769600e40879279dd544ef9ea32bd0dab6b9 SHA512 b3fb8b2c5261e187a2ab3a5a3b12d221df7de08766c6bb2ad9990c0f23517534871ecc9d5ad529e79b0d0aef8b2b800728320c57435a8c0d8c3f80a4ba0f7e4a +EBUILD pyzor-1.0.0-r1.ebuild 2138 BLAKE2B 84221ba29f76b77eaa9d5dd9f71ab652c57b5b2860686b8dc55253612ffb43167c1e437f1ea67e1fac50b35cfa81547fe108ada5daa906df59dbdb6f6fdc5621 SHA512 8611504e9f9d5e0ff97e9439b6aa74d17ea7ede5c2d12d15c4f6bf8937a82151c17124c0558cb40714962dff0ffc345927577a96d46254753e4c2513795c057f +MISC metadata.xml 1061 BLAKE2B d2ad7e863f055f46e4ab2048cd8cf042444476da9423743c246ede1f6b3f2b8be4b9f980da10e741726ae25625af09a8ce6eeb7710c2f5a8ceb4cc4f915d2e61 SHA512 58d18a197dd3575d7644f0e9f446344ccfcc321d33493fadfd89f7f233a1dc58e0c899b42a3ae72b219dc1327e2de6eeaf90a8de3735fdc0dc1f6c67c5cc8722 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..03031a976690 --- /dev/null +++ b/dev-python/pyzor/files/read-stdin-as-binary-in-get_input_msg.patch @@ -0,0 +1,85 @@ +From 66225b32d2774cf37fa7f702f7eb26cd94094482 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Sun, 4 Mar 2018 17:27:01 -0500 +Subject: [PATCH 1/1] scripts/pyzor: replace the client with the git (+ issue + 64 fix) version. + +--- + scripts/pyzor | 33 +++++++++++++++++++++++++++------ + 1 file changed, 27 insertions(+), 6 deletions(-) + +diff --git a/scripts/pyzor b/scripts/pyzor +index 19b1d21..86c6f7d 100755 +--- a/scripts/pyzor ++++ b/scripts/pyzor +@@ -17,9 +17,9 @@ import tempfile + import threading + + try: +- import ConfigParser +-except ImportError: + import configparser as ConfigParser ++except ImportError: ++ import ConfigParser + + import pyzor.digest + import pyzor.client +@@ -110,7 +110,7 @@ def load_configuration(): + config = ConfigParser.ConfigParser() + # Set the defaults. + config.add_section("client") +- for key, value in defaults.iteritems(): ++ for key, value in defaults.items(): + config.set("client", key, value) + # Override with the configuration. + config.read(os.path.join(options.homedir, "config")) +@@ -171,14 +171,35 @@ def _get_input_digests(dummy): + + + def _get_input_msg(digester): +- msg = email.message_from_file(sys.stdin) ++ msg = email.message_from_bytes(get_binary_stdin().read()) + digested = digester(msg).value + yield digested + + ++def _is_binary_reader(stream, default=False): ++ try: ++ return isinstance(stream.read(0), bytes) ++ except Exception: ++ return default ++ ++ ++def get_binary_stdin(): ++ # sys.stdin might or might not be binary in some extra cases. By ++ # default it's obviously non binary which is the core of the ++ # problem but the docs recommend changing it to binary for such ++ # cases so we need to deal with it. ++ is_binary = _is_binary_reader(sys.stdin, False) ++ if is_binary: ++ return sys.stdin ++ buf = getattr(sys.stdin, 'buffer', None) ++ if buf is not None and _is_binary_reader(buf, True): ++ return buf ++ raise RuntimeError('Did not manage to get binary stdin') ++ ++ + def _get_input_mbox(digester): + tfile = tempfile.NamedTemporaryFile() +- tfile.write(sys.stdin.read().encode("utf8")) ++ tfile.write(get_binary_stdin().read()) + tfile.seek(0) + mbox = mailbox.mbox(tfile.name) + for msg in mbox: +@@ -372,7 +393,7 @@ def genkey(client, servers, config, hash_func=hashlib.sha1): + return False + # pylint: disable-msg=W0612 + salt = "".join([chr(random.randint(0, 255)) +- for unused in xrange(hash_func(b"").digest_size)]) ++ for unused in range(hash_func(b"").digest_size)]) + if sys.version_info >= (3, 0): + salt = salt.encode("utf8") + salt_digest = hash_func(salt) +-- +2.13.6 + diff --git a/dev-python/pyzor/files/unfix-configparser-compat-for-2to3.patch b/dev-python/pyzor/files/unfix-configparser-compat-for-2to3.patch new file mode 100644 index 000000000000..93d0f07a2579 --- /dev/null +++ b/dev-python/pyzor/files/unfix-configparser-compat-for-2to3.patch @@ -0,0 +1,41 @@ +From e4f06e21f697b863fa45a50e535ff0c6e3621a60 Mon Sep 17 00:00:00 2001 +From: Michael Orlitzky <michael@orlitzky.com> +Date: Sun, 25 Mar 2018 10:14:21 -0400 +Subject: [PATCH 1/1] scripts/pyzor: undo ConfigParser python-3.x + compatibility. + +The build system for pyzor-1.0.0 still runs the 2to3 utility on the +scripts to be installed. As an unintended side-effect, the python-3.x +"try... import... except" compatibility block for the ConfigParser <-> +configparser module gets modified (the module name gets mistakenly +lowercased). + +This commit puts back the python-2.x "import ConfigParser" line +unconditionally, and we'll have to rely on 2to3 to fix it when run +under python-3.x. In newer versions of pyzor, the automatic 2to3 will +not happen. + +Bug: https://bugs.gentoo.org/643692 +--- + scripts/pyzor | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/scripts/pyzor b/scripts/pyzor +index 86c6f7d..2750d92 100755 +--- a/scripts/pyzor ++++ b/scripts/pyzor +@@ -16,10 +16,7 @@ import optparse + import tempfile + import threading + +-try: +- import configparser as ConfigParser +-except ImportError: +- import ConfigParser ++import ConfigParser + + import pyzor.digest + import pyzor.client +-- +2.16.1 + diff --git a/dev-python/pyzor/metadata.xml b/dev-python/pyzor/metadata.xml new file mode 100644 index 000000000000..d88c249a89ff --- /dev/null +++ b/dev-python/pyzor/metadata.xml @@ -0,0 +1,32 @@ +<?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 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> + <remote-id type="sourceforge">pyzor</remote-id> + </upstream> +</pkgmetadata> 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..278c554b64d0 --- /dev/null +++ b/dev-python/pyzor/pyzor-1.0.0-r1.ebuild @@ -0,0 +1,73 @@ +# 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,3_6} ) + +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" + "${FILESDIR}/unfix-configparser-compat-for-2to3.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 +} |