Patchwork buildhistory.bbclass: add pkg_pre/postinst/rm contents

login
register
mail settings
Submitter Andreas Müller
Date May 27, 2012, 6:29 p.m.
Message ID <1338143382-5982-1-git-send-email-schnitzeltony@googlemail.com>
Download mbox | patch
Permalink /patch/28845/
State Superseded
Headers show

Comments

Andreas Müller - May 27, 2012, 6:29 p.m.
A use-case would have been [1].

The following tests were performed:
* image from scratch with old buildhistory contents
* image from scratch with buildhistory contents from scratch
* decrement a PR for a test recipe and check if the message
  'ERROR: Package version for xy went backwards' is displayed.

[1] http://patches.openembedded.org/patch/28841/

Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
 meta/classes/buildhistory.bbclass |   80 +++++++++++++++++++++++--------------
 1 files changed, 50 insertions(+), 30 deletions(-)
Paul Eggleton - May 28, 2012, 1:19 p.m.
On Sunday 27 May 2012 20:29:42 Andreas Müller wrote:
> A use-case would have been [1].
> 
> The following tests were performed:
> * image from scratch with old buildhistory contents
> * image from scratch with buildhistory contents from scratch
> * decrement a PR for a test recipe and check if the message
>   'ERROR: Package version for xy went backwards' is displayed.
> 
> [1] http://patches.openembedded.org/patch/28841/

FWIW I hadn't forgotten about this feature request, although I hadn't got 
around to implementing it yet.

I haven't tested your patch but if I read it correctly you are writing the 
scripts out underneath the "value =" lines in the package data file. My concern 
with doing this is that it makes those files more difficult to parse. I had 
thought that the way to do it would be to write these scripts to separate files 
(e.g. latest.pkg_prerm, latest.pkg_postrm etc.). Would that be OK?

Cheers,
Paul

Patch

diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index d2d19ff..9c49bab 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -57,6 +57,10 @@  python buildhistory_emit_pkghistory() {
 			self.rrecommends = ""
 			self.files = ""
 			self.filelist = ""
+			self.preinst = ""
+			self.postinst = ""
+			self.prerm = ""
+			self.postrm = ""
 
 	# Should check PACKAGES here to see if anything removed
 
@@ -74,18 +78,19 @@  python buildhistory_emit_pkghistory() {
 		try:
 			for line in f:
 				lns = line.split('=')
-				name = lns[0].strip()
-				value = lns[1].strip(" \t\r\n").strip('"')
-				if name == "PE":
-					rcpinfo.pe = value
-				elif name == "PV":
-					rcpinfo.pv = value
-				elif name == "PR":
-					rcpinfo.pr = value
-				elif name == "DEPENDS":
-					rcpinfo.depends = value
-				elif name == "PACKAGES":
-					rcpinfo.packages = value
+				if len(lns)==2:
+					name = lns[0].strip()
+					value = lns[1].strip(" \t\r\n").strip('"')
+					if name == "PE":
+						rcpinfo.pe = value
+					elif name == "PV":
+						rcpinfo.pv = value
+					elif name == "PR":
+						rcpinfo.pr = value
+					elif name == "DEPENDS":
+						rcpinfo.depends = value
+					elif name == "PACKAGES":
+						rcpinfo.packages = value
 		finally:
 			f.close()
 		return rcpinfo
@@ -96,24 +101,25 @@  python buildhistory_emit_pkghistory() {
 		try:
 			for line in f:
 				lns = line.split('=')
-				name = lns[0].strip()
-				value = lns[1].strip(" \t\r\n").strip('"')
-				if name == "PE":
-					pkginfo.pe = value
-				elif name == "PV":
-					pkginfo.pv = value
-				elif name == "PR":
-					pkginfo.pr = value
-				elif name == "RDEPENDS":
-					pkginfo.rdepends = value
-				elif name == "RRECOMMENDS":
-					pkginfo.rrecommends = value
-				elif name == "PKGSIZE":
-					pkginfo.size = long(value)
-				elif name == "FILES":
-					pkginfo.files = value
-				elif name == "FILELIST":
-					pkginfo.filelist = value
+				if len(lns)==2:
+					name = lns[0].strip()
+					value = lns[1].strip(" \t\r\n").strip('"')
+					if name == "PE":
+						pkginfo.pe = value
+					elif name == "PV":
+						pkginfo.pv = value
+					elif name == "PR":
+						pkginfo.pr = value
+					elif name == "RDEPENDS":
+						pkginfo.rdepends = value
+					elif name == "RRECOMMENDS":
+						pkginfo.rrecommends = value
+					elif name == "PKGSIZE":
+						pkginfo.size = long(value)
+					elif name == "FILES":
+						pkginfo.files = value
+					elif name == "FILELIST":
+						pkginfo.filelist = value
 		finally:
 			f.close()
 		return pkginfo
@@ -198,6 +204,12 @@  python buildhistory_emit_pkghistory() {
 		filelist.sort()
 		pkginfo.filelist = " ".join(filelist)
 
+		# pre/postinst/rm
+		pkginfo.preinst = getpkgvar(pkg, 'pkg_preinst') or ""
+		pkginfo.postinst = getpkgvar(pkg, 'pkg_postinst') or ""
+		pkginfo.prerm = getpkgvar(pkg, 'pkg_prerm') or ""
+		pkginfo.postrm = getpkgvar(pkg, 'pkg_postrm') or ""
+
 		write_pkghistory(pkginfo, d)
 
 		write_latestlink(pkg, pe, pv, pr, d)
@@ -246,6 +258,14 @@  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)
+		if pkginfo.preinst != "":
+			f.write("\npkg_preinst=\n%s\n" %  pkginfo.preinst)
+		if pkginfo.postinst != "":
+			f.write("\npkg_postinst=\n%s\n" %  pkginfo.postinst)
+		if pkginfo.prerm != "":
+			f.write("\npkg_prerm=\n%s\n" %  pkginfo.prerm)
+		if pkginfo.postrm != "":
+			f.write("\npkg_postrm=\n%s\n" %  pkginfo.postrm)
 	finally:
 		f.close()