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