blob: c85f7b3474fab8a1293c077c9335fabaca0d2c65 [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
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500264 def get_upstream_version_and_status():
265
266 # set if the upstream check fails reliably, e.g. absent git tags, or weird version format used on our or on upstream side.
267 upstream_version_unknown = localdata.getVar('UPSTREAM_VERSION_UNKNOWN')
268 # set if the upstream check cannot be reliably performed due to transient network failures, or server behaving weirdly.
269 # This one should be used sparingly, as it completely excludes a recipe from upstream checking.
270 upstream_check_unreliable = localdata.getVar('UPSTREAM_CHECK_UNRELIABLE')
271
272 if upstream_check_unreliable == "1":
273 return "N/A", "CHECK_IS_UNRELIABLE"
274
275 try:
276 uv = oe.recipeutils.get_recipe_upstream_version(localdata)
277 pupver = uv['version'] if uv['version'] else "N/A"
278 except Exception as e:
279 pupver = "N/A"
280
281 if pupver == "N/A":
282 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
283 else:
284 src_uri = (localdata.getVar('SRC_URI') or '').split()
285 if src_uri:
286 uri_type, _, _, _, _, _ = decodeurl(src_uri[0])
287 else:
288 uri_type = "none"
289 pv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pversion, uri_type)
290 upv, _, _ = oe.recipeutils.get_recipe_pv_without_srcpv(pupver, uri_type)
291
292 cmp = vercmp_string(pv, upv)
293 if cmp == -1:
294 pstatus = "UPDATE" if not upstream_version_unknown else "KNOWN_BROKEN"
295 elif cmp == 0:
296 pstatus = "MATCH" if not upstream_version_unknown else "KNOWN_BROKEN"
297 else:
298 pstatus = "UNKNOWN" if upstream_version_unknown else "UNKNOWN_BROKEN"
299
300 return pupver, pstatus
301
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500302
303 """initialize log files."""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500304 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500305 bb.utils.mkdirhier(logpath)
306 logfile = os.path.join(logpath, "checkpkg.csv")
307
308 """generate package information from .bb file"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500309 pname = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500310
311 if pname.find("-native") != -1:
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500312 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500313 return
314 pnstripped = pname.split("-native")
315 bb.note("Native 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
318 if pname.startswith("nativesdk-"):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500319 if d.getVar('BBCLASSEXTEND'):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500320 return
321 pnstripped = pname.replace("nativesdk-", "")
322 bb.note("NativeSDK Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 localdata.setVar('OVERRIDES', "pn-" + pnstripped + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500324
325 if pname.find("-cross") != -1:
326 pnstripped = pname.split("-cross")
327 bb.note("cross Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500328 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500329
330 if pname.find("-initial") != -1:
331 pnstripped = pname.split("-initial")
332 bb.note("initial Split: %s" % pnstripped)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500333 localdata.setVar('OVERRIDES', "pn-" + pnstripped[0] + ":" + d.getVar('OVERRIDES'))
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500334
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500335 pdesc = localdata.getVar('DESCRIPTION')
336 pgrp = localdata.getVar('SECTION')
337 pversion = localdata.getVar('PV')
338 plicense = localdata.getVar('LICENSE')
339 psection = localdata.getVar('SECTION')
340 phome = localdata.getVar('HOMEPAGE')
341 prelease = localdata.getVar('PR')
342 pdepends = localdata.getVar('DEPENDS')
343 pbugtracker = localdata.getVar('BUGTRACKER')
344 ppe = localdata.getVar('PE')
345 psrcuri = localdata.getVar('SRC_URI')
346 maintainer = localdata.getVar('RECIPE_MAINTAINER')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500347
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500348 pupver, pstatus = get_upstream_version_and_status()
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500349
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500350 if psrcuri:
351 psrcuri = psrcuri.split()[0]
352 else:
353 psrcuri = "none"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500354 pdepends = "".join(pdepends.split("\t"))
355 pdesc = "".join(pdesc.split("\t"))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500356 no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500357 lf = bb.utils.lockfile("%s.lock" % logfile)
358 with open(logfile, "a") as f:
359 writer = csv.writer(f, delimiter='\t')
360 writer.writerow([pname, pversion, pupver, plicense, psection, phome,
361 prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, pupver,
362 psrcuri, maintainer, no_upgr_reason])
363 f.close()
364 bb.utils.unlockfile(lf)
365}
366
367addtask checkpkgall after do_checkpkg
368do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg"
369do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}"
370do_checkpkgall[nostamp] = "1"
371do_checkpkgall() {
372 :
373}
374
375addhandler distro_check_eventhandler
376distro_check_eventhandler[eventmask] = "bb.event.BuildStarted"
377python distro_check_eventhandler() {
378 """initialize log files."""
379 import oe.distro_check as dc
380 result_file = dc.create_log_file(e.data, "distrocheck.csv")
381 return
382}
383
384addtask distro_check
385do_distro_check[nostamp] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500386do_distro_check[vardepsexclude] += "DATETIME"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500387python do_distro_check() {
388 """checks if the package is present in other public Linux distros"""
389 import oe.distro_check as dc
390 import shutil
391 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):
392 return
393
394 localdata = bb.data.createCopy(d)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500395 tmpdir = d.getVar('TMPDIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500396 distro_check_dir = os.path.join(tmpdir, "distro_check")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500397 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500398 bb.utils.mkdirhier(logpath)
399 result_file = os.path.join(logpath, "distrocheck.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500400 datetime = localdata.getVar('DATETIME')
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500401 dc.update_distro_data(distro_check_dir, datetime, localdata)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500402
403 # do the comparison
404 result = dc.compare_in_distro_packages_list(distro_check_dir, d)
405
406 # save the results
407 dc.save_distro_check_result(result, datetime, result_file, d)
408}
409
410addtask distro_checkall after do_distro_check
411do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check"
412do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}"
413do_distro_checkall[nostamp] = "1"
414do_distro_checkall() {
415 :
416}
417#
418#Check Missing License Text.
419#Use this task to generate the missing license text data for pkg-report system,
420#then we can search those recipes which license text isn't exsit in common-licenses directory
421#
422addhandler checklicense_eventhandler
423checklicense_eventhandler[eventmask] = "bb.event.BuildStarted"
424python checklicense_eventhandler() {
425 """initialize log files."""
426 import csv
427 import oe.distro_check as dc
428 logfile = dc.create_log_file(e.data, "missinglicense.csv")
429 lf = bb.utils.lockfile("%s.lock" % logfile)
430 with open(logfile, "a") as f:
431 writer = csv.writer(f, delimiter='\t')
432 writer.writerow(['Package', 'License', 'MissingLicense'])
433 f.close()
434 bb.utils.unlockfile(lf)
435 return
436}
437
438addtask checklicense
439do_checklicense[nostamp] = "1"
440python do_checklicense() {
441 import csv
442 import shutil
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500443 logpath = d.getVar('LOG_DIR')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500444 bb.utils.mkdirhier(logpath)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500445 pn = d.getVar('PN')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500446 logfile = os.path.join(logpath, "missinglicense.csv")
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500447 generic_directory = d.getVar('COMMON_LICENSE_DIR')
448 license_types = d.getVar('LICENSE')
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500449 for license_type in ((license_types.replace('+', '').replace('|', '&')
450 .replace('(', '').replace(')', '').replace(';', '')
451 .replace(',', '').replace(" ", "").split("&"))):
452 if not os.path.isfile(os.path.join(generic_directory, license_type)):
453 lf = bb.utils.lockfile("%s.lock" % logfile)
454 with open(logfile, "a") as f:
455 writer = csv.writer(f, delimiter='\t')
456 writer.writerow([pn, license_types, license_type])
457 f.close()
458 bb.utils.unlockfile(lf)
459 return
460}
461
462addtask checklicenseall after do_checklicense
463do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense"
464do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}"
465do_checklicenseall[nostamp] = "1"
466do_checklicenseall() {
467 :
468}