From c0149ac6c4859a05a7a1f7310a9bd981caea8f2d Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Thu, 2 Aug 2012 10:23:04 +0100 Subject: classes/buildhistory: save preinst/postinst/prerm/postrm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Write the value of these package script variables into the packageinfo so that any changes to them can be tracked (in separate files since they are multi-line). Inspired by an earlier patch from Andreas Müller (From OE-Core rev: 988a417c857c01c87de6ba9602968059cf8d830f) Signed-off-by: Paul Eggleton Signed-off-by: Richard Purdie --- meta/classes/buildhistory.bbclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'meta/classes/buildhistory.bbclass') 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() { self.rrecommends = "" self.files = "" self.filelist = "" + # Variables that need to be written to their own separate file + self.filevars = dict.fromkeys(['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']) # Should check PACKAGES here to see if anything removed @@ -167,6 +169,8 @@ python buildhistory_emit_pkghistory() { pkginfo.rdepends = sortpkglist(squashspaces(getpkgvar(pkg, 'RDEPENDS') or "")) pkginfo.rrecommends = sortpkglist(squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "")) pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") + for filevar in pkginfo.filevars: + pkginfo.filevars[filevar] = getpkgvar(pkg, filevar) # Gather information about packaged files pkgdestpkg = os.path.join(pkgdest, pkg) @@ -191,16 +195,13 @@ def write_recipehistory(rcpinfo, d): pkghistdir = d.getVar('BUILDHISTORY_DIR_PACKAGE', True) infofile = os.path.join(pkghistdir, "latest") - f = open(infofile, "w") - try: + with open(infofile, "w") as f: if rcpinfo.pe != "0": f.write("PE = %s\n" % rcpinfo.pe) f.write("PV = %s\n" % rcpinfo.pv) f.write("PR = %s\n" % rcpinfo.pr) f.write("DEPENDS = %s\n" % rcpinfo.depends) f.write("PACKAGES = %s\n" % rcpinfo.packages) - finally: - f.close() def write_pkghistory(pkginfo, d): @@ -213,8 +214,7 @@ def write_pkghistory(pkginfo, d): os.makedirs(pkgpath) infofile = os.path.join(pkgpath, "latest") - f = open(infofile, "w") - try: + with open(infofile, "w") as f: if pkginfo.pe != "0": f.write("PE = %s\n" % pkginfo.pe) f.write("PV = %s\n" % pkginfo.pv) @@ -224,8 +224,16 @@ def write_pkghistory(pkginfo, d): f.write("PKGSIZE = %d\n" % pkginfo.size) f.write("FILES = %s\n" % pkginfo.files) f.write("FILELIST = %s\n" % pkginfo.filelist) - finally: - f.close() + + for filevar in pkginfo.filevars: + filevarpath = os.path.join(pkgpath, "latest.%s" % filevar) + val = pkginfo.filevars[filevar] + if val: + with open(filevarpath, "w") as f: + f.write(val) + else: + if os.path.exists(filevarpath): + os.unlink(filevarpath) buildhistory_get_image_installed() { -- cgit v1.2.3-54-g00ecf