Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-devel/clang/, sys-devel/clang/files/12.0.0/
Date: Sat, 17 Apr 2021 06:23:09
Message-Id: 1618638796.e423501d8ce3971dff16dd52e35bd4b55c61117f.mgorny@gentoo
1 commit: e423501d8ce3971dff16dd52e35bd4b55c61117f
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Sat Apr 17 05:53:16 2021 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sat Apr 17 05:53:16 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e423501d
7
8 sys-devel/clang: Backport scan-view fix
9
10 Closes: https://bugs.gentoo.org/783126
11 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
12
13 ...{clang-12.0.0.ebuild => clang-12.0.0-r1.ebuild} | 1 +
14 sys-devel/clang/files/12.0.0/readd-reporter.patch | 200 +++++++++++++++++++++
15 2 files changed, 201 insertions(+)
16
17 diff --git a/sys-devel/clang/clang-12.0.0.ebuild b/sys-devel/clang/clang-12.0.0-r1.ebuild
18 similarity index 99%
19 rename from sys-devel/clang/clang-12.0.0.ebuild
20 rename to sys-devel/clang/clang-12.0.0-r1.ebuild
21 index 5feec724ffc..100f9a26b26 100644
22 --- a/sys-devel/clang/clang-12.0.0.ebuild
23 +++ b/sys-devel/clang/clang-12.0.0-r1.ebuild
24 @@ -77,6 +77,7 @@ llvm.org_set_globals
25 # multilib clang* libraries (not runtime, not wrappers).
26
27 PATCHES=(
28 + "${FILESDIR}"/12.0.0/readd-reporter.patch
29 "${FILESDIR}"/9999/prefix-dirs.patch
30 )
31
32
33 diff --git a/sys-devel/clang/files/12.0.0/readd-reporter.patch b/sys-devel/clang/files/12.0.0/readd-reporter.patch
34 new file mode 100644
35 index 00000000000..5f3f1646943
36 --- /dev/null
37 +++ b/sys-devel/clang/files/12.0.0/readd-reporter.patch
38 @@ -0,0 +1,200 @@
39 +diff --git a/clang/tools/scan-view/CMakeLists.txt b/clang/tools/scan-view/CMakeLists.txt
40 +--- a/clang/tools/scan-view/CMakeLists.txt
41 ++++ b/clang/tools/scan-view/CMakeLists.txt
42 +@@ -5,6 +5,7 @@
43 +
44 + set(ShareFiles
45 + ScanView.py
46 ++ Reporter.py
47 + startfile.py
48 + bugcatcher.ico)
49 +
50 +diff --git a/clang/tools/scan-view/share/Reporter.py b/clang/tools/scan-view/share/Reporter.py
51 +new file mode 100644
52 +--- /dev/null
53 ++++ b/clang/tools/scan-view/share/Reporter.py
54 +@@ -0,0 +1,183 @@
55 ++#!/usr/bin/env python
56 ++# -*- coding: utf-8 -*-
57 ++
58 ++"""Methods for reporting bugs."""
59 ++
60 ++import subprocess, sys, os
61 ++
62 ++__all__ = ['ReportFailure', 'BugReport', 'getReporters']
63 ++
64 ++#
65 ++
66 ++class ReportFailure(Exception):
67 ++ """Generic exception for failures in bug reporting."""
68 ++ def __init__(self, value):
69 ++ self.value = value
70 ++
71 ++# Collect information about a bug.
72 ++
73 ++class BugReport(object):
74 ++ def __init__(self, title, description, files):
75 ++ self.title = title
76 ++ self.description = description
77 ++ self.files = files
78 ++
79 ++# Reporter interfaces.
80 ++
81 ++import os
82 ++
83 ++import email, mimetypes, smtplib
84 ++from email import encoders
85 ++from email.message import Message
86 ++from email.mime.base import MIMEBase
87 ++from email.mime.multipart import MIMEMultipart
88 ++from email.mime.text import MIMEText
89 ++
90 ++#===------------------------------------------------------------------------===#
91 ++# ReporterParameter
92 ++#===------------------------------------------------------------------------===#
93 ++
94 ++class ReporterParameter(object):
95 ++ def __init__(self, n):
96 ++ self.name = n
97 ++ def getName(self):
98 ++ return self.name
99 ++ def getValue(self,r,bugtype,getConfigOption):
100 ++ return getConfigOption(r.getName(),self.getName())
101 ++ def saveConfigValue(self):
102 ++ return True
103 ++
104 ++class TextParameter (ReporterParameter):
105 ++ def getHTML(self,r,bugtype,getConfigOption):
106 ++ return """\
107 ++<tr>
108 ++<td class="form_clabel">%s:</td>
109 ++<td class="form_value"><input type="text" name="%s_%s" value="%s"></td>
110 ++</tr>"""%(self.getName(),r.getName(),self.getName(),self.getValue(r,bugtype,getConfigOption))
111 ++
112 ++class SelectionParameter (ReporterParameter):
113 ++ def __init__(self, n, values):
114 ++ ReporterParameter.__init__(self,n)
115 ++ self.values = values
116 ++
117 ++ def getHTML(self,r,bugtype,getConfigOption):
118 ++ default = self.getValue(r,bugtype,getConfigOption)
119 ++ return """\
120 ++<tr>
121 ++<td class="form_clabel">%s:</td><td class="form_value"><select name="%s_%s">
122 ++%s
123 ++</select></td>"""%(self.getName(),r.getName(),self.getName(),'\n'.join(["""\
124 ++<option value="%s"%s>%s</option>"""%(o[0],
125 ++ o[0] == default and ' selected="selected"' or '',
126 ++ o[1]) for o in self.values]))
127 ++
128 ++#===------------------------------------------------------------------------===#
129 ++# Reporters
130 ++#===------------------------------------------------------------------------===#
131 ++
132 ++class EmailReporter(object):
133 ++ def getName(self):
134 ++ return 'Email'
135 ++
136 ++ def getParameters(self):
137 ++ return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP Port']]
138 ++
139 ++ # Lifted from python email module examples.
140 ++ def attachFile(self, outer, path):
141 ++ # Guess the content type based on the file's extension. Encoding
142 ++ # will be ignored, although we should check for simple things like
143 ++ # gzip'd or compressed files.
144 ++ ctype, encoding = mimetypes.guess_type(path)
145 ++ if ctype is None or encoding is not None:
146 ++ # No guess could be made, or the file is encoded (compressed), so
147 ++ # use a generic bag-of-bits type.
148 ++ ctype = 'application/octet-stream'
149 ++ maintype, subtype = ctype.split('/', 1)
150 ++ if maintype == 'text':
151 ++ fp = open(path)
152 ++ # Note: we should handle calculating the charset
153 ++ msg = MIMEText(fp.read(), _subtype=subtype)
154 ++ fp.close()
155 ++ else:
156 ++ fp = open(path, 'rb')
157 ++ msg = MIMEBase(maintype, subtype)
158 ++ msg.set_payload(fp.read())
159 ++ fp.close()
160 ++ # Encode the payload using Base64
161 ++ encoders.encode_base64(msg)
162 ++ # Set the filename parameter
163 ++ msg.add_header('Content-Disposition', 'attachment', filename=os.path.basename(path))
164 ++ outer.attach(msg)
165 ++
166 ++ def fileReport(self, report, parameters):
167 ++ mainMsg = """\
168 ++BUG REPORT
169 ++---
170 ++Title: %s
171 ++Description: %s
172 ++"""%(report.title, report.description)
173 ++
174 ++ if not parameters.get('To'):
175 ++ raise ReportFailure('No "To" address specified.')
176 ++ if not parameters.get('From'):
177 ++ raise ReportFailure('No "From" address specified.')
178 ++
179 ++ msg = MIMEMultipart()
180 ++ msg['Subject'] = 'BUG REPORT: %s'%(report.title)
181 ++ # FIXME: Get config parameters
182 ++ msg['To'] = parameters.get('To')
183 ++ msg['From'] = parameters.get('From')
184 ++ msg.preamble = mainMsg
185 ++
186 ++ msg.attach(MIMEText(mainMsg, _subtype='text/plain'))
187 ++ for file in report.files:
188 ++ self.attachFile(msg, file)
189 ++
190 ++ try:
191 ++ s = smtplib.SMTP(host=parameters.get('SMTP Server'),
192 ++ port=parameters.get('SMTP Port'))
193 ++ s.sendmail(msg['From'], msg['To'], msg.as_string())
194 ++ s.close()
195 ++ except:
196 ++ raise ReportFailure('Unable to send message via SMTP.')
197 ++
198 ++ return "Message sent!"
199 ++
200 ++class BugzillaReporter(object):
201 ++ def getName(self):
202 ++ return 'Bugzilla'
203 ++
204 ++ def getParameters(self):
205 ++ return [TextParameter(x) for x in ['URL','Product']]
206 ++
207 ++ def fileReport(self, report, parameters):
208 ++ raise NotImplementedError
209 ++
210 ++
211 ++class RadarClassificationParameter(SelectionParameter):
212 ++ def __init__(self):
213 ++ SelectionParameter.__init__(self,"Classification",
214 ++ [['1', 'Security'], ['2', 'Crash/Hang/Data Loss'],
215 ++ ['3', 'Performance'], ['4', 'UI/Usability'],
216 ++ ['6', 'Serious Bug'], ['7', 'Other']])
217 ++
218 ++ def saveConfigValue(self):
219 ++ return False
220 ++
221 ++ def getValue(self,r,bugtype,getConfigOption):
222 ++ if bugtype.find("leak") != -1:
223 ++ return '3'
224 ++ elif bugtype.find("dereference") != -1:
225 ++ return '2'
226 ++ elif bugtype.find("missing ivar release") != -1:
227 ++ return '3'
228 ++ else:
229 ++ return '7'
230 ++
231 ++###
232 ++
233 ++def getReporters():
234 ++ reporters = []
235 ++ reporters.append(EmailReporter())
236 ++ return reporters
237 ++
238 +