Browse code

pyzor - fix für python deprecation

Hanno Böck authored on 15/10/2013 21:55:11
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+AUX pyzor-0.5.0-python26_warnings.patch 2680 SHA256 f1b9f51295788ac40c6396ea12a846f0b01d45fa8d87448d764900b3b167b9ff SHA512 e7a8826dc2b02ff24301b116247344ca221008333fbaf1fb4037ed1eef7e317235070fd6f6b70e4ffec0a44de675b1c6ae09da555d6a23295fd4c81301a13c80 WHIRLPOOL c3bdaeb5e2b312434164ec24b83fb067961cbaf164dc568da138ea397deee75c411edbc0b510ca2bd904c76caec079e46251dee5b8af8ca659c689e181b203f7
2
+AUX pyzord_getopt.patch 640 SHA256 6cc675c7caf935342c3728ef399c2ebdb57029d146903aa36593fa3a34f270a9 SHA512 8c405266251f61b0d4b54d3811512067d90521dc04fb0a2df60fc19d27d818fb00849af0c0469187d60fe2d3c6bdde71fbf8320e22b2d5db5e6226c06cde93db WHIRLPOOL 2fef82cb54b2cd03baf29536e121c84b9f1823c9593278c362624cceb180cbd562d57e8147cb6218ba1ceeffb7d4137d0ec64f94cc1d66e9d93effe4bf29ce95
3
+DIST pyzor-0.5.0.tar.bz2 40654 SHA256 2bf3df9e916861063a73f7b46cb8b27bac6f661fce1362803de9e7921fc155ba SHA512 048c81e373be217808f4e4e8f6adbc1b464891b725b3004031dfa7a82abe234b080c3a87bc9ad61ee1df2bfb78ed0ee78565b49843f09243f72b6315df6877a1 WHIRLPOOL 966090015bfe93d4ef059a1186e97705807769f9341e94a2f5d9c223540effac04209a32cad850c6f405225c00aea55bdf7ac5a6a98e0927824d641ee61e5c80
4
+EBUILD pyzor-0.5.0-r1.ebuild 1478 SHA256 edb0e83054daa54a05a25b1a80ec712acbe53e5b85da8e68bb248982a0c3a7ce SHA512 af8c0db7e313db16e9f09b2df8d4225bfee3be18a2690f2b03fdcaba3feb076e4f53bc0ec28165aab941152025d61e219b0d7f137fd916feb5248f0414edd508 WHIRLPOOL 875448bbe0522faf96a766c5b3cf598e00e1804ab9fcbc4816149c90cf38be383231786c8b60177b371f16511dccea423715edf48e561461b0e25eb1f7728753
0 5
new file mode 100644
... ...
@@ -0,0 +1,89 @@
1
+# Description: Fix python2.6 deprecation warnings
2
+# Origin: Ubuntu
3
+# Author: Alessio Treglia <quadrispro@ubuntu.com>
4
+# Bug-Ubuntu: https://bugs.launchpad.net/bugs/394775
5
+diff -Nur -x '*.orig' -x '*~' pyzor-0.5.0/lib/pyzor/client.py pyzor-0.5.0.new/lib/pyzor/client.py
6
+--- pyzor-0.5.0/lib/pyzor/client.py	2009-04-29 22:53:50.000000000 +0200
7
+@@ -10,7 +10,7 @@
8
+ import tempfile
9
+ import mimetools
10
+ import multifile
11
+-import sha
12
++import hashlib
13
+ 
14
+ import pyzor
15
+ from pyzor import *
16
+@@ -402,12 +402,12 @@
17
+         del p2
18
+ 
19
+         saltfile = open(randfile)
20
+-        salt = saltfile.read(sha.digest_size)
21
++        salt = saltfile.read(hashlib.sha1().digest_size)
22
+         del saltfile
23
+ 
24
+-        salt_digest = sha.new(salt)
25
++        salt_digest = hashlib.sha1(salt)
26
+ 
27
+-        pass_digest = sha.new()
28
++        pass_digest = hashlib.sha1()
29
+         pass_digest.update(salt_digest.digest())
30
+         pass_digest.update(p1)
31
+         sys.stdout.write("salt,key:\n")
32
+@@ -498,7 +498,7 @@
33
+         if len(offsets) == 0:
34
+             return
35
+ 
36
+-        self._digest = sha.new()
37
++        self._digest = hashlib.sha1()
38
+ 
39
+         if len(offsets) <= self.atomic_num_lines:
40
+             self.handle_atomic(fp)
41
+diff -Nur -x '*.orig' -x '*~' pyzor-0.5.0/lib/pyzor/__init__.py pyzor-0.5.0.new/lib/pyzor/__init__.py
42
+--- pyzor-0.5.0/lib/pyzor/__init__.py	2009-04-29 22:53:50.000000000 +0200
43
+@@ -8,7 +8,7 @@
44
+ import os.path
45
+ import re
46
+ import sys
47
+-import sha
48
++import hashlib
49
+ import tempfile
50
+ import random
51
+ import ConfigParser
52
+@@ -114,7 +114,7 @@
53
+ 
54
+ class DataDigest(str):
55
+     # hex output doubles digest size
56
+-    value_size = sha.digest_size * 2
57
++    value_size = hashlib.sha1().digest_size * 2
58
+ 
59
+     def __init__(self, value):
60
+         if len(value) != self.value_size:
61
+@@ -285,7 +285,7 @@
62
+         """returns a digest object"""
63
+         typecheck(msg, Message)
64
+ 
65
+-        return sha.new(str(msg))
66
++        return hashlib.sha1(str(msg))
67
+ 
68
+     hash_msg = staticmethod(hash_msg)
69
+ 
70
+@@ -295,7 +295,7 @@
71
+         typecheck(key, long)
72
+         typecheck(user, Username)
73
+ 
74
+-        return sha.new("%s:%x" % (Username, key)).hexdigest().lower()
75
++        return hashlib.sha1("%s:%x" % (Username, key)).hexdigest().lower()
76
+ 
77
+     hash_key = staticmethod(hash_key)
78
+ 
79
+@@ -316,7 +316,7 @@
80
+ 
81
+         h_msg = self.hash_msg(msg)
82
+ 
83
+-        return sha.new("%s:%d:%s" % (h_msg.digest(), ts, hashed_key)).hexdigest().lower()
84
++        return hashlib.sha1("%s:%d:%s" % (h_msg.digest(), ts, hashed_key)).hexdigest().lower()
85
+ 
86
+     sign_msg = classmethod(sign_msg)
87
+ 
0 88
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+--- scripts/pyzord.orig	2002-09-08 06:33:44.000000000 +0300
2
+@@ -52,7 +52,11 @@
3
+ # functions above, run below
4
+ 
5
+ debug = 0
6
+-(options, args) = getopt.getopt(sys.argv[1:], 'dh:', ['homedir='])
7
++try:
8
++    (options, args) = getopt.getopt(sys.argv[1:], 'hd', ['help','homedir='])
9
++except getopt.GetoptError, err:
10
++    print str(err)
11
++    usage()
12
+ if len(args) != 0:
13
+     usage()
14
+ 
15
+@@ -61,7 +65,7 @@
16
+ for (o, v) in options:
17
+     if o == '-d':
18
+         debug = 1
19
+-    elif o == '-h':
20
++    elif o in ('-h', '--help'):
21
+         usage()
22
+     elif o == '--homedir':
23
+         specified_homedir = v
0 24
new file mode 100644
... ...
@@ -0,0 +1,66 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/dev-python/pyzor/pyzor-0.5.0-r1.ebuild,v 1.7 2010/07/27 16:49:25 arfrever Exp $
4
+
5
+EAPI="3"
6
+PYTHON_DEPEND="2"
7
+PYTHON_USE_WITH="gdbm"
8
+PYTHON_USE_WITH_OPT="pyzord"
9
+SUPPORT_PYTHON_ABIS="1"
10
+RESTRICT_PYTHON_ABIS="3.*"
11
+
12
+inherit distutils eutils
13
+
14
+DESCRIPTION="A distributed, collaborative spam detection and filtering network"
15
+HOMEPAGE="http://pyzor.sourceforge.net/"
16
+SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
17
+
18
+LICENSE="GPL-2"
19
+SLOT="0"
20
+KEYWORDS="alpha amd64 hppa ia64 ppc ppc64 sparc x86"
21
+IUSE="pyzord"
22
+
23
+DEPEND=""
24
+RDEPEND=""
25
+
26
+DOCS="THANKS UPGRADING"
27
+
28
+src_prepare() {
29
+	epatch "${FILESDIR}/pyzord_getopt.patch"
30
+	epatch "${FILESDIR}/pyzor-0.5.0-python26_warnings.patch"
31
+
32
+	# rfc822BodyCleanerTest doesn't work fine.
33
+	# Remove it until it's fixed.
34
+	sed -i \
35
+		-e '/rfc822BodyCleanerTest/,/self\.assertEqual/d' \
36
+		unittests.py || die "sed in unittest.py failed"
37
+}
38
+
39
+src_test() {
40
+	testing() {
41
+		PYTHONPATH="build-${PYTHON_ABI}/lib" "$(PYTHON)" unittests.py
42
+	}
43
+	python_execute_function testing
44
+}
45
+
46
+src_install () {
47
+	distutils_src_install
48
+
49
+	dohtml docs/usage.html
50
+	rm -rf "${ED}usr/share/doc/pyzor"
51
+
52
+	if use pyzord; then
53
+		dodir /usr/sbin
54
+		mv "${ED}"usr/bin/pyzord* "${ED}usr/sbin"
55
+	else
56
+		rm "${ED}"usr/bin/pyzord*
57
+	fi
58
+}
59
+
60
+pkg_postinst() {
61
+	distutils_pkg_postinst
62
+
63
+	if use pyzord; then
64
+		ewarn "/usr/bin/pyzord has been moved to /usr/sbin"
65
+	fi
66
+}