blob: 59ee8cea660fa7d53e4530bfd962ca789c05a707 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191addhandler checkpkg_eventhandler
192checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted"
193python checkpkg_eventhandler() {
194 import csv
195
196 def parse_csv_file(filename):
197 package_dict = {}
198
199 with open(filename, "r") as f:
200 reader = csv.reader(f, delimiter='\t')
201 for row in reader:
202 pn = row[0]
203
204 if reader.line_num == 1:
205 header = row
206 continue
207
208 if not pn in package_dict.keys():
209 package_dict[pn] = row
210 f.close()
211
212 with open(filename, "w") as f:
213 writer = csv.writer(f, delimiter='\t')
214 writer.writerow(header)
215 for pn in package_dict.keys():
216 writer.writerow(package_dict[pn])
217 f.close()
218
219 del package_dict
220
221 if bb.event.getName(e) == "BuildStarted":
222 import oe.distro_check as dc
223 logfile = dc.create_log_file(e.data, "checkpkg.csv")
224
225 lf = bb.utils.lockfile("%s.lock" % logfile)
226 with open(logfile, "a") as f:
227 writer = csv.writer(f, delimiter='\t')
228 headers = ['Package', 'Version', 'Upver', 'License', 'Section',
229 'Home', 'Release', 'Depends', 'BugTracker', 'PE', 'Description',
230 'Status', 'Tracking', 'URI', 'MAINTAINER', 'NoUpReason']
231 writer.writerow(headers)
232 f.close()
233 bb.utils.unlockfile(lf)
234 elif bb.event.getName(e) == "BuildCompleted":
235 import os
236 filename = "tmp/log/checkpkg.csv"
237 if os.path.isfile(filename):
238 lf = bb.utils.lockfile("%s.lock"%filename)
239 parse_csv_file(filename)
240 bb.utils.unlockfile(lf)
241 return
242}
243
244addtask checkpkg
245do_checkpkg[nostamp] = "1"
246python do_checkpkg() {
247 localdata = bb.data.createCopy(d)
248 import csv
249 import re
250 import tempfile
251 import subprocess
252 import oe.recipeutils
253 from bb.utils import vercmp_string
254 from bb.fetch2 import FetchError, NoMethodError, decodeurl
255
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500256 def get_upstream_version_and_status():
257
258 # set if the upstream check fails reliably, e.g. absent git tags, or weird version format used on our or on upstream side.
259 upstream_version_unknown = localdata.getVar('UPSTREAM_VERSION_UNKNOWN')
260 # set if the upstream check cannot be reliably performed due to transient network failures, or server behaving weirdly.
261 # This one should be used sparingly, as it completely excludes a recipe from upstream checking.
262 upstream_check_unreliable = localdata.getVar('UPSTREAM_CHECK_UNRELIABLE')
263
264 if upstream_check_unreliable == "1":
265 return "N/A", "CHECK_IS_UNRELIABLE"
266
Brad Bishop316dfdd2018-06-25 12:45:53 -0400267 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
268 pupver = uv['version'] if uv['version'] else "N/A"
269 pversion = uv['current_version']
270 revision = uv['revision'] if uv['revision'] else "N/A"
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500271
272 if pupver == "N/A":
273 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
274 else:
Brad Bishop316dfdd2018-06-25 12:45:53 -0400275 cmp = vercmp_string(pversion, pupver)
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500276 if cmp == -1:
277 pstatus = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN"
278 elif cmp == 0:
279 pstatus = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN"
280 else:
281 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
282
Brad Bishop316dfdd2018-06-25 12:45:53 -0400283 return pversion, pupver, pstatus, revision
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500284
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500285
286 """initialize log files."""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500287 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500288 bb.utils.mkdirhier(logpath)
289 logfile = os.path.join(logpath, "checkpkg.csv")
290
291 """generate package information from .bb file"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500292 pname = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500293
294 if pname.find("-native") != -1:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500295 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500296 return
297 pnstripped = pname.split("-native")
298 bb.note("Native Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500299 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500300
301 if pname.startswith("nativesdk-"):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500302 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500303 return
304 pnstripped = pname.replace("nativesdk-", "")
305 bb.note("NativeSDK Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500306 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500307
308 if pname.find("-cross") != -1:
309 pnstripped = pname.split("-cross")
310 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500311 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500312
313 if pname.find("-initial") != -1:
314 pnstripped = pname.split("-initial")
315 bb.note("initial Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500316 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500317
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500318 pdesc = localdata.getVar('DESCRIPTION')
319 pgrp = localdata.getVar('SECTION')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500320 plicense = localdata.getVar('LICENSE')
321 psection = localdata.getVar('SECTION')
322 phome = localdata.getVar('HOMEPAGE')
323 prelease = localdata.getVar('PR')
324 pdepends = localdata.getVar('DEPENDS')
325 pbugtracker = localdata.getVar('BUGTRACKER')
326 ppe = localdata.getVar('PE')
327 psrcuri = localdata.getVar('SRC_URI')
328 maintainer = localdata.getVar('RECIPE_MAINTAINER')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500329
Brad Bishop316dfdd2018-06-25 12:45:53 -0400330 pversion, pupver, pstatus, prevision = get_upstream_version_and_status()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500331
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500332 if psrcuri:
333 psrcuri = psrcuri.split()[0]
334 else:
335 psrcuri = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500336 pdepends = "".join(pdepends.split("\t"))
337 pdesc = "".join(pdesc.split("\t"))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500338 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500339 lf = bb.utils.lockfile("%s.lock" % logfile)
340 with open(logfile, "a") as f:
341 writer = csv.writer(f, delimiter='\t')
342 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
Brad Bishop316dfdd2018-06-25 12:45:53 -0400343 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, prevision,
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500344 psrcuri, maintainer, no_upgr_reason])
345 f.close()
346 bb.utils.unlockfile(lf)
347}
348
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500349addhandler distro_check_eventhandler
350distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
351python distro_check_eventhandler() {
352 """initialize log files."""
353 import oe.distro_check as dc
354 result_file = dc.create_log_file(e.data, "distrocheck.csv")
355 return
356}
357
358addtask distro_check
359do_distro_check[nostamp] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500360do_distro_check[vardepsexclude] += "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500361python do_distro_check() {
362 """checks if the package is present in other public Linux distros"""
363 import oe.distro_check as dc
364 import shutil
365 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):
366 return
367
368 localdata = bb.data.createCopy(d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500369 tmpdir = d.getVar('TMPDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500370 distro_check_dir = os.path.join(tmpdir, "distro_check")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500371 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500372 bb.utils.mkdirhier(logpath)
373 result_file = os.path.join(logpath, "distrocheck.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500374 datetime = localdata.getVar('DATETIME')
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500375 dc.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500376
377 # do the comparison
378 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
379
380 # save the results
381 dc.save_distro_check_result(result, datetime, result_file, d)
382}
383
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500384#
385#Check Missing License Text.
386#Use this task to generate the missing license text data for pkg-report system,
387#then we can search those recipes which license text isn't exsit in common-licenses directory
388#
389addhandler checklicense_eventhandler
390checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
391python checklicense_eventhandler() {
392 """initialize log files."""
393 import csv
394 import oe.distro_check as dc
395 logfile = dc.create_log_file(e.data, "missinglicense.csv")
396 lf = bb.utils.lockfile("%s.lock" % logfile)
397 with open(logfile, "a") as f:
398 writer = csv.writer(f, delimiter='\t')
399 writer.writerow(['Package', 'License', 'MissingLicense'])
400 f.close()
401 bb.utils.unlockfile(lf)
402 return
403}
404
405addtask checklicense
406do_checklicense[nostamp] = "1"
407python do_checklicense() {
408 import csv
409 import shutil
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500410 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500411 bb.utils.mkdirhier(logpath)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500412 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500413 logfile = os.path.join(logpath, "missinglicense.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500414 generic_directory = d.getVar('COMMON_LICENSE_DIR')
415 license_types = d.getVar('LICENSE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500416 for license_type in ((license_types.replace('+', '').replace('|', '&')
417 .replace('(', '').replace(')', '').replace(';', '')
418 .replace(',', '').replace(" ", "").split("&"))):
419 if not os.path.isfile(os.path.join(generic_directory, license_type)):
420 lf = bb.utils.lockfile("%s.lock" % logfile)
421 with open(logfile, "a") as f:
422 writer = csv.writer(f, delimiter='\t')
423 writer.writerow([pn, license_types, license_type])
424 f.close()
425 bb.utils.unlockfile(lf)
426 return
427}