1 |
commit: fc2ed88084be5fa1595ab7562f1eb6ef8475e5b6 |
2 |
Author: Paul Healy <lmiphay <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Aug 31 09:10:39 2020 +0000 |
4 |
Commit: Aaron Bauman <bman <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Aug 31 17:15:47 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc2ed880 |
7 |
|
8 |
app-admin/syslog-summary: port to py3 |
9 |
|
10 |
Backport upstream py3 PR https://github.com/dpaleino/syslog-summary/pull/4 |
11 |
Remove py2 support |
12 |
|
13 |
Bug: https://bugs.gentoo.org/735202 |
14 |
Signed-off-by: Paul Healy <lmiphay <AT> gmail.com> |
15 |
Signed-off-by: Aaron Bauman <bman <AT> gentoo.org> |
16 |
|
17 |
.../files/syslog-summary-1.14-py3.patch | 142 +++++++++++++++++++++ |
18 |
.../syslog-summary/syslog-summary-1.14-r5.ebuild | 46 +++++++ |
19 |
2 files changed, 188 insertions(+) |
20 |
|
21 |
diff --git a/app-admin/syslog-summary/files/syslog-summary-1.14-py3.patch b/app-admin/syslog-summary/files/syslog-summary-1.14-py3.patch |
22 |
new file mode 100644 |
23 |
index 00000000000..945c7ce290b |
24 |
--- /dev/null |
25 |
+++ b/app-admin/syslog-summary/files/syslog-summary-1.14-py3.patch |
26 |
@@ -0,0 +1,142 @@ |
27 |
+diff --git a/syslog-summary b/syslog-summary |
28 |
+index abf6381..a658c14 100755 |
29 |
+--- a/syslog-summary |
30 |
++++ b/syslog-summary |
31 |
+@@ -35,6 +35,8 @@ Lars Wirzenius <liw@×××.fi> |
32 |
+ Tommi Virtanen <tv@××××××.org> |
33 |
+ David Paleino <d.paleino@×××××.com>""" |
34 |
+ |
35 |
++from __future__ import print_function |
36 |
++ |
37 |
+ version = "1.14" |
38 |
+ |
39 |
+ import sys, re, getopt, string |
40 |
+@@ -62,7 +64,7 @@ def io_error(err, filename, die=True): |
41 |
+ if die: |
42 |
+ traceback.print_exc(file=sys.stderr) |
43 |
+ else: |
44 |
+- print "[E] %s [%s(%s) - %s]" % (os.strerror(num), errno.errorcode[num], num, filename) |
45 |
++ print("[E] %s [%s(%s) - %s]" % (os.strerror(num), errno.errorcode[num], num, filename)) |
46 |
+ |
47 |
+ if die: |
48 |
+ sys.exit(1) |
49 |
+@@ -72,7 +74,7 @@ def read_patterns(filename): |
50 |
+ pats = [] |
51 |
+ try: |
52 |
+ f = open(filename, "r") |
53 |
+- except IOError, e: |
54 |
++ except IOError as e: |
55 |
+ io_error(e, filename, False) |
56 |
+ return [] |
57 |
+ for line in f: |
58 |
+@@ -91,7 +93,7 @@ def read_states(filename): |
59 |
+ return states |
60 |
+ try: |
61 |
+ f = open(filename, "r") |
62 |
+- except IOError, e: |
63 |
++ except IOError as e: |
64 |
+ io_error(e, filename, False) |
65 |
+ return states |
66 |
+ for line in f: |
67 |
+@@ -105,9 +107,9 @@ def save_states(filename, states): |
68 |
+ return |
69 |
+ try: |
70 |
+ f = open(filename, "w") |
71 |
+- except IOError, e: |
72 |
++ except IOError as e: |
73 |
+ io_error(e, filename, True) |
74 |
+- for filename in states.keys(): |
75 |
++ for filename in list(states.keys()): |
76 |
+ value = states[filename] |
77 |
+ f.write("%s %d %s\n" % (filename, value[0], value[1])) |
78 |
+ f.close() |
79 |
+@@ -123,7 +125,7 @@ def split_date(line): |
80 |
+ m = pat.match(line) |
81 |
+ if m: |
82 |
+ return line[:m.end()], line[m.end():] |
83 |
+- print "line has bad date", "<" + string.rstrip(line) + ">" |
84 |
++ print("line has bad date", "<" + string.rstrip(line) + ">") |
85 |
+ return None, line |
86 |
+ |
87 |
+ def is_gzipped(filename): |
88 |
+@@ -152,7 +154,7 @@ def summarize(filename, states): |
89 |
+ order = [] |
90 |
+ ignored_count = 0 |
91 |
+ if not QUIET: |
92 |
+- print "Summarizing %s" % filename |
93 |
++ print("Summarizing %s" % filename) |
94 |
+ |
95 |
+ # If the file is a gzipped log, open it |
96 |
+ # using the proper function from the gzip |
97 |
+@@ -162,7 +164,7 @@ def summarize(filename, states): |
98 |
+ file = gzopen(filename, "rb") |
99 |
+ else: |
100 |
+ file = open(filename, "r") |
101 |
+- except IOError, e: |
102 |
++ except IOError as e: |
103 |
+ io_error(e, filename, True) |
104 |
+ |
105 |
+ linecount = 0 |
106 |
+@@ -170,7 +172,7 @@ def summarize(filename, states): |
107 |
+ shaobj = sha1() |
108 |
+ if filename in states: |
109 |
+ oldlines, oldsha = states[filename] |
110 |
+- for i in xrange(oldlines): |
111 |
++ for i in range(oldlines): |
112 |
+ line = file.readline() |
113 |
+ shaobj.update(line) |
114 |
+ # print "OLD-new: %s" % shaobj.hexdigest() |
115 |
+@@ -182,7 +184,7 @@ def summarize(filename, states): |
116 |
+ else: |
117 |
+ linecount = oldlines |
118 |
+ if not QUIET: |
119 |
+- print "%8d Lines skipped (already processed)" % linecount |
120 |
++ print("%8d Lines skipped (already processed)" % linecount) |
121 |
+ |
122 |
+ line = file.readline() |
123 |
+ previous = None |
124 |
+@@ -190,13 +192,13 @@ def summarize(filename, states): |
125 |
+ foo=0 |
126 |
+ while line: |
127 |
+ # foo+=1 |
128 |
+- shaobj.update(line) |
129 |
++ shaobj.update(line.encode()) |
130 |
+ linecount += 1 |
131 |
+ |
132 |
+ if should_be_ignored(line): |
133 |
+ ignored_count += 1 |
134 |
+ if DEBUG: |
135 |
+- print "Ignoring: %s" % line |
136 |
++ print("Ignoring: %s" % line) |
137 |
+ line = file.readline() |
138 |
+ |
139 |
+ date, rest = split_date(line) |
140 |
+@@ -213,7 +215,7 @@ def summarize(filename, states): |
141 |
+ count = int(repeated.group(1)) |
142 |
+ rest = previous |
143 |
+ |
144 |
+- if counts.has_key(rest): |
145 |
++ if rest in counts: |
146 |
+ counts[rest] = counts[rest] + count |
147 |
+ else: |
148 |
+ assert count == 1 |
149 |
+@@ -233,14 +235,14 @@ def summarize(filename, states): |
150 |
+ # print states |
151 |
+ |
152 |
+ if QUIET and order: |
153 |
+- print "Summarizing %s" % filename |
154 |
++ print("Summarizing %s" % filename) |
155 |
+ if not QUIET or order: |
156 |
+- print "%8d Patterns to ignore" % len(ignore_pats) |
157 |
+- print "%8d Ignored lines" % ignored_count |
158 |
++ print("%8d Patterns to ignore" % len(ignore_pats)) |
159 |
++ print("%8d Ignored lines" % ignored_count) |
160 |
+ for rest in order: |
161 |
+- print "%8d %s" % (counts[rest], rest), |
162 |
++ print("%8d %s" % (counts[rest], rest), end='') |
163 |
+ if not QUIET or order: |
164 |
+- print |
165 |
++ print() |
166 |
+ |
167 |
+ def main(): |
168 |
+ global ignore_pats, IGNORE_FILENAME, STATE_FILENAME, REPEAT, QUIET, DEBUG |
169 |
|
170 |
diff --git a/app-admin/syslog-summary/syslog-summary-1.14-r5.ebuild b/app-admin/syslog-summary/syslog-summary-1.14-r5.ebuild |
171 |
new file mode 100644 |
172 |
index 00000000000..e34fa9528f0 |
173 |
--- /dev/null |
174 |
+++ b/app-admin/syslog-summary/syslog-summary-1.14-r5.ebuild |
175 |
@@ -0,0 +1,46 @@ |
176 |
+# Copyright 1999-2020 Gentoo Authors |
177 |
+# Distributed under the terms of the GNU General Public License v2 |
178 |
+ |
179 |
+EAPI=7 |
180 |
+ |
181 |
+PYTHON_COMPAT=( python3_{7,8} ) |
182 |
+ |
183 |
+inherit python-single-r1 |
184 |
+ |
185 |
+DESCRIPTION="Summarizes the contents of a syslog log file" |
186 |
+HOMEPAGE="https://github.com/dpaleino/syslog-summary" |
187 |
+SRC_URI="https://github.com/downloads/dpaleino/${PN}/${P}.tar.gz" |
188 |
+ |
189 |
+LICENSE="GPL-3+" |
190 |
+SLOT="0" |
191 |
+KEYWORDS="~amd64 ~sparc ~x86" |
192 |
+IUSE="" |
193 |
+ |
194 |
+REQUIRED_USE="${PYTHON_REQUIRED_USE}" |
195 |
+ |
196 |
+DEPEND="" |
197 |
+RDEPEND="${PYTHON_DEPS}" |
198 |
+ |
199 |
+PATCHES=( \ |
200 |
+ "${FILESDIR}/${P}-fix-ignore-code.patch" \ |
201 |
+ "${FILESDIR}/${P}-remove-file-magic.patch" \ |
202 |
+ "${FILESDIR}/${P}-py3.patch" \ |
203 |
+ ) |
204 |
+ |
205 |
+src_prepare() { |
206 |
+ python_fix_shebang -f syslog-summary |
207 |
+ |
208 |
+ # Sadly, the makefile is useless for us. |
209 |
+ rm Makefile || die |
210 |
+ |
211 |
+ default |
212 |
+} |
213 |
+ |
214 |
+src_install() { |
215 |
+ dobin syslog-summary |
216 |
+ einstalldocs |
217 |
+ doman syslog-summary.1 |
218 |
+ |
219 |
+ insinto /etc/syslog-summary |
220 |
+ doins ignore.rules |
221 |
+} |