Patchwork [1/2] package.bbclass: fire an event with package info

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 26, 2013, 4:01 p.m.
Message ID <1380211301-23898-1-git-send-email-alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/59037/
State New
Headers show

Comments

Alexandru DAMIAN - Sept. 26, 2013, 4:01 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

On emit_pkgdata, the code writes a file with all the
package details like PN, PV, PR, LICENSE, etc...

In order to record package information on a remote client,
we also build out a custom event with this information
and fire it.

This will not have any performance impact, and allow
us to retrieve data about built packages from a
remote build server.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 meta/classes/package.bbclass | 67 +++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 29 deletions(-)

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index fbb6839..67ee138 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1106,10 +1106,11 @@  python emit_pkgdata() {
         val = d.getVar('%s_%s' % (var, pkg), True)
         if val:
             f.write('%s_%s: %s\n' % (var, pkg, encode(val)))
-            return
+            return encode(val)
         val = d.getVar('%s' % (var), True)
         if val:
             f.write('%s: %s\n' % (var, encode(val)))
+            return encode(val)
         return
 
     def get_directory_size(dir):
@@ -1175,41 +1176,49 @@  python emit_pkgdata() {
 
         d.setVar('FILES_INFO', str(items))
 
+        lpkgdata = {}
+
         sf = open(subdata_file, 'w')
-        write_if_exists(sf, pkg, 'PN')
-        write_if_exists(sf, pkg, 'PV')
-        write_if_exists(sf, pkg, 'PR')
-        write_if_exists(sf, pkg, 'PKGV')
-        write_if_exists(sf, pkg, 'PKGR')
-        write_if_exists(sf, pkg, 'LICENSE')
-        write_if_exists(sf, pkg, 'DESCRIPTION')
-        write_if_exists(sf, pkg, 'SUMMARY')
-        write_if_exists(sf, pkg, 'RDEPENDS')
-        write_if_exists(sf, pkg, 'RPROVIDES')
-        write_if_exists(sf, pkg, 'RRECOMMENDS')
-        write_if_exists(sf, pkg, 'RSUGGESTS')
-        write_if_exists(sf, pkg, 'RREPLACES')
-        write_if_exists(sf, pkg, 'RCONFLICTS')
-        write_if_exists(sf, pkg, 'SECTION')
-        write_if_exists(sf, pkg, 'PKG')
-        write_if_exists(sf, pkg, 'ALLOW_EMPTY')
-        write_if_exists(sf, pkg, 'FILES')
-        write_if_exists(sf, pkg, 'pkg_postinst')
-        write_if_exists(sf, pkg, 'pkg_postrm')
-        write_if_exists(sf, pkg, 'pkg_preinst')
-        write_if_exists(sf, pkg, 'pkg_prerm')
-        write_if_exists(sf, pkg, 'FILERPROVIDESFLIST')
-        write_if_exists(sf, pkg, 'FILES_INFO')
+        lpkgdata['PN'] = write_if_exists(sf, pkg, 'PN')
+        lpkgdata['PV'] = write_if_exists(sf, pkg, 'PV')
+        lpkgdata['PR'] = write_if_exists(sf, pkg, 'PR')
+        lpkgdata['PKGV'] = write_if_exists(sf, pkg, 'PKGV')
+        lpkgdata['PKGR'] = write_if_exists(sf, pkg, 'PKGR')
+        lpkgdata['LICENSE'] = write_if_exists(sf, pkg, 'LICENSE')
+        lpkgdata['DESCRIPTION'] = write_if_exists(sf, pkg, 'DESCRIPTION')
+        lpkgdata['SUMMARY'] = write_if_exists(sf, pkg, 'SUMMARY')
+        lpkgdata['RDEPENDS'] = write_if_exists(sf, pkg, 'RDEPENDS')
+        lpkgdata['RPROVIDES'] = write_if_exists(sf, pkg, 'RPROVIDES')
+        lpkgdata['RRECOMMENDS'] = write_if_exists(sf, pkg, 'RRECOMMENDS')
+        lpkgdata['RSUGGESTS'] = write_if_exists(sf, pkg, 'RSUGGESTS')
+        lpkgdata['RREPLACES'] = write_if_exists(sf, pkg, 'RREPLACES')
+        lpkgdata['RCONFLICTS'] = write_if_exists(sf, pkg, 'RCONFLICTS')
+        lpkgdata['SECTION'] = write_if_exists(sf, pkg, 'SECTION')
+        lpkgdata['PKG'] = write_if_exists(sf, pkg, 'PKG')
+        lpkgdata['ALLOW_EMPTY'] = write_if_exists(sf, pkg, 'ALLOW_EMPTY')
+        lpkgdata['FILES'] = write_if_exists(sf, pkg, 'FILES')
+        lpkgdata['pkg_postinst'] = write_if_exists(sf, pkg, 'pkg_postinst')
+        lpkgdata['pkg_postrm'] = write_if_exists(sf, pkg, 'pkg_postrm')
+        lpkgdata['pkg_preinst'] = write_if_exists(sf, pkg, 'pkg_preinst')
+        lpkgdata['pkg_prerm'] = write_if_exists(sf, pkg, 'pkg_prerm')
+        lpkgdata['FILERPROVIDESFLIST'] = write_if_exists(sf, pkg, 'FILERPROVIDESFLIST')
+        lpkgdata['FILES_INFO'] = write_if_exists(sf, pkg, 'FILES_INFO')
         for dfile in (d.getVar('FILERPROVIDESFLIST_' + pkg, True) or "").split():
-            write_if_exists(sf, pkg, 'FILERPROVIDES_' + dfile)
+            lpkgdata['FILERDEPENDSFLIST_'+dfile] = write_if_exists(sf, pkg, 'FILERPROVIDES_' + dfile)
 
-        write_if_exists(sf, pkg, 'FILERDEPENDSFLIST')
+        lpkgdata['FILERDEPENDSFLIST'] = write_if_exists(sf, pkg, 'FILERDEPENDSFLIST')
         for dfile in (d.getVar('FILERDEPENDSFLIST_' + pkg, True) or "").split():
-            write_if_exists(sf, pkg, 'FILERDEPENDS_' + dfile)
+            lpkgdata['FILERDEPENDS_'+dfile] = write_if_exists(sf, pkg, 'FILERDEPENDS_' + dfile)
 
-        sf.write('%s_%s: %s\n' % ('PKGSIZE', pkg, get_directory_size(pkgdest + "/%s" % pkg)))
+        lsize = get_directory_size(pkgdest + "/%s" % pkg)
+        sf.write('%s_%s: %s\n' % ('PKGSIZE', pkg, lsize ))
+        lpkgdata['PKGSIZE'] = lsize
         sf.close()
 
+        # Fire an event containing the pkg data
+        bb.event.fire(bb.event.MetadataEvent("SinglePackageInfo", lpkgdata), d)
+
+
         # Symlinks needed for reverse lookups (from the final package name)
         subdata_sym = pkgdatadir + "/runtime-reverse/%s" % pkgval
         oe.path.symlink("../runtime/%s" % pkg, subdata_sym, True)