Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | include conf/distro/include/package_regex.inc |
| 2 | include conf/distro/include/upstream_tracking.inc |
| 3 | include conf/distro/include/distro_alias.inc |
| 4 | include conf/distro/include/maintainers.inc |
| 5 | |
| 6 | addhandler distro_eventhandler |
| 7 | distro_eventhandler[eventmask] = "bb.event.BuildStarted" |
| 8 | python 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 | |
| 25 | addtask distrodata_np |
| 26 | do_distrodata_np[nostamp] = "1" |
| 27 | python 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 36 | dist_check.update_distro_data(distro_check_dir, datetime, localdata) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 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 | } |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 107 | do_distrodata_np[vardepsexclude] = "DATETIME" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 108 | |
| 109 | addtask distrodata |
| 110 | do_distrodata[nostamp] = "1" |
| 111 | python 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 122 | dist_check.update_distro_data(distro_check_dir, datetime, localdata) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | |
| 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 200 | do_distrodata[vardepsexclude] = "DATETIME" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 201 | |
| 202 | addtask distrodataall after do_distrodata |
| 203 | do_distrodataall[recrdeptask] = "do_distrodataall do_distrodata" |
| 204 | do_distrodataall[recideptask] = "do_${BB_DEFAULT_TASK}" |
| 205 | do_distrodataall[nostamp] = "1" |
| 206 | do_distrodataall() { |
| 207 | : |
| 208 | } |
| 209 | |
| 210 | addhandler checkpkg_eventhandler |
| 211 | checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted" |
| 212 | python 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 | |
| 263 | addtask checkpkg |
| 264 | do_checkpkg[nostamp] = "1" |
| 265 | python 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 276 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 281 | |
| 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 360 | if psrcuri: |
| 361 | psrcuri = psrcuri.split()[0] |
| 362 | else: |
| 363 | psrcuri = "none" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 364 | 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 | |
| 377 | addtask checkpkgall after do_checkpkg |
| 378 | do_checkpkgall[recrdeptask] = "do_checkpkgall do_checkpkg" |
| 379 | do_checkpkgall[recideptask] = "do_${BB_DEFAULT_TASK}" |
| 380 | do_checkpkgall[nostamp] = "1" |
| 381 | do_checkpkgall() { |
| 382 | : |
| 383 | } |
| 384 | |
| 385 | addhandler distro_check_eventhandler |
| 386 | distro_check_eventhandler[eventmask] = "bb.event.BuildStarted" |
| 387 | python 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 | |
| 394 | addtask distro_check |
| 395 | do_distro_check[nostamp] = "1" |
| 396 | python 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 Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 411 | dc.update_distro_data(distro_check_dir, datetime, localdata) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 412 | |
| 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 | |
| 420 | addtask distro_checkall after do_distro_check |
| 421 | do_distro_checkall[recrdeptask] = "do_distro_checkall do_distro_check" |
| 422 | do_distro_checkall[recideptask] = "do_${BB_DEFAULT_TASK}" |
| 423 | do_distro_checkall[nostamp] = "1" |
| 424 | do_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 | # |
| 432 | addhandler checklicense_eventhandler |
| 433 | checklicense_eventhandler[eventmask] = "bb.event.BuildStarted" |
| 434 | python 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 | |
| 448 | addtask checklicense |
| 449 | do_checklicense[nostamp] = "1" |
| 450 | python 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 | |
| 472 | addtask checklicenseall after do_checklicense |
| 473 | do_checklicenseall[recrdeptask] = "do_checklicenseall do_checklicense" |
| 474 | do_checklicenseall[recideptask] = "do_${BB_DEFAULT_TASK}" |
| 475 | do_checklicenseall[nostamp] = "1" |
| 476 | do_checklicenseall() { |
| 477 | : |
| 478 | } |
| 479 | |
| 480 | |