diff options
| -rw-r--r-- | meta/classes/buildhistory.bbclass | 24 | ||||
| -rw-r--r-- | meta/lib/oe/buildhistory_analysis.py | 50 |
2 files changed, 65 insertions, 9 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass index 510a6df85a..200d03192e 100644 --- a/meta/classes/buildhistory.bbclass +++ b/meta/classes/buildhistory.bbclass | |||
| @@ -57,6 +57,8 @@ python buildhistory_emit_pkghistory() { | |||
| 57 | self.rrecommends = "" | 57 | self.rrecommends = "" |
| 58 | self.files = "" | 58 | self.files = "" |
| 59 | self.filelist = "" | 59 | self.filelist = "" |
| 60 | # Variables that need to be written to their own separate file | ||
| 61 | self.filevars = dict.fromkeys(['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']) | ||
| 60 | 62 | ||
| 61 | # Should check PACKAGES here to see if anything removed | 63 | # Should check PACKAGES here to see if anything removed |
| 62 | 64 | ||
| @@ -167,6 +169,8 @@ python buildhistory_emit_pkghistory() { | |||
| 167 | pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) | 169 | pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) |
| 168 | pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) | 170 | pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) |
| 169 | pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") | 171 | pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") |
| 172 | for filevar in pkginfo.filevars: | ||
| 173 | pkginfo.filevars[filevar] = getpkgvar(pkg, filevar) | ||
| 170 | 174 | ||
| 171 | # Gather information about packaged files | 175 | # Gather information about packaged files |
| 172 | pkgdestpkg = os.path.join(pkgdest, pkg) | 176 | pkgdestpkg = os.path.join(pkgdest, pkg) |
| @@ -191,16 +195,13 @@ def write_recipehistory(rcpinfo, d): | |||
| 191 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) | 195 | pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) |
| 192 | 196 | ||
| 193 | infofile = os.path.join(pkghistdir, "latest") | 197 | infofile = os.path.join(pkghistdir, "latest") |
| 194 | f = open(infofile, "w") | 198 | with open(infofile, "w") as f: |
| 195 | try: | ||
| 196 | if rcpinfo.pe != "0": | 199 | if rcpinfo.pe != "0": |
| 197 | f.write("PE = %s\n" % rcpinfo.pe) | 200 | f.write("PE = %s\n" % rcpinfo.pe) |
| 198 | f.write("PV = %s\n" % rcpinfo.pv) | 201 | f.write("PV = %s\n" % rcpinfo.pv) |
| 199 | f.write("PR = %s\n" % rcpinfo.pr) | 202 | f.write("PR = %s\n" % rcpinfo.pr) |
| 200 | f.write("DEPENDS = %s\n" % rcpinfo.depends) | 203 | f.write("DEPENDS = %s\n" % rcpinfo.depends) |
| 201 | f.write("PACKAGES = %s\n" % rcpinfo.packages) | 204 | f.write("PACKAGES = %s\n" % rcpinfo.packages) |
| 202 | finally: | ||
| 203 | f.close() | ||
| 204 | 205 | ||
| 205 | 206 | ||
| 206 | def write_pkghistory(pkginfo, d): | 207 | def write_pkghistory(pkginfo, d): |
| @@ -213,8 +214,7 @@ def write_pkghistory(pkginfo, d): | |||
| 213 | os.makedirs(pkgpath) | 214 | os.makedirs(pkgpath) |
| 214 | 215 | ||
| 215 | infofile = os.path.join(pkgpath, "latest") | 216 | infofile = os.path.join(pkgpath, "latest") |
| 216 | f = open(infofile, "w") | 217 | with open(infofile, "w") as f: |
| 217 | try: | ||
| 218 | if pkginfo.pe != "0": | 218 | if pkginfo.pe != "0": |
| 219 | f.write("PE = %s\n" % pkginfo.pe) | 219 | f.write("PE = %s\n" % pkginfo.pe) |
| 220 | f.write("PV = %s\n" % pkginfo.pv) | 220 | f.write("PV = %s\n" % pkginfo.pv) |
| @@ -224,8 +224,16 @@ def write_pkghistory(pkginfo, d): | |||
| 224 | f.write("PKGSIZE = %d\n" % pkginfo.size) | 224 | f.write("PKGSIZE = %d\n" % pkginfo.size) |
| 225 | f.write("FILES = %s\n" % pkginfo.files) | 225 | f.write("FILES = %s\n" % pkginfo.files) |
| 226 | f.write("FILELIST = %s\n" % pkginfo.filelist) | 226 | f.write("FILELIST = %s\n" % pkginfo.filelist) |
| 227 | finally: | 227 | |
| 228 | f.close() | 228 | for filevar in pkginfo.filevars: |
| 229 | filevarpath = os.path.join(pkgpath, "latest.%s" % filevar) | ||
| 230 | val = pkginfo.filevars[filevar] | ||
| 231 | if val: | ||
| 232 | with open(filevarpath, "w") as f: | ||
| 233 | f.write(val) | ||
| 234 | else: | ||
| 235 | if os.path.exists(filevarpath): | ||
| 236 | os.unlink(filevarpath) | ||
| 229 | 237 | ||
| 230 | 238 | ||
| 231 | buildhistory_get_image_installed() { | 239 | buildhistory_get_image_installed() { |
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py index 29dc4a9ecf..6c6a085d19 100644 --- a/meta/lib/oe/buildhistory_analysis.py +++ b/meta/lib/oe/buildhistory_analysis.py | |||
| @@ -90,6 +90,18 @@ class ChangeRecord: | |||
| 90 | else: | 90 | else: |
| 91 | percentchg = 100 | 91 | percentchg = 100 |
| 92 | out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg) | 92 | out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg) |
| 93 | elif self.fieldname in ['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']: | ||
| 94 | if self.oldvalue and self.newvalue: | ||
| 95 | out = '%s changed:\n ' % self.fieldname | ||
| 96 | elif self.newvalue: | ||
| 97 | out = '%s added:\n ' % self.fieldname | ||
| 98 | elif self.oldvalue: | ||
| 99 | out = '%s cleared:\n ' % self.fieldname | ||
| 100 | alines = self.oldvalue.splitlines() | ||
| 101 | blines = self.newvalue.splitlines() | ||
| 102 | diff = difflib.unified_diff(alines, blines, self.fieldname, self.fieldname, lineterm='') | ||
| 103 | out += '\n '.join(list(diff)[2:]) | ||
| 104 | out += '\n --' | ||
| 93 | elif self.fieldname in img_monitor_files: | 105 | elif self.fieldname in img_monitor_files: |
| 94 | if outer: | 106 | if outer: |
| 95 | prefix = 'Changes to %s ' % self.path | 107 | prefix = 'Changes to %s ' % self.path |
| @@ -330,7 +342,12 @@ def process_changes(repopath, revision1, revision2 = 'HEAD', report_all = False) | |||
| 330 | for d in diff.iter_change_type('M'): | 342 | for d in diff.iter_change_type('M'): |
| 331 | path = os.path.dirname(d.a_blob.path) | 343 | path = os.path.dirname(d.a_blob.path) |
| 332 | if path.startswith('packages/'): | 344 | if path.startswith('packages/'): |
| 333 | changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all)) | 345 | filename = os.path.basename(d.a_blob.path) |
| 346 | if filename == 'latest': | ||
| 347 | changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all)) | ||
| 348 | elif filename.startswith('latest.'): | ||
| 349 | chg = ChangeRecord(path, filename, d.a_blob.data_stream.read(), d.b_blob.data_stream.read(), True) | ||
| 350 | changes.append(chg) | ||
| 334 | elif path.startswith('images/'): | 351 | elif path.startswith('images/'): |
| 335 | filename = os.path.basename(d.a_blob.path) | 352 | filename = os.path.basename(d.a_blob.path) |
| 336 | if filename in img_monitor_files: | 353 | if filename in img_monitor_files: |
| @@ -356,6 +373,37 @@ def process_changes(repopath, revision1, revision2 = 'HEAD', report_all = False) | |||
| 356 | elif filename == 'image-info.txt': | 373 | elif filename == 'image-info.txt': |
| 357 | changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all)) | 374 | changes.extend(compare_dict_blobs(path, d.a_blob, d.b_blob, report_all)) |
| 358 | 375 | ||
| 376 | # Look for added preinst/postinst/prerm/postrm | ||
| 377 | # (without reporting newly added recipes) | ||
| 378 | addedpkgs = [] | ||
| 379 | addedchanges = [] | ||
| 380 | for d in diff.iter_change_type('A'): | ||
| 381 | path = os.path.dirname(d.b_blob.path) | ||
| 382 | if path.startswith('packages/'): | ||
| 383 | filename = os.path.basename(d.b_blob.path) | ||
| 384 | if filename == 'latest': | ||
| 385 | addedpkgs.append(path) | ||
| 386 | elif filename.startswith('latest.'): | ||
| 387 | chg = ChangeRecord(path, filename[7:], '', d.b_blob.data_stream.read(), True) | ||
| 388 | addedchanges.append(chg) | ||
| 389 | for chg in addedchanges: | ||
| 390 | found = False | ||
| 391 | for pkg in addedpkgs: | ||
| 392 | if chg.path.startswith(pkg): | ||
| 393 | found = True | ||
| 394 | break | ||
| 395 | if not found: | ||
| 396 | changes.append(chg) | ||
| 397 | |||
| 398 | # Look for cleared preinst/postinst/prerm/postrm | ||
| 399 | for d in diff.iter_change_type('D'): | ||
| 400 | path = os.path.dirname(d.a_blob.path) | ||
| 401 | if path.startswith('packages/'): | ||
| 402 | filename = os.path.basename(d.a_blob.path) | ||
| 403 | if filename != 'latest' and filename.startswith('latest.'): | ||
| 404 | chg = ChangeRecord(path, filename[7:], d.a_blob.data_stream.read(), '', True) | ||
| 405 | changes.append(chg) | ||
| 406 | |||
| 359 | # Link related changes | 407 | # Link related changes |
| 360 | for chg in changes: | 408 | for chg in changes: |
| 361 | if chg.monitored: | 409 | if chg.monitored: |
