Patchwork [2/3] package.bbclass: trigger event when collecting package info

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 24, 2013, 4:36 p.m.
Message ID <3145da4c2b158fd0e2684b66cd68dd769a1c94de.1380040307.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/58683/
State New
Headers show

Comments

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

Adding an event that contains the package details,
which is triggered when the emit_pkgdata runs.
This is used to collect package information in the UI clients.

Slight rewrite of the file-writing section as to make
the code easier to maintain.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 meta/classes/package.bbclass | 41 +++++++++++++----------------------------
 1 file changed, 13 insertions(+), 28 deletions(-)
Richard Purdie - Sept. 24, 2013, 4:44 p.m.
On Tue, 2013-09-24 at 17:36 +0100, Alex DAMIAN wrote:
> From: Alexandru DAMIAN <alexandru.damian@intel.com>
> 
> Adding an event that contains the package details,
> which is triggered when the emit_pkgdata runs.
> This is used to collect package information in the UI clients.
> 
> Slight rewrite of the file-writing section as to make
> the code easier to maintain.
> 
> Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
> ---
>  meta/classes/package.bbclass | 41 +++++++++++++----------------------------
>  1 file changed, 13 insertions(+), 28 deletions(-)

Simply put, this isn't going in and it isn't right.

If you want to do this, please do this in a different class file which
hooks into the packaging code and generates the event needed, preferably
with one event rather than two.

The class can then be inherited when webhob is enabled (and removed from
influencing the sstate checksums).

Cheers,

Richard
Otavio Salvador - Sept. 24, 2013, 4:44 p.m.
On Tue, Sep 24, 2013 at 1:36 PM, Alex DAMIAN <alexandru.damian@intel.com> wrote:
> Slight rewrite of the file-writing section as to make
> the code easier to maintain.

Please split the code rewrite in another patch.

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index fbb6839..624a1ab 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,25 @@  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')
+        for vn in ('PN',  'PV',  'PR',  'PKGV',  'PKGR',  'LICENSE',  'DESCRIPTION',  'SUMMARY',  'RDEPENDS',  'RPROVIDES',  'RRECOMMENDS',  'RSUGGESTS',  'RREPLACES',  'RCONFLICTS',  'SECTION',  'PKG',  'ALLOW_EMPTY',  'FILES',  'pkg_postinst',  'pkg_postrm',  'pkg_preinst',  'pkg_prerm',  'FILERPROVIDESFLIST',  'FILES_INFO', 'FILERDEPENDSFLIST'):
+            lpkgdata[vn] = write_if_exists(sf, pkg, vn)
+
         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')
         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)))
         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)