summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-17 23:31:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-18 16:19:34 +0000
commit739c420caa13bd87df6fd27bf69fb8be871a9e50 (patch)
tree0264696c94b00591982e61edc31cffc584873b39 /meta
parente4e0445431d64ba4ed9c59086791f189d218191b (diff)
downloadpoky-739c420caa13bd87df6fd27bf69fb8be871a9e50.tar.gz
distrodata: Remove
The code in the tasks within this class are old and there are much better ways to do these things now such as through tinfoil rather than writing csv files incrementally with start/stop events and lock files. Existing users of the code (mainly the do_checkpkg task) have been ported over to tinfoil. Drop the class, any other users should also make use of the tinfoil functionality. (From OE-Core rev: 6e2a488f01e5e8bc6f06b6fac1d336bf5372a82b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/distrodata.bbclass425
1 files changed, 0 insertions, 425 deletions
diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass
deleted file mode 100644
index 7712c8e40d..0000000000
--- a/meta/classes/distrodata.bbclass
+++ /dev/null
@@ -1,425 +0,0 @@
1include conf/distro/include/distro_alias.inc
2
3addhandler distro_eventhandler
4distro_eventhandler[eventmask] = "bb.event.BuildStarted"
5python distro_eventhandler() {
6 import oe.distro_check as dc
7 import csv
8 logfile = dc.create_log_file(e.data, "distrodata.csv")
9
10 lf = bb.utils.lockfile("%s.lock" % logfile)
11 with open(logfile, "a") as f:
12 writer = csv.writer(f)
13 writer.writerow(['Package', 'Description', 'Owner', 'License',
14 'VerMatch', 'Version', 'Upstream', 'Reason', 'Recipe Status',
15 'Distro 1', 'Distro 2', 'Distro 3'])
16 f.close()
17 bb.utils.unlockfile(lf)
18
19 return
20}
21
22addtask distrodata_np
23do_distrodata_np[nostamp] = "1"
24python do_distrodata_np() {
25 localdata = bb.data.createCopy(d)
26 pn = d.getVar("PN")
27 bb.note("Package Name: %s" % pn)
28
29 import oe.distro_check as dist_check
30 tmpdir = d.getVar('TMPDIR')
31 distro_check_dir = os.path.join(tmpdir, "distro_check")
32 datetime = localdata.getVar('DATETIME')
33 dist_check.update_distro_data(distro_check_dir, datetime, localdata)
34
35 if pn.find("-native") != -1:
36 pnstripped = pn.split("-native")
37 bb.note("Native Split: %s" % pnstripped)
38 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
39
40 if pn.find("-cross") != -1:
41 pnstripped = pn.split("-cross")
42 bb.note("cross Split: %s" % pnstripped)
43 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
44
45 if pn.find("-crosssdk") != -1:
46 pnstripped = pn.split("-crosssdk")
47 bb.note("cross Split: %s" % pnstripped)
48 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
49
50 if pn.startswith("nativesdk-"):
51 pnstripped = pn.replace("nativesdk-", "")
52 bb.note("NativeSDK Split: %s" % pnstripped)
53 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
54
55
56 if pn.find("-initial") != -1:
57 pnstripped = pn.split("-initial")
58 bb.note("initial Split: %s" % pnstripped)
59 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
60
61 """generate package information from .bb file"""
62 pname = localdata.getVar('PN')
63 pcurver = localdata.getVar('PV')
64 pdesc = localdata.getVar('DESCRIPTION')
65 if pdesc is not None:
66 pdesc = pdesc.replace(',','')
67 pdesc = pdesc.replace('\n','')
68
69 pgrp = localdata.getVar('SECTION')
70 plicense = localdata.getVar('LICENSE').replace(',','_')
71
72 rstatus = localdata.getVar('RECIPE_COLOR')
73 if rstatus is not None:
74 rstatus = rstatus.replace(',','')
75
76 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION')
77 if pcurver == pupver:
78 vermatch="1"
79 else:
80 vermatch="0"
81 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON')
82 if noupdate_reason is None:
83 noupdate="0"
84 else:
85 noupdate="1"
86 noupdate_reason = noupdate_reason.replace(',','')
87
88 maintainer = localdata.getVar('RECIPE_MAINTAINER')
89 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE')
90 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
91
92 bb.note("DISTRO: %s,%s,%s,%s,%s,%s,%s,%s,%s\n" % \
93 (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus))
94 line = pn
95 for i in result:
96 line = line + "," + i
97 bb.note("%s\n" % line)
98}
99do_distrodata_np[vardepsexclude] = "DATETIME"
100
101addtask distrodata
102do_distrodata[nostamp] = "1"
103python do_distrodata() {
104 import csv
105 logpath = d.getVar('LOG_DIR')
106 bb.utils.mkdirhier(logpath)
107 logfile = os.path.join(logpath, "distrodata.csv")
108
109 import oe.distro_check as dist_check
110 localdata = bb.data.createCopy(d)
111 tmpdir = d.getVar('TMPDIR')
112 distro_check_dir = os.path.join(tmpdir, "distro_check")
113 datetime = localdata.getVar('DATETIME')
114 dist_check.update_distro_data(distro_check_dir, datetime, localdata)
115
116 pn = d.getVar("PN")
117 bb.note("Package Name: %s" % pn)
118
119 if pn.find("-native") != -1:
120 pnstripped = pn.split("-native")
121 bb.note("Native Split: %s" % pnstripped)
122 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
123
124 if pn.startswith("nativesdk-"):
125 pnstripped = pn.replace("nativesdk-", "")
126 bb.note("NativeSDK Split: %s" % pnstripped)
127 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
128
129 if pn.find("-cross") != -1:
130 pnstripped = pn.split("-cross")
131 bb.note("cross Split: %s" % pnstripped)
132 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
133
134 if pn.find("-crosssdk") != -1:
135 pnstripped = pn.split("-crosssdk")
136 bb.note("cross Split: %s" % pnstripped)
137 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
138
139 if pn.find("-initial") != -1:
140 pnstripped = pn.split("-initial")
141 bb.note("initial Split: %s" % pnstripped)
142 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
143
144 """generate package information from .bb file"""
145 pname = localdata.getVar('PN')
146 pcurver = localdata.getVar('PV')
147 pdesc = localdata.getVar('DESCRIPTION')
148 if pdesc is not None:
149 pdesc = pdesc.replace(',','')
150 pdesc = pdesc.replace('\n','')
151
152 pgrp = localdata.getVar('SECTION')
153 plicense = localdata.getVar('LICENSE').replace(',','_')
154
155 rstatus = localdata.getVar('RECIPE_COLOR')
156 if rstatus is not None:
157 rstatus = rstatus.replace(',','')
158
159 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION')
160 if pcurver == pupver:
161 vermatch="1"
162 else:
163 vermatch="0"
164
165 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON')
166 if noupdate_reason is None:
167 noupdate="0"
168 else:
169 noupdate="1"
170 noupdate_reason = noupdate_reason.replace(',','')
171
172 maintainer = localdata.getVar('RECIPE_MAINTAINER')
173 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE')
174 # do the comparison
175 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
176
177 lf = bb.utils.lockfile("%s.lock" % logfile)
178 with open(logfile, "a") as f:
179 row = [pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus]
180 row.extend(result)
181
182 writer = csv.writer(f)
183 writer.writerow(row)
184 f.close()
185 bb.utils.unlockfile(lf)
186}
187do_distrodata[vardepsexclude] = "DATETIME"
188
189addhandler checkpkg_eventhandler
190checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted"
191python checkpkg_eventhandler() {
192 import csv
193
194 def parse_csv_file(filename):
195 package_dict = {}
196
197 with open(filename, "r") as f:
198 reader = csv.reader(f, delimiter='\t')
199 for row in reader:
200 pn = row[0]
201
202 if reader.line_num == 1:
203 header = row
204 continue
205
206 if not pn in package_dict.keys():
207 package_dict[pn] = row
208 f.close()
209
210 with open(filename, "w") as f:
211 writer = csv.writer(f, delimiter='\t')
212 writer.writerow(header)
213 for pn in package_dict.keys():
214 writer.writerow(package_dict[pn])
215 f.close()
216
217 del package_dict
218
219 if bb.event.getName(e) == "BuildStarted":
220 import oe.distro_check as dc
221 logfile = dc.create_log_file(e.data, "checkpkg.csv")
222
223 lf = bb.utils.lockfile("%s.lock" % logfile)
224 with open(logfile, "a") as f:
225 writer = csv.writer(f, delimiter='\t')
226 headers = ['Package', 'Version', 'Upver', 'License', 'Section',
227 'Home', 'Release', 'Depends', 'BugTracker', 'PE', 'Description',
228 'Status', 'Tracking', 'URI', 'MAINTAINER', 'NoUpReason']
229 writer.writerow(headers)
230 f.close()
231 bb.utils.unlockfile(lf)
232 elif bb.event.getName(e) == "BuildCompleted":
233 import os
234 filename = "tmp/log/checkpkg.csv"
235 if os.path.isfile(filename):
236 lf = bb.utils.lockfile("%s.lock"%filename)
237 parse_csv_file(filename)
238 bb.utils.unlockfile(lf)
239 return
240}
241
242addtask checkpkg
243do_checkpkg[nostamp] = "1"
244python do_checkpkg() {
245 localdata = bb.data.createCopy(d)
246 import csv
247 import re
248 import tempfile
249 import subprocess
250 import oe.recipeutils
251 from bb.utils import vercmp_string
252 from bb.fetch2 import FetchError, NoMethodError, decodeurl
253
254 def get_upstream_version_and_status():
255
256 # set if the upstream check fails reliably, e.g. absent git tags, or weird version format used on our or on upstream side.
257 upstream_version_unknown = localdata.getVar('UPSTREAM_VERSION_UNKNOWN')
258 # set if the upstream check cannot be reliably performed due to transient network failures, or server behaving weirdly.
259 # This one should be used sparingly, as it completely excludes a recipe from upstream checking.
260 upstream_check_unreliable = localdata.getVar('UPSTREAM_CHECK_UNRELIABLE')
261
262 if upstream_check_unreliable == "1":
263 return "N/A", "CHECK_IS_UNRELIABLE"
264
265 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
266 pupver = uv['version'] if uv['version'] else "N/A"
267 pversion = uv['current_version']
268 revision = uv['revision'] if uv['revision'] else "N/A"
269
270 if pupver == "N/A":
271 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
272 else:
273 cmp = vercmp_string(pversion, pupver)
274 if cmp == -1:
275 pstatus = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN"
276 elif cmp == 0:
277 pstatus = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN"
278 else:
279 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
280
281 return pversion, pupver, pstatus, revision
282
283
284 """initialize log files."""
285 logpath = d.getVar('LOG_DIR')
286 bb.utils.mkdirhier(logpath)
287 logfile = os.path.join(logpath, "checkpkg.csv")
288
289 """generate package information from .bb file"""
290 pname = d.getVar('PN')
291
292 if pname.find("-native") != -1:
293 if d.getVar('BBCLASSEXTEND'):
294 return
295 pnstripped = pname.split("-native")
296 bb.note("Native Split: %s" % pnstripped)
297 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
298
299 if pname.startswith("nativesdk-"):
300 if d.getVar('BBCLASSEXTEND'):
301 return
302 pnstripped = pname.replace("nativesdk-", "")
303 bb.note("NativeSDK Split: %s" % pnstripped)
304 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
305
306 if pname.find("-cross") != -1:
307 pnstripped = pname.split("-cross")
308 bb.note("cross Split: %s" % pnstripped)
309 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
310
311 if pname.find("-initial") != -1:
312 pnstripped = pname.split("-initial")
313 bb.note("initial Split: %s" % pnstripped)
314 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
315
316 pdesc = localdata.getVar('DESCRIPTION')
317 pgrp = localdata.getVar('SECTION')
318 plicense = localdata.getVar('LICENSE')
319 psection = localdata.getVar('SECTION')
320 phome = localdata.getVar('HOMEPAGE')
321 prelease = localdata.getVar('PR')
322 pdepends = localdata.getVar('DEPENDS')
323 pbugtracker = localdata.getVar('BUGTRACKER')
324 ppe = localdata.getVar('PE')
325 psrcuri = localdata.getVar('SRC_URI')
326 maintainer = localdata.getVar('RECIPE_MAINTAINER')
327
328 pversion, pupver, pstatus, prevision = get_upstream_version_and_status()
329
330 if psrcuri:
331 psrcuri = psrcuri.split()[0]
332 else:
333 psrcuri = "none"
334 pdepends = "".join(pdepends.split("\t"))
335 pdesc = "".join(pdesc.split("\t"))
336 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON')
337 lf = bb.utils.lockfile("%s.lock" % logfile)
338 with open(logfile, "a") as f:
339 writer = csv.writer(f, delimiter='\t')
340 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
341 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, prevision,
342 psrcuri, maintainer, no_upgr_reason])
343 f.close()
344 bb.utils.unlockfile(lf)
345}
346
347addhandler distro_check_eventhandler
348distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
349python distro_check_eventhandler() {
350 """initialize log files."""
351 import oe.distro_check as dc
352 result_file = dc.create_log_file(e.data, "distrocheck.csv")
353 return
354}
355
356addtask distro_check
357do_distro_check[nostamp] = "1"
358do_distro_check[vardepsexclude] += "DATETIME"
359python do_distro_check() {
360 """checks if the package is present in other public Linux distros"""
361 import oe.distro_check as dc
362 import shutil
363 if bb.data.inherits_class('native', d) or bb.data.inherits_class('cross', d) or bb.data.inherits_class('sdk', d) or bb.data.inherits_class('crosssdk', d) or bb.data.inherits_class('nativesdk',d):
364 return
365
366 localdata = bb.data.createCopy(d)
367 tmpdir = d.getVar('TMPDIR')
368 distro_check_dir = os.path.join(tmpdir, "distro_check")
369 logpath = d.getVar('LOG_DIR')
370 bb.utils.mkdirhier(logpath)
371 result_file = os.path.join(logpath, "distrocheck.csv")
372 datetime = localdata.getVar('DATETIME')
373 dc.update_distro_data(distro_check_dir, datetime, localdata)
374
375 # do the comparison
376 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
377
378 # save the results
379 dc.save_distro_check_result(result, datetime, result_file, d)
380}
381
382#
383#Check Missing License Text.
384#Use this task to generate the missing license text data for pkg-report system,
385#then we can search those recipes which license text isn't exsit in common-licenses directory
386#
387addhandler checklicense_eventhandler
388checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
389python checklicense_eventhandler() {
390 """initialize log files."""
391 import csv
392 import oe.distro_check as dc
393 logfile = dc.create_log_file(e.data, "missinglicense.csv")
394 lf = bb.utils.lockfile("%s.lock" % logfile)
395 with open(logfile, "a") as f:
396 writer = csv.writer(f, delimiter='\t')
397 writer.writerow(['Package', 'License', 'MissingLicense'])
398 f.close()
399 bb.utils.unlockfile(lf)
400 return
401}
402
403addtask checklicense
404do_checklicense[nostamp] = "1"
405python do_checklicense() {
406 import csv
407 import shutil
408 logpath = d.getVar('LOG_DIR')
409 bb.utils.mkdirhier(logpath)
410 pn = d.getVar('PN')
411 logfile = os.path.join(logpath, "missinglicense.csv")
412 generic_directory = d.getVar('COMMON_LICENSE_DIR')
413 license_types = d.getVar('LICENSE')
414 for license_type in ((license_types.replace('+', '').replace('|', '&')
415 .replace('(', '').replace(')', '').replace(';', '')
416 .replace(',', '').replace(" ", "").split("&"))):
417 if not os.path.isfile(os.path.join(generic_directory, license_type)):
418 lf = bb.utils.lockfile("%s.lock" % logfile)
419 with open(logfile, "a") as f:
420 writer = csv.writer(f, delimiter='\t')
421 writer.writerow([pn, license_types, license_type])
422 f.close()
423 bb.utils.unlockfile(lf)
424 return
425}