blob: fbb7402e0ccc9a007faaf294d6159359557f838b [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001include conf/distro/include/upstream_tracking.inc
2include conf/distro/include/distro_alias.inc
3include conf/distro/include/maintainers.inc
4
5addhandler distro_eventhandler
6distro_eventhandler[eventmask] = "bb.event.BuildStarted"
7python distro_eventhandler() {
8 import oe.distro_check as dc
9 import csv
10 logfile = dc.create_log_file(e.data, "distrodata.csv")
11
12 lf = bb.utils.lockfile("%s.lock" % logfile)
13 with open(logfile, "a") as f:
14 writer = csv.writer(f)
15 writer.writerow(['Package', 'Description', 'Owner', 'License',
16 'VerMatch', 'Version', 'Upstream', 'Reason', 'Recipe Status',
17 'Distro 1', 'Distro 2', 'Distro 3'])
18 f.close()
19 bb.utils.unlockfile(lf)
20
21 return
22}
23
24addtask distrodata_np
25do_distrodata_np[nostamp] = "1"
26python do_distrodata_np() {
27 localdata = bb.data.createCopy(d)
28 pn = d.getVar("PN", True)
29 bb.note("Package Name: %s" % pn)
30
31 import oe.distro_check as dist_check
32 tmpdir = d.getVar('TMPDIR', True)
33 distro_check_dir = os.path.join(tmpdir, "distro_check")
34 datetime = localdata.getVar('DATETIME', True)
Patrick Williamsf1e5d692016-03-30 15:21:19 -050035 dist_check.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
37 if pn.find("-native") != -1:
38 pnstripped = pn.split("-native")
39 bb.note("Native Split: %s" % pnstripped)
40 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
41 bb.data.update_data(localdata)
42
43 if pn.find("-cross") != -1:
44 pnstripped = pn.split("-cross")
45 bb.note("cross Split: %s" % pnstripped)
46 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
47 bb.data.update_data(localdata)
48
49 if pn.find("-crosssdk") != -1:
50 pnstripped = pn.split("-crosssdk")
51 bb.note("cross Split: %s" % pnstripped)
52 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
53 bb.data.update_data(localdata)
54
55 if pn.startswith("nativesdk-"):
56 pnstripped = pn.replace("nativesdk-", "")
57 bb.note("NativeSDK Split: %s" % pnstripped)
58 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
59 bb.data.update_data(localdata)
60
61
62 if pn.find("-initial") != -1:
63 pnstripped = pn.split("-initial")
64 bb.note("initial Split: %s" % pnstripped)
65 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
66 bb.data.update_data(localdata)
67
68 """generate package information from .bb file"""
69 pname = localdata.getVar('PN', True)
70 pcurver = localdata.getVar('PV', True)
71 pdesc = localdata.getVar('DESCRIPTION', True)
72 if pdesc is not None:
73 pdesc = pdesc.replace(',','')
74 pdesc = pdesc.replace('\n','')
75
76 pgrp = localdata.getVar('SECTION', True)
77 plicense = localdata.getVar('LICENSE', True).replace(',','_')
78
79 rstatus = localdata.getVar('RECIPE_COLOR', True)
80 if rstatus is not None:
81 rstatus = rstatus.replace(',','')
82
83 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION', True)
84 if pcurver == pupver:
85 vermatch="1"
86 else:
87 vermatch="0"
88 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON', True)
89 if noupdate_reason is None:
90 noupdate="0"
91 else:
92 noupdate="1"
93 noupdate_reason = noupdate_reason.replace(',','')
94
95 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
96 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE', True)
97 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
98
99 bb.note("DISTRO: %s,%s,%s,%s,%s,%s,%s,%s,%s\n" % \
100 (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus))
101 line = pn
102 for i in result:
103 line = line + "," + i
104 bb.note("%s\n" % line)
105}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500106do_distrodata_np[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107
108addtask distrodata
109do_distrodata[nostamp] = "1"
110python do_distrodata() {
111 import csv
112 logpath = d.getVar('LOG_DIR', True)
113 bb.utils.mkdirhier(logpath)
114 logfile = os.path.join(logpath, "distrodata.csv")
115
116 import oe.distro_check as dist_check
117 localdata = bb.data.createCopy(d)
118 tmpdir = d.getVar('TMPDIR', True)
119 distro_check_dir = os.path.join(tmpdir, "distro_check")
120 datetime = localdata.getVar('DATETIME', True)
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500121 dist_check.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122
123 pn = d.getVar("PN", True)
124 bb.note("Package Name: %s" % pn)
125
126 if pn.find("-native") != -1:
127 pnstripped = pn.split("-native")
128 bb.note("Native Split: %s" % pnstripped)
129 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
130 bb.data.update_data(localdata)
131
132 if pn.startswith("nativesdk-"):
133 pnstripped = pn.replace("nativesdk-", "")
134 bb.note("NativeSDK Split: %s" % pnstripped)
135 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
136 bb.data.update_data(localdata)
137
138 if pn.find("-cross") != -1:
139 pnstripped = pn.split("-cross")
140 bb.note("cross Split: %s" % pnstripped)
141 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
142 bb.data.update_data(localdata)
143
144 if pn.find("-crosssdk") != -1:
145 pnstripped = pn.split("-crosssdk")
146 bb.note("cross Split: %s" % pnstripped)
147 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
148 bb.data.update_data(localdata)
149
150 if pn.find("-initial") != -1:
151 pnstripped = pn.split("-initial")
152 bb.note("initial Split: %s" % pnstripped)
153 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
154 bb.data.update_data(localdata)
155
156 """generate package information from .bb file"""
157 pname = localdata.getVar('PN', True)
158 pcurver = localdata.getVar('PV', True)
159 pdesc = localdata.getVar('DESCRIPTION', True)
160 if pdesc is not None:
161 pdesc = pdesc.replace(',','')
162 pdesc = pdesc.replace('\n','')
163
164 pgrp = localdata.getVar('SECTION', True)
165 plicense = localdata.getVar('LICENSE', True).replace(',','_')
166
167 rstatus = localdata.getVar('RECIPE_COLOR', True)
168 if rstatus is not None:
169 rstatus = rstatus.replace(',','')
170
171 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION', True)
172 if pcurver == pupver:
173 vermatch="1"
174 else:
175 vermatch="0"
176
177 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON', True)
178 if noupdate_reason is None:
179 noupdate="0"
180 else:
181 noupdate="1"
182 noupdate_reason = noupdate_reason.replace(',','')
183
184 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
185 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE', True)
186 # do the comparison
187 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
188
189 lf = bb.utils.lockfile("%s.lock" % logfile)
190 with open(logfile, "a") as f:
191 row = [pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus]
192 row.extend(result)
193
194 writer = csv.writer(f)
195 writer.writerow(row)
196 f.close()
197 bb.utils.unlockfile(lf)
198}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500199do_distrodata[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500200
201addtask distrodataall after do_distrodata
202do_distrodataall[recrdeptask] = "do_distrodataall do_distrodata"
203do_distrodataall[recideptask] = "do_${BB_DEFAULT_TASK}"
204do_distrodataall[nostamp] = "1"
205do_distrodataall() {
206 :
207}
208
209addhandler checkpkg_eventhandler
210checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted"
211python checkpkg_eventhandler() {
212 import csv
213
214 def parse_csv_file(filename):
215 package_dict = {}
216
217 with open(filename, "r") as f:
218 reader = csv.reader(f, delimiter='\t')
219 for row in reader:
220 pn = row[0]
221
222 if reader.line_num == 1:
223 header = row
224 continue
225
226 if not pn in package_dict.keys():
227 package_dict[pn] = row
228 f.close()
229
230 with open(filename, "w") as f:
231 writer = csv.writer(f, delimiter='\t')
232 writer.writerow(header)
233 for pn in package_dict.keys():
234 writer.writerow(package_dict[pn])
235 f.close()
236
237 del package_dict
238
239 if bb.event.getName(e) == "BuildStarted":
240 import oe.distro_check as dc
241 logfile = dc.create_log_file(e.data, "checkpkg.csv")
242
243 lf = bb.utils.lockfile("%s.lock" % logfile)
244 with open(logfile, "a") as f:
245 writer = csv.writer(f, delimiter='\t')
246 headers = ['Package', 'Version', 'Upver', 'License', 'Section',
247 'Home', 'Release', 'Depends', 'BugTracker', 'PE', 'Description',
248 'Status', 'Tracking', 'URI', 'MAINTAINER', 'NoUpReason']
249 writer.writerow(headers)
250 f.close()
251 bb.utils.unlockfile(lf)
252 elif bb.event.getName(e) == "BuildCompleted":
253 import os
254 filename = "tmp/log/checkpkg.csv"
255 if os.path.isfile(filename):
256 lf = bb.utils.lockfile("%s.lock"%filename)
257 parse_csv_file(filename)
258 bb.utils.unlockfile(lf)
259 return
260}
261
262addtask checkpkg
263do_checkpkg[nostamp] = "1"
264python do_checkpkg() {
265 localdata = bb.data.createCopy(d)
266 import csv
267 import re
268 import tempfile
269 import subprocess
270 import oe.recipeutils
271 from bb.utils import vercmp_string
272 from bb.fetch2 import FetchError, NoMethodError, decodeurl
273
274 """first check whether a uri is provided"""
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500275 src_uri = (d.getVar('SRC_URI', True) or '').split()
276 if src_uri:
277 uri_type, _, _, _, _, _ = decodeurl(src_uri[0])
278 else:
279 uri_type = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500280
281 """initialize log files."""
282 logpath = d.getVar('LOG_DIR', True)
283 bb.utils.mkdirhier(logpath)
284 logfile = os.path.join(logpath, "checkpkg.csv")
285
286 """generate package information from .bb file"""
287 pname = d.getVar('PN', True)
288
289 if pname.find("-native") != -1:
290 if d.getVar('BBCLASSEXTEND', True):
291 return
292 pnstripped = pname.split("-native")
293 bb.note("Native Split: %s" % pnstripped)
294 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
295 bb.data.update_data(localdata)
296
297 if pname.startswith("nativesdk-"):
298 if d.getVar('BBCLASSEXTEND', True):
299 return
300 pnstripped = pname.replace("nativesdk-", "")
301 bb.note("NativeSDK Split: %s" % pnstripped)
302 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
303 bb.data.update_data(localdata)
304
305 if pname.find("-cross") != -1:
306 pnstripped = pname.split("-cross")
307 bb.note("cross Split: %s" % pnstripped)
308 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
309 bb.data.update_data(localdata)
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', True))
315 bb.data.update_data(localdata)
316
317 pdesc = localdata.getVar('DESCRIPTION', True)
318 pgrp = localdata.getVar('SECTION', True)
319 pversion = localdata.getVar('PV', True)
320 plicense = localdata.getVar('LICENSE', True)
321 psection = localdata.getVar('SECTION', True)
322 phome = localdata.getVar('HOMEPAGE', True)
323 prelease = localdata.getVar('PR', True)
324 pdepends = localdata.getVar('DEPENDS', True)
325 pbugtracker = localdata.getVar('BUGTRACKER', True)
326 ppe = localdata.getVar('PE', True)
327 psrcuri = localdata.getVar('SRC_URI', True)
328 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
329
330 """ Get upstream version version """
331 pupver = ""
332 pstatus = ""
333
334 try:
335 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
336
337 pupver = uv['version']
338 except Exception as e:
339 if e is FetchError:
340 pstatus = "ErrAccess"
341 elif e is NoMethodError:
342 pstatus = "ErrUnsupportedProto"
343 else:
344 pstatus = "ErrUnknown"
345
346 """Set upstream version status"""
347 if not pupver:
348 pupver = "N/A"
349 else:
350 pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type)
351 upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type)
352
353 cmp = vercmp_string(pv, upv)
354 if cmp == -1:
355 pstatus = "UPDATE"
356 elif cmp == 0:
357 pstatus = "MATCH"
358
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500359 if psrcuri:
360 psrcuri = psrcuri.split()[0]
361 else:
362 psrcuri = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500363 pdepends = "".join(pdepends.split("\t"))
364 pdesc = "".join(pdesc.split("\t"))
365 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON', True)
366 lf = bb.utils.lockfile("%s.lock" % logfile)
367 with open(logfile, "a") as f:
368 writer = csv.writer(f, delimiter='\t')
369 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
370 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, pupver,
371 psrcuri, maintainer, no_upgr_reason])
372 f.close()
373 bb.utils.unlockfile(lf)
374}
375
376addtask checkpkgall after do_checkpkg
377do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg"
378do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}"
379do_checkpkgall[nostamp] = "1"
380do_checkpkgall() {
381 :
382}
383
384addhandler distro_check_eventhandler
385distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
386python distro_check_eventhandler() {
387 """initialize log files."""
388 import oe.distro_check as dc
389 result_file = dc.create_log_file(e.data, "distrocheck.csv")
390 return
391}
392
393addtask distro_check
394do_distro_check[nostamp] = "1"
395python do_distro_check() {
396 """checks if the package is present in other public Linux distros"""
397 import oe.distro_check as dc
398 import shutil
399 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):
400 return
401
402 localdata = bb.data.createCopy(d)
403 bb.data.update_data(localdata)
404 tmpdir = d.getVar('TMPDIR', True)
405 distro_check_dir = os.path.join(tmpdir, "distro_check")
406 logpath = d.getVar('LOG_DIR', True)
407 bb.utils.mkdirhier(logpath)
408 result_file = os.path.join(logpath, "distrocheck.csv")
409 datetime = localdata.getVar('DATETIME', True)
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500410 dc.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500411
412 # do the comparison
413 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
414
415 # save the results
416 dc.save_distro_check_result(result, datetime, result_file, d)
417}
418
419addtask distro_checkall after do_distro_check
420do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check"
421do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}"
422do_distro_checkall[nostamp] = "1"
423do_distro_checkall() {
424 :
425}
426#
427#Check Missing License Text.
428#Use this task to generate the missing license text data for pkg-report system,
429#then we can search those recipes which license text isn't exsit in common-licenses directory
430#
431addhandler checklicense_eventhandler
432checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
433python checklicense_eventhandler() {
434 """initialize log files."""
435 import csv
436 import oe.distro_check as dc
437 logfile = dc.create_log_file(e.data, "missinglicense.csv")
438 lf = bb.utils.lockfile("%s.lock" % logfile)
439 with open(logfile, "a") as f:
440 writer = csv.writer(f, delimiter='\t')
441 writer.writerow(['Package', 'License', 'MissingLicense'])
442 f.close()
443 bb.utils.unlockfile(lf)
444 return
445}
446
447addtask checklicense
448do_checklicense[nostamp] = "1"
449python do_checklicense() {
450 import csv
451 import shutil
452 logpath = d.getVar('LOG_DIR', True)
453 bb.utils.mkdirhier(logpath)
454 pn = d.getVar('PN', True)
455 logfile = os.path.join(logpath, "missinglicense.csv")
456 generic_directory = d.getVar('COMMON_LICENSE_DIR', True)
457 license_types = d.getVar('LICENSE', True)
458 for license_type in ((license_types.replace('+', '').replace('|', '&')
459 .replace('(', '').replace(')', '').replace(';', '')
460 .replace(',', '').replace(" ", "").split("&"))):
461 if not os.path.isfile(os.path.join(generic_directory, license_type)):
462 lf = bb.utils.lockfile("%s.lock" % logfile)
463 with open(logfile, "a") as f:
464 writer = csv.writer(f, delimiter='\t')
465 writer.writerow([pn, license_types, license_type])
466 f.close()
467 bb.utils.unlockfile(lf)
468 return
469}
470
471addtask checklicenseall after do_checklicense
472do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense"
473do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}"
474do_checklicenseall[nostamp] = "1"
475do_checklicenseall() {
476 :
477}
478
479