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