blob: 4168e43849f2a4fd1a3390a99a04c1b997a52c1f [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)
36 dist_check.update_distro_data(distro_check_dir, datetime)
37
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)
121 dist_check.update_distro_data(distro_check_dir, datetime)
122
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"""
274 src_uri = d.getVar('SRC_URI', True)
275 if not src_uri:
276 return
277 uri_type, _, _, _, _, _ = decodeurl(src_uri)
278
279 """initialize log files."""
280 logpath = d.getVar('LOG_DIR', True)
281 bb.utils.mkdirhier(logpath)
282 logfile = os.path.join(logpath, "checkpkg.csv")
283
284 """generate package information from .bb file"""
285 pname = d.getVar('PN', True)
286
287 if pname.find("-native") != -1:
288 if d.getVar('BBCLASSEXTEND', True):
289 return
290 pnstripped = pname.split("-native")
291 bb.note("Native Split: %s" % pnstripped)
292 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
293 bb.data.update_data(localdata)
294
295 if pname.startswith("nativesdk-"):
296 if d.getVar('BBCLASSEXTEND', True):
297 return
298 pnstripped = pname.replace("nativesdk-", "")
299 bb.note("NativeSDK Split: %s" % pnstripped)
300 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES', True))
301 bb.data.update_data(localdata)
302
303 if pname.find("-cross") != -1:
304 pnstripped = pname.split("-cross")
305 bb.note("cross Split: %s" % pnstripped)
306 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
307 bb.data.update_data(localdata)
308
309 if pname.find("-initial") != -1:
310 pnstripped = pname.split("-initial")
311 bb.note("initial Split: %s" % pnstripped)
312 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES', True))
313 bb.data.update_data(localdata)
314
315 pdesc = localdata.getVar('DESCRIPTION', True)
316 pgrp = localdata.getVar('SECTION', True)
317 pversion = localdata.getVar('PV', True)
318 plicense = localdata.getVar('LICENSE', True)
319 psection = localdata.getVar('SECTION', True)
320 phome = localdata.getVar('HOMEPAGE', True)
321 prelease = localdata.getVar('PR', True)
322 pdepends = localdata.getVar('DEPENDS', True)
323 pbugtracker = localdata.getVar('BUGTRACKER', True)
324 ppe = localdata.getVar('PE', True)
325 psrcuri = localdata.getVar('SRC_URI', True)
326 maintainer = localdata.getVar('RECIPE_MAINTAINER', True)
327
328 """ Get upstream version version """
329 pupver = ""
330 pstatus = ""
331
332 try:
333 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
334
335 pupver = uv['version']
336 except Exception as e:
337 if e is FetchError:
338 pstatus = "ErrAccess"
339 elif e is NoMethodError:
340 pstatus = "ErrUnsupportedProto"
341 else:
342 pstatus = "ErrUnknown"
343
344 """Set upstream version status"""
345 if not pupver:
346 pupver = "N/A"
347 else:
348 pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type)
349 upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type)
350
351 cmp = vercmp_string(pv, upv)
352 if cmp == -1:
353 pstatus = "UPDATE"
354 elif cmp == 0:
355 pstatus = "MATCH"
356
357 psrcuri = psrcuri.split()[0]
358 pdepends = "".join(pdepends.split("\t"))
359 pdesc = "".join(pdesc.split("\t"))
360 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON', True)
361 lf = bb.utils.lockfile("%s.lock" % logfile)
362 with open(logfile, "a") as f:
363 writer = csv.writer(f, delimiter='\t')
364 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
365 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, pupver,
366 psrcuri, maintainer, no_upgr_reason])
367 f.close()
368 bb.utils.unlockfile(lf)
369}
370
371addtask checkpkgall after do_checkpkg
372do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg"
373do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}"
374do_checkpkgall[nostamp] = "1"
375do_checkpkgall() {
376 :
377}
378
379addhandler distro_check_eventhandler
380distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
381python distro_check_eventhandler() {
382 """initialize log files."""
383 import oe.distro_check as dc
384 result_file = dc.create_log_file(e.data, "distrocheck.csv")
385 return
386}
387
388addtask distro_check
389do_distro_check[nostamp] = "1"
390python do_distro_check() {
391 """checks if the package is present in other public Linux distros"""
392 import oe.distro_check as dc
393 import shutil
394 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):
395 return
396
397 localdata = bb.data.createCopy(d)
398 bb.data.update_data(localdata)
399 tmpdir = d.getVar('TMPDIR', True)
400 distro_check_dir = os.path.join(tmpdir, "distro_check")
401 logpath = d.getVar('LOG_DIR', True)
402 bb.utils.mkdirhier(logpath)
403 result_file = os.path.join(logpath, "distrocheck.csv")
404 datetime = localdata.getVar('DATETIME', True)
405 dc.update_distro_data(distro_check_dir, datetime)
406
407 # do the comparison
408 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
409
410 # save the results
411 dc.save_distro_check_result(result, datetime, result_file, d)
412}
413
414addtask distro_checkall after do_distro_check
415do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check"
416do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}"
417do_distro_checkall[nostamp] = "1"
418do_distro_checkall() {
419 :
420}
421#
422#Check Missing License Text.
423#Use this task to generate the missing license text data for pkg-report system,
424#then we can search those recipes which license text isn't exsit in common-licenses directory
425#
426addhandler checklicense_eventhandler
427checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
428python checklicense_eventhandler() {
429 """initialize log files."""
430 import csv
431 import oe.distro_check as dc
432 logfile = dc.create_log_file(e.data, "missinglicense.csv")
433 lf = bb.utils.lockfile("%s.lock" % logfile)
434 with open(logfile, "a") as f:
435 writer = csv.writer(f, delimiter='\t')
436 writer.writerow(['Package', 'License', 'MissingLicense'])
437 f.close()
438 bb.utils.unlockfile(lf)
439 return
440}
441
442addtask checklicense
443do_checklicense[nostamp] = "1"
444python do_checklicense() {
445 import csv
446 import shutil
447 logpath = d.getVar('LOG_DIR', True)
448 bb.utils.mkdirhier(logpath)
449 pn = d.getVar('PN', True)
450 logfile = os.path.join(logpath, "missinglicense.csv")
451 generic_directory = d.getVar('COMMON_LICENSE_DIR', True)
452 license_types = d.getVar('LICENSE', True)
453 for license_type in ((license_types.replace('+', '').replace('|', '&')
454 .replace('(', '').replace(')', '').replace(';', '')
455 .replace(',', '').replace(" ", "").split("&"))):
456 if not os.path.isfile(os.path.join(generic_directory, license_type)):
457 lf = bb.utils.lockfile("%s.lock" % logfile)
458 with open(logfile, "a") as f:
459 writer = csv.writer(f, delimiter='\t')
460 writer.writerow([pn, license_types, license_type])
461 f.close()
462 bb.utils.unlockfile(lf)
463 return
464}
465
466addtask checklicenseall after do_checklicense
467do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense"
468do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}"
469do_checklicenseall[nostamp] = "1"
470do_checklicenseall() {
471 :
472}
473
474