diff options
Diffstat (limited to 'meta/classes/distrodata.bbclass')
-rw-r--r-- | meta/classes/distrodata.bbclass | 126 |
1 files changed, 65 insertions, 61 deletions
diff --git a/meta/classes/distrodata.bbclass b/meta/classes/distrodata.bbclass index 092c372204..1886805824 100644 --- a/meta/classes/distrodata.bbclass +++ b/meta/classes/distrodata.bbclass | |||
@@ -2,11 +2,16 @@ addhandler distro_eventhandler | |||
2 | distro_eventhandler[eventmask] = "bb.event.BuildStarted" | 2 | distro_eventhandler[eventmask] = "bb.event.BuildStarted" |
3 | python distro_eventhandler() { | 3 | python distro_eventhandler() { |
4 | import oe.distro_check as dc | 4 | import oe.distro_check as dc |
5 | import csv | ||
5 | logfile = dc.create_log_file(e.data, "distrodata.csv") | 6 | logfile = dc.create_log_file(e.data, "distrodata.csv") |
7 | |||
6 | lf = bb.utils.lockfile("%s.lock" % logfile) | 8 | lf = bb.utils.lockfile("%s.lock" % logfile) |
7 | f = open(logfile, "a") | 9 | with open(logfile, "a") as f: |
8 | f.write("Package,Description,Owner,License,VerMatch,Version,Upsteam,Reason,Recipe Status,Distro 1,Distro 2,Distro 3\n") | 10 | writer = csv.writer(f) |
9 | f.close() | 11 | writer.writerow(['Package', 'Description', 'Owner', 'License', |
12 | 'VerMatch', 'Version', 'Upsteam', 'Reason', 'Recipe Status', | ||
13 | 'Distro 1', 'Distro 2', 'Distro 3']) | ||
14 | f.close() | ||
10 | bb.utils.unlockfile(lf) | 15 | bb.utils.unlockfile(lf) |
11 | 16 | ||
12 | return | 17 | return |
@@ -98,6 +103,7 @@ python do_distrodata_np() { | |||
98 | addtask distrodata | 103 | addtask distrodata |
99 | do_distrodata[nostamp] = "1" | 104 | do_distrodata[nostamp] = "1" |
100 | python do_distrodata() { | 105 | python do_distrodata() { |
106 | import csv | ||
101 | logpath = d.getVar('LOG_DIR', True) | 107 | logpath = d.getVar('LOG_DIR', True) |
102 | bb.utils.mkdirhier(logpath) | 108 | bb.utils.mkdirhier(logpath) |
103 | logfile = os.path.join(logpath, "distrodata.csv") | 109 | logfile = os.path.join(logpath, "distrodata.csv") |
@@ -176,14 +182,13 @@ python do_distrodata() { | |||
176 | result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata) | 182 | result = dist_check.compare_in_distro_packages_list(distro_check_dir, localdata) |
177 | 183 | ||
178 | lf = bb.utils.lockfile("%s.lock" % logfile) | 184 | lf = bb.utils.lockfile("%s.lock" % logfile) |
179 | f = open(logfile, "a") | 185 | with open(logfile, "a") as f: |
180 | f.write("%s,%s,%s,%s,%s,%s,%s,%s,%s" % \ | 186 | row = [pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus] |
181 | (pname, pdesc, maintainer, plicense, vermatch, pcurver, pupver, noupdate_reason, rstatus)) | 187 | row.extend(result) |
182 | line = "" | 188 | |
183 | for i in result: | 189 | writer = csv.writer(f) |
184 | line = line + "," + i | 190 | writer.writerow(row) |
185 | f.write(line + "\n") | 191 | f.close() |
186 | f.close() | ||
187 | bb.utils.unlockfile(lf) | 192 | bb.utils.unlockfile(lf) |
188 | } | 193 | } |
189 | 194 | ||
@@ -198,45 +203,33 @@ do_distrodataall() { | |||
198 | addhandler checkpkg_eventhandler | 203 | addhandler checkpkg_eventhandler |
199 | checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted" | 204 | checkpkg_eventhandler[eventmask] = "bb.event.BuildStarted bb.event.BuildCompleted" |
200 | python checkpkg_eventhandler() { | 205 | python checkpkg_eventhandler() { |
206 | import csv | ||
207 | |||
201 | def parse_csv_file(filename): | 208 | def parse_csv_file(filename): |
202 | package_dict = {} | 209 | package_dict = {} |
203 | fd = open(filename, "r") | 210 | |
204 | lines = fd.read().rsplit("\n") | 211 | with open(filename, "r") as f: |
205 | fd.close() | 212 | reader = csv.reader(f, delimiter='\t') |
206 | 213 | for row in reader: | |
207 | first_line = '' | 214 | pn = row[0] |
208 | index = 0 | 215 | |
209 | for line in lines: | 216 | if reader.line_num == 1: |
210 | #Skip the first line | 217 | header = row |
211 | if index == 0: | ||
212 | first_line = line | ||
213 | index += 1 | ||
214 | continue | ||
215 | elif line == '': | ||
216 | continue | ||
217 | index += 1 | ||
218 | package_name = line.rsplit("\t")[0] | ||
219 | if '-native' in package_name or 'nativesdk-' in package_name: | ||
220 | original_name = package_name.rsplit('-native')[0] | ||
221 | if original_name == '': | ||
222 | original_name = package_name.rsplit('nativesdk-')[0] | ||
223 | if original_name in package_dict: | ||
224 | continue | 218 | continue |
225 | else: | 219 | |
226 | package_dict[package_name] = line | 220 | if '-native' in pn or 'nativesdk-' in pn: |
227 | else: | 221 | continue |
228 | new_name = package_name + "-native" | 222 | |
229 | if not(new_name in package_dict): | 223 | if not pn in package_dict.keys(): |
230 | new_name = 'nativesdk-' + package_name | 224 | package_dict[pn] = row |
231 | if new_name in package_dict: | 225 | f.close() |
232 | del package_dict[new_name] | 226 | |
233 | package_dict[package_name] = line | 227 | with open(filename, "w") as f: |
234 | 228 | writer = csv.writer(f, delimiter='\t') | |
235 | fd = open(filename, "w") | 229 | writer.writerow(header) |
236 | fd.write("%s\n"%first_line) | 230 | for pn in package_dict.keys(): |
237 | for el in package_dict: | 231 | writer.writerow(package_dict[pn]) |
238 | fd.write(package_dict[el] + "\n") | 232 | f.close() |
239 | fd.close() | ||
240 | 233 | ||
241 | del package_dict | 234 | del package_dict |
242 | 235 | ||
@@ -245,9 +238,13 @@ python checkpkg_eventhandler() { | |||
245 | logfile = dc.create_log_file(e.data, "checkpkg.csv") | 238 | logfile = dc.create_log_file(e.data, "checkpkg.csv") |
246 | 239 | ||
247 | lf = bb.utils.lockfile("%s.lock" % logfile) | 240 | lf = bb.utils.lockfile("%s.lock" % logfile) |
248 | f = open(logfile, "a") | 241 | with open(logfile, "a") as f: |
249 | f.write("Package\tVersion\tUpver\tLicense\tSection\tHome\tRelease\tDepends\tBugTracker\tPE\tDescription\tStatus\tTracking\tURI\tMAINTAINER\tNoUpReason\n") | 242 | writer = csv.writer(f, delimiter='\t') |
250 | f.close() | 243 | headers = ['Package', 'Version', 'Upver', 'License', 'Section', |
244 | 'Home', 'Release', 'Depends', 'BugTracker', 'PE', 'Description', | ||
245 | 'Status', 'Tracking', 'URI', 'MAINTAINER', 'NoUpReason'] | ||
246 | writer.writerow(headers) | ||
247 | f.close() | ||
251 | bb.utils.unlockfile(lf) | 248 | bb.utils.unlockfile(lf) |
252 | elif bb.event.getName(e) == "BuildCompleted": | 249 | elif bb.event.getName(e) == "BuildCompleted": |
253 | import os | 250 | import os |
@@ -263,6 +260,7 @@ addtask checkpkg | |||
263 | do_checkpkg[nostamp] = "1" | 260 | do_checkpkg[nostamp] = "1" |
264 | python do_checkpkg() { | 261 | python do_checkpkg() { |
265 | localdata = bb.data.createCopy(d) | 262 | localdata = bb.data.createCopy(d) |
263 | import csv | ||
266 | import re | 264 | import re |
267 | import tempfile | 265 | import tempfile |
268 | import subprocess | 266 | import subprocess |
@@ -371,14 +369,17 @@ python do_checkpkg() { | |||
371 | else: | 369 | else: |
372 | pmstatus = "" | 370 | pmstatus = "" |
373 | 371 | ||
372 | psrcuri = psrcuri.split()[0] | ||
374 | pdepends = "".join(pdepends.split("\t")) | 373 | pdepends = "".join(pdepends.split("\t")) |
375 | pdesc = "".join(pdesc.split("\t")) | 374 | pdesc = "".join(pdesc.split("\t")) |
376 | no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON', True) | 375 | no_upgr_reason = d.getVar('RECIPE_NO_UPDATE_REASON', True) |
377 | lf = bb.utils.lockfile("%s.lock" % logfile) | 376 | lf = bb.utils.lockfile("%s.lock" % logfile) |
378 | f = open(logfile, "a") | 377 | with open(logfile, "a") as f: |
379 | f.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % \ | 378 | writer = csv.writer(f, delimiter='\t') |
380 | (pname,pversion,pupver,plicense,psection, phome,prelease, pdepends,pbugtracker,ppe,pdesc,pstatus,pmver,psrcuri,maintainer, no_upgr_reason)) | 379 | writer.writerow([pname, pversion, pupver, plicense, psection, phome, |
381 | f.close() | 380 | prelease, pdepends, pbugtracker, ppe, pdesc, pstatus, pmver, |
381 | psrcuri, maintainer, no_upgr_reason]) | ||
382 | f.close() | ||
382 | bb.utils.unlockfile(lf) | 383 | bb.utils.unlockfile(lf) |
383 | } | 384 | } |
384 | 385 | ||
@@ -441,12 +442,14 @@ addhandler checklicense_eventhandler | |||
441 | checklicense_eventhandler[eventmask] = "bb.event.BuildStarted" | 442 | checklicense_eventhandler[eventmask] = "bb.event.BuildStarted" |
442 | python checklicense_eventhandler() { | 443 | python checklicense_eventhandler() { |
443 | """initialize log files.""" | 444 | """initialize log files.""" |
445 | import csv | ||
444 | import oe.distro_check as dc | 446 | import oe.distro_check as dc |
445 | logfile = dc.create_log_file(e.data, "missinglicense.csv") | 447 | logfile = dc.create_log_file(e.data, "missinglicense.csv") |
446 | lf = bb.utils.lockfile("%s.lock" % logfile) | 448 | lf = bb.utils.lockfile("%s.lock" % logfile) |
447 | f = open(logfile, "a") | 449 | with open(logfile, "a") as f: |
448 | f.write("Package\tLicense\tMissingLicense\n") | 450 | writer = csv.writer(f, delimiter='\t') |
449 | f.close() | 451 | writer.writerow(['Package', 'License', 'MissingLicense']) |
452 | f.close() | ||
450 | bb.utils.unlockfile(lf) | 453 | bb.utils.unlockfile(lf) |
451 | return | 454 | return |
452 | } | 455 | } |
@@ -454,6 +457,7 @@ python checklicense_eventhandler() { | |||
454 | addtask checklicense | 457 | addtask checklicense |
455 | do_checklicense[nostamp] = "1" | 458 | do_checklicense[nostamp] = "1" |
456 | python do_checklicense() { | 459 | python do_checklicense() { |
460 | import csv | ||
457 | import shutil | 461 | import shutil |
458 | logpath = d.getVar('LOG_DIR', True) | 462 | logpath = d.getVar('LOG_DIR', True) |
459 | bb.utils.mkdirhier(logpath) | 463 | bb.utils.mkdirhier(logpath) |
@@ -466,10 +470,10 @@ python do_checklicense() { | |||
466 | .replace(',', '').replace(" ", "").split("&"))): | 470 | .replace(',', '').replace(" ", "").split("&"))): |
467 | if not os.path.isfile(os.path.join(generic_directory, license_type)): | 471 | if not os.path.isfile(os.path.join(generic_directory, license_type)): |
468 | lf = bb.utils.lockfile("%s.lock" % logfile) | 472 | lf = bb.utils.lockfile("%s.lock" % logfile) |
469 | f = open(logfile, "a") | 473 | with open(logfile, "a") as f: |
470 | f.write("%s\t%s\t%s\n" % \ | 474 | writer = csv.writer(f, delimiter='\t') |
471 | (pn,license_types,license_type)) | 475 | writer.writerow([pn, license_types, license_type]) |
472 | f.close() | 476 | f.close() |
473 | bb.utils.unlockfile(lf) | 477 | bb.utils.unlockfile(lf) |
474 | return | 478 | return |
475 | } | 479 | } |