Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-misc/ca-certificates/files/, app-misc/ca-certificates/
Date: Sat, 26 Sep 2015 17:46:15
Message-Id: 1443289528.6e28397b91d9a84ccc36f8fdb3499f747d50e3d9.vapier@gentoo
1 commit: 6e28397b91d9a84ccc36f8fdb3499f747d50e3d9
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 26 16:23:38 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 26 17:45:28 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e28397b
7
8 app-misc/ca-certificates: add python 3 support #548374
9
10 Patch taken from Debian bug report.
11
12 .../ca-certificates-20150426.3.20.ebuild | 5 +-
13 ...ertificates-20150426-nss-certdata2pem-py3.patch | 82 ++++++++++++++++++++++
14 2 files changed, 86 insertions(+), 1 deletion(-)
15
16 diff --git a/app-misc/ca-certificates/ca-certificates-20150426.3.20.ebuild b/app-misc/ca-certificates/ca-certificates-20150426.3.20.ebuild
17 index 2431504..c37ecde 100644
18 --- a/app-misc/ca-certificates/ca-certificates-20150426.3.20.ebuild
19 +++ b/app-misc/ca-certificates/ca-certificates-20150426.3.20.ebuild
20 @@ -26,7 +26,7 @@
21 # https://bugzilla.mozilla.org/enter_bug.cgi?product=NSS&component=CA%20Certificates&version=trunk
22
23 EAPI="4"
24 -PYTHON_COMPAT=( python2_7 )
25 +PYTHON_COMPAT=( python{2_7,3_3,3_4} )
26
27 inherit eutils python-any-r1
28
29 @@ -123,6 +123,9 @@ src_prepare() {
30 -e '/="$ROOT/s:ROOT/:ROOT'"${EPREFIX}"'/:' \
31 -e '/RELPATH="\.\./s:"$:'"${relp}"'":' \
32 usr/sbin/update-ca-certificates || die
33 +
34 + cd "${S}"
35 + epatch "${FILESDIR}"/${PN}-20150426-nss-certdata2pem-py3.patch #548374
36 }
37
38 src_compile() {
39
40 diff --git a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
41 new file mode 100644
42 index 0000000..300ce47
43 --- /dev/null
44 +++ b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
45 @@ -0,0 +1,82 @@
46 +https://bugs.debian.org/789753
47 +https://bugs.gentoo.org/548374
48 +
49 +--- a/ca-certificates/mozilla/certdata2pem.py
50 ++++ b/ca-certificates/mozilla/certdata2pem.py
51 +@@ -53,7 +53,7 @@ for line in open('certdata.txt', 'r'):
52 + if type == 'MULTILINE_OCTAL':
53 + line = line.strip()
54 + for i in re.finditer(r'\\([0-3][0-7][0-7])', line):
55 +- value += chr(int(i.group(1), 8))
56 ++ value.append(int(i.group(1), 8))
57 + else:
58 + value += line
59 + continue
60 +@@ -70,13 +70,13 @@ for line in open('certdata.txt', 'r'):
61 + field, type = line_parts
62 + value = None
63 + else:
64 +- raise NotImplementedError, 'line_parts < 2 not supported.'
65 ++ raise NotImplementedError('line_parts < 2 not supported.')
66 + if type == 'MULTILINE_OCTAL':
67 + in_multiline = True
68 +- value = ""
69 ++ value = bytearray()
70 + continue
71 + obj[field] = value
72 +-if len(obj.items()) > 0:
73 ++if len(obj) > 0:
74 + objects.append(obj)
75 +
76 + # Read blacklist.
77 +@@ -95,7 +95,7 @@ for obj in objects:
78 + if obj['CKA_CLASS'] not in ('CKO_NETSCAPE_TRUST', 'CKO_NSS_TRUST'):
79 + continue
80 + if obj['CKA_LABEL'] in blacklist:
81 +- print "Certificate %s blacklisted, ignoring." % obj['CKA_LABEL']
82 ++ print("Certificate %s blacklisted, ignoring." % obj['CKA_LABEL'])
83 + elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_TRUSTED_DELEGATOR',
84 + 'CKT_NSS_TRUSTED_DELEGATOR'):
85 + trust[obj['CKA_LABEL']] = True
86 +@@ -104,13 +104,13 @@ for obj in objects:
87 + trust[obj['CKA_LABEL']] = True
88 + elif obj['CKA_TRUST_SERVER_AUTH'] in ('CKT_NETSCAPE_UNTRUSTED',
89 + 'CKT_NSS_NOT_TRUSTED'):
90 +- print '!'*74
91 +- print "UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s" % obj['CKA_LABEL']
92 +- print '!'*74
93 ++ print('!'*74)
94 ++ print("UNTRUSTED BUT NOT BLACKLISTED CERTIFICATE FOUND: %s" % obj['CKA_LABEL'])
95 ++ print('!'*74)
96 + else:
97 +- print "Ignoring certificate %s. SAUTH=%s, EPROT=%s" % \
98 ++ print("Ignoring certificate %s. SAUTH=%s, EPROT=%s" % \
99 + (obj['CKA_LABEL'], obj['CKA_TRUST_SERVER_AUTH'],
100 +- obj['CKA_TRUST_EMAIL_PROTECTION'])
101 ++ obj['CKA_TRUST_EMAIL_PROTECTION']))
102 +
103 + for obj in objects:
104 + if obj['CKA_CLASS'] == 'CKO_CERTIFICATE':
105 +@@ -121,13 +121,19 @@ for obj in objects:
106 + .replace('(', '=')\
107 + .replace(')', '=')\
108 + .replace(',', '_')
109 +- bname = bname.decode('string_escape')
110 ++
111 ++ # this is the only way to decode the way NSS stores multi-byte UTF-8
112 ++ if bytes != str:
113 ++ bname = bname.encode('utf-8')
114 ++ bname = bname.decode('unicode_escape').encode('latin-1').decode('utf-8')
115 + fname = bname + '.crt'
116 ++
117 + if os.path.exists(fname):
118 +- print "Found duplicate certificate name %s, renaming." % bname
119 ++ print("Found duplicate certificate name %s, renaming." % bname)
120 + fname = bname + '_2.crt'
121 + f = open(fname, 'w')
122 + f.write("-----BEGIN CERTIFICATE-----\n")
123 +- f.write("\n".join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))
124 ++ encoded = base64.b64encode(obj['CKA_VALUE']).decode('utf-8')
125 ++ f.write("\n".join(textwrap.wrap(encoded, 64)))
126 + f.write("\n-----END CERTIFICATE-----\n")
127 +