blob: 5e3444161059e7da95c815d7fc3fd2742498e9d8 [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)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050028 pn = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029 bb.note("Package Name: %s" % pn)
30
31 import oe.distro_check as dist_check
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 tmpdir = d.getVar('TMPDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 distro_check_dir = os.path.join(tmpdir, "distro_check")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034 datetime = localdata.getVar('DATETIME')
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)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050041
42 if pn.find("-cross") != -1:
43 pnstripped = pn.split("-cross")
44 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046
47 if pn.find("-crosssdk") != -1:
48 pnstripped = pn.split("-crosssdk")
49 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051
52 if pn.startswith("nativesdk-"):
53 pnstripped = pn.replace("nativesdk-", "")
54 bb.note("NativeSDK Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050055 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050056
57
58 if pn.find("-initial") != -1:
59 pnstripped = pn.split("-initial")
60 bb.note("initial Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062
63 """generate package information from .bb file"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 pname = localdata.getVar('PN')
65 pcurver = localdata.getVar('PV')
66 pdesc = localdata.getVar('DESCRIPTION')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 if pdesc is not None:
68 pdesc = pdesc.replace(',','')
69 pdesc = pdesc.replace('\n','')
70
Brad Bishop6e60e8b2018-02-01 10:27:11 -050071 pgrp = localdata.getVar('SECTION')
72 plicense = localdata.getVar('LICENSE').replace(',','_')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074 rstatus = localdata.getVar('RECIPE_COLOR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 if rstatus is not None:
76 rstatus = rstatus.replace(',','')
77
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079 if pcurver == pupver:
80 vermatch="1"
81 else:
82 vermatch="0"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050083 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 if noupdate_reason is None:
85 noupdate="0"
86 else:
87 noupdate="1"
88 noupdate_reason = noupdate_reason.replace(',','')
89
Brad Bishop6e60e8b2018-02-01 10:27:11 -050090 maintainer = localdata.getVar('RECIPE_MAINTAINER')
91 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
93
94 bb.note("DISTRO: %s,%s,%s,%s,%s,%s,%s,%s,%s\n" % \
95 (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus))
96 line = pn
97 for i in result:
98 line = line + "," + i
99 bb.note("%s\n" % line)
100}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500101do_distrodata_np[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102
103addtask distrodata
104do_distrodata[nostamp] = "1"
105python do_distrodata() {
106 import csv
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108 bb.utils.mkdirhier(logpath)
109 logfile = os.path.join(logpath, "distrodata.csv")
110
111 import oe.distro_check as dist_check
112 localdata = bb.data.createCopy(d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113 tmpdir = d.getVar('TMPDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 distro_check_dir = os.path.join(tmpdir, "distro_check")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500115 datetime = localdata.getVar('DATETIME')
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500116 dist_check.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500118 pn = d.getVar("PN")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119 bb.note("Package Name: %s" % pn)
120
121 if pn.find("-native") != -1:
122 pnstripped = pn.split("-native")
123 bb.note("Native Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125
126 if pn.startswith("nativesdk-"):
127 pnstripped = pn.replace("nativesdk-", "")
128 bb.note("NativeSDK Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500129 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130
131 if pn.find("-cross") != -1:
132 pnstripped = pn.split("-cross")
133 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500134 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135
136 if pn.find("-crosssdk") != -1:
137 pnstripped = pn.split("-crosssdk")
138 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140
141 if pn.find("-initial") != -1:
142 pnstripped = pn.split("-initial")
143 bb.note("initial Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500144 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500145
146 """generate package information from .bb file"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147 pname = localdata.getVar('PN')
148 pcurver = localdata.getVar('PV')
149 pdesc = localdata.getVar('DESCRIPTION')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500150 if pdesc is not None:
151 pdesc = pdesc.replace(',','')
152 pdesc = pdesc.replace('\n','')
153
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 pgrp = localdata.getVar('SECTION')
155 plicense = localdata.getVar('LICENSE').replace(',','_')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500157 rstatus = localdata.getVar('RECIPE_COLOR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 if rstatus is not None:
159 rstatus = rstatus.replace(',','')
160
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500161 pupver = localdata.getVar('RECIPE_UPSTREAM_VERSION')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 if pcurver == pupver:
163 vermatch="1"
164 else:
165 vermatch="0"
166
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500167 noupdate_reason = localdata.getVar('RECIPE_NO_UPDATE_REASON')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 if noupdate_reason is None:
169 noupdate="0"
170 else:
171 noupdate="1"
172 noupdate_reason = noupdate_reason.replace(',','')
173
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500174 maintainer = localdata.getVar('RECIPE_MAINTAINER')
175 rlrd = localdata.getVar('RECIPE_UPSTREAM_DATE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176 # do the comparison
177 result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata)
178
179 lf = bb.utils.lockfile("%s.lock" % logfile)
180 with open(logfile, "a") as f:
181 row = [pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus]
182 row.extend(result)
183
184 writer = csv.writer(f)
185 writer.writerow(row)
186 f.close()
187 bb.utils.unlockfile(lf)
188}
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500189do_distrodata[vardepsexclude] = "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190
191addtask distrodataall after do_distrodata
192do_distrodataall[recrdeptask] = "do_distrodataall do_distrodata"
193do_distrodataall[recideptask] = "do_${BB_DEFAULT_TASK}"
194do_distrodataall[nostamp] = "1"
195do_distrodataall() {
196 :
197}
198
199addhandler checkpkg_eventhandler
200checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted"
201python checkpkg_eventhandler() {
202 import csv
203
204 def parse_csv_file(filename):
205 package_dict = {}
206
207 with open(filename, "r") as f:
208 reader = csv.reader(f, delimiter='\t')
209 for row in reader:
210 pn = row[0]
211
212 if reader.line_num == 1:
213 header = row
214 continue
215
216 if not pn in package_dict.keys():
217 package_dict[pn] = row
218 f.close()
219
220 with open(filename, "w") as f:
221 writer = csv.writer(f, delimiter='\t')
222 writer.writerow(header)
223 for pn in package_dict.keys():
224 writer.writerow(package_dict[pn])
225 f.close()
226
227 del package_dict
228
229 if bb.event.getName(e) == "BuildStarted":
230 import oe.distro_check as dc
231 logfile = dc.create_log_file(e.data, "checkpkg.csv")
232
233 lf = bb.utils.lockfile("%s.lock" % logfile)
234 with open(logfile, "a") as f:
235 writer = csv.writer(f, delimiter='\t')
236 headers = ['Package', 'Version', 'Upver', 'License', 'Section',
237 'Home', 'Release', 'Depends', 'BugTracker', 'PE', 'Description',
238 'Status', 'Tracking', 'URI', 'MAINTAINER', 'NoUpReason']
239 writer.writerow(headers)
240 f.close()
241 bb.utils.unlockfile(lf)
242 elif bb.event.getName(e) == "BuildCompleted":
243 import os
244 filename = "tmp/log/checkpkg.csv"
245 if os.path.isfile(filename):
246 lf = bb.utils.lockfile("%s.lock"%filename)
247 parse_csv_file(filename)
248 bb.utils.unlockfile(lf)
249 return
250}
251
252addtask checkpkg
253do_checkpkg[nostamp] = "1"
254python do_checkpkg() {
255 localdata = bb.data.createCopy(d)
256 import csv
257 import re
258 import tempfile
259 import subprocess
260 import oe.recipeutils
261 from bb.utils import vercmp_string
262 from bb.fetch2 import FetchError, NoMethodError, decodeurl
263
264 """first check whether a uri is provided"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500265 src_uri = (d.getVar('SRC_URI') or '').split()
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500266 if src_uri:
267 uri_type, _, _, _, _, _ = decodeurl(src_uri[0])
268 else:
269 uri_type = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500270
271 """initialize log files."""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500272 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500273 bb.utils.mkdirhier(logpath)
274 logfile = os.path.join(logpath, "checkpkg.csv")
275
276 """generate package information from .bb file"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500277 pname = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500278
279 if pname.find("-native") != -1:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500280 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500281 return
282 pnstripped = pname.split("-native")
283 bb.note("Native Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500284 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285
286 if pname.startswith("nativesdk-"):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500287 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288 return
289 pnstripped = pname.replace("nativesdk-", "")
290 bb.note("NativeSDK Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500291 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500292
293 if pname.find("-cross") != -1:
294 pnstripped = pname.split("-cross")
295 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500296 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500297
298 if pname.find("-initial") != -1:
299 pnstripped = pname.split("-initial")
300 bb.note("initial Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500301 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500303 pdesc = localdata.getVar('DESCRIPTION')
304 pgrp = localdata.getVar('SECTION')
305 pversion = localdata.getVar('PV')
306 plicense = localdata.getVar('LICENSE')
307 psection = localdata.getVar('SECTION')
308 phome = localdata.getVar('HOMEPAGE')
309 prelease = localdata.getVar('PR')
310 pdepends = localdata.getVar('DEPENDS')
311 pbugtracker = localdata.getVar('BUGTRACKER')
312 ppe = localdata.getVar('PE')
313 psrcuri = localdata.getVar('SRC_URI')
314 maintainer = localdata.getVar('RECIPE_MAINTAINER')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500315
316 """ Get upstream version version """
317 pupver = ""
318 pstatus = ""
319
320 try:
321 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
322
323 pupver = uv['version']
324 except Exception as e:
325 if e is FetchError:
326 pstatus = "ErrAccess"
327 elif e is NoMethodError:
328 pstatus = "ErrUnsupportedProto"
329 else:
330 pstatus = "ErrUnknown"
331
332 """Set upstream version status"""
333 if not pupver:
334 pupver = "N/A"
335 else:
336 pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type)
337 upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type)
338
339 cmp = vercmp_string(pv, upv)
340 if cmp == -1:
341 pstatus = "UPDATE"
342 elif cmp == 0:
343 pstatus = "MATCH"
344
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500345 if psrcuri:
346 psrcuri = psrcuri.split()[0]
347 else:
348 psrcuri = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500349 pdepends = "".join(pdepends.split("\t"))
350 pdesc = "".join(pdesc.split("\t"))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500351 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500352 lf = bb.utils.lockfile("%s.lock" % logfile)
353 with open(logfile, "a") as f:
354 writer = csv.writer(f, delimiter='\t')
355 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
356 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, pupver,
357 psrcuri, maintainer, no_upgr_reason])
358 f.close()
359 bb.utils.unlockfile(lf)
360}
361
362addtask checkpkgall after do_checkpkg
363do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg"
364do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}"
365do_checkpkgall[nostamp] = "1"
366do_checkpkgall() {
367 :
368}
369
370addhandler distro_check_eventhandler
371distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
372python distro_check_eventhandler() {
373 """initialize log files."""
374 import oe.distro_check as dc
375 result_file = dc.create_log_file(e.data, "distrocheck.csv")
376 return
377}
378
379addtask distro_check
380do_distro_check[nostamp] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500381do_distro_check[vardepsexclude] += "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500382python do_distro_check() {
383 """checks if the package is present in other public Linux distros"""
384 import oe.distro_check as dc
385 import shutil
386 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):
387 return
388
389 localdata = bb.data.createCopy(d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500390 tmpdir = d.getVar('TMPDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500391 distro_check_dir = os.path.join(tmpdir, "distro_check")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500392 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500393 bb.utils.mkdirhier(logpath)
394 result_file = os.path.join(logpath, "distrocheck.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500395 datetime = localdata.getVar('DATETIME')
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500396 dc.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500397
398 # do the comparison
399 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
400
401 # save the results
402 dc.save_distro_check_result(result, datetime, result_file, d)
403}
404
405addtask distro_checkall after do_distro_check
406do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check"
407do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}"
408do_distro_checkall[nostamp] = "1"
409do_distro_checkall() {
410 :
411}
412#
413#Check Missing License Text.
414#Use this task to generate the missing license text data for pkg-report system,
415#then we can search those recipes which license text isn't exsit in common-licenses directory
416#
417addhandler checklicense_eventhandler
418checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
419python checklicense_eventhandler() {
420 """initialize log files."""
421 import csv
422 import oe.distro_check as dc
423 logfile = dc.create_log_file(e.data, "missinglicense.csv")
424 lf = bb.utils.lockfile("%s.lock" % logfile)
425 with open(logfile, "a") as f:
426 writer = csv.writer(f, delimiter='\t')
427 writer.writerow(['Package', 'License', 'MissingLicense'])
428 f.close()
429 bb.utils.unlockfile(lf)
430 return
431}
432
433addtask checklicense
434do_checklicense[nostamp] = "1"
435python do_checklicense() {
436 import csv
437 import shutil
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500438 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500439 bb.utils.mkdirhier(logpath)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500440 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500441 logfile = os.path.join(logpath, "missinglicense.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500442 generic_directory = d.getVar('COMMON_LICENSE_DIR')
443 license_types = d.getVar('LICENSE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500444 for license_type in ((license_types.replace('+', '').replace('|', '&')
445 .replace('(', '').replace(')', '').replace(';', '')
446 .replace(',', '').replace(" ", "").split("&"))):
447 if not os.path.isfile(os.path.join(generic_directory, license_type)):
448 lf = bb.utils.lockfile("%s.lock" % logfile)
449 with open(logfile, "a") as f:
450 writer = csv.writer(f, delimiter='\t')
451 writer.writerow([pn, license_types, license_type])
452 f.close()
453 bb.utils.unlockfile(lf)
454 return
455}
456
457addtask checklicenseall after do_checklicense
458do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense"
459do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}"
460do_checklicenseall[nostamp] = "1"
461do_checklicenseall() {
462 :
463}