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/
Date: Tue, 29 Sep 2015 00:39:00
Message-Id: 1443487118.751d0f79973aa5c2918b386e814aa3eda17df27b.vapier@gentoo
1 commit: 751d0f79973aa5c2918b386e814aa3eda17df27b
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Tue Sep 29 00:37:37 2015 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Tue Sep 29 00:38:38 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=751d0f79
7
8 app-misc/ca-certificates: rework py3 patch a bit more #561586
9
10 Rework some of the codec logic to make sure we can read files when
11 in a non-UTF8 locale (like LANG=C), and it works w/py2.7 and py3.4.
12
13 ...certificates-20150426-nss-certdata2pem-py3.patch | 21 ++++++++++++++++++---
14 1 file changed, 18 insertions(+), 3 deletions(-)
15
16 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
17 index 300ce47..d639aef 100644
18 --- a/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
19 +++ b/app-misc/ca-certificates/files/ca-certificates-20150426-nss-certdata2pem-py3.patch
20 @@ -3,6 +3,19 @@ https://bugs.gentoo.org/548374
21
22 --- a/ca-certificates/mozilla/certdata2pem.py
23 +++ b/ca-certificates/mozilla/certdata2pem.py
24 +@@ -31,7 +31,11 @@ objects = []
25 + # Dirty file parser.
26 + in_data, in_multiline, in_obj = False, False, False
27 + field, type, value, obj = None, None, None, dict()
28 +-for line in open('certdata.txt', 'r'):
29 ++try:
30 ++ f = open('certdata.txt', 'r', encoding='utf-8')
31 ++except TypeError:
32 ++ f = open('certdata.txt', 'r')
33 ++for line in f:
34 + # Ignore the file header.
35 + if not in_data:
36 + if line.startswith('BEGINDATA'):
37 @@ -53,7 +53,7 @@ for line in open('certdata.txt', 'r'):
38 if type == 'MULTILINE_OCTAL':
39 line = line.strip()
40 @@ -62,17 +75,19 @@ https://bugs.gentoo.org/548374
41 .replace(')', '=')\
42 .replace(',', '_')
43 - bname = bname.decode('string_escape')
44 +- fname = bname + '.crt'
45 +
46 + # this is the only way to decode the way NSS stores multi-byte UTF-8
47 + if bytes != str:
48 + bname = bname.encode('utf-8')
49 + bname = bname.decode('unicode_escape').encode('latin-1').decode('utf-8')
50 - fname = bname + '.crt'
51 ++ fname = (bname + '.crt').encode('utf-8')
52 +
53 if os.path.exists(fname):
54 - print "Found duplicate certificate name %s, renaming." % bname
55 -+ print("Found duplicate certificate name %s, renaming." % bname)
56 - fname = bname + '_2.crt'
57 +- fname = bname + '_2.crt'
58 ++ print("Found duplicate certificate name %s, renaming." % fname)
59 ++ fname = (bname + '_2.crt').encode('utf-8')
60 f = open(fname, 'w')
61 f.write("-----BEGIN CERTIFICATE-----\n")
62 - f.write("\n".join(textwrap.wrap(base64.b64encode(obj['CKA_VALUE']), 64)))