Patchwork [3/3] package: fire an event with file sizes

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

Comments

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

Adding code to fire an event containing
file information for each of the build packages.

This event will be tracked in the UI clients.

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

Patch

diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 624a1ab..d35aa58 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1025,6 +1025,22 @@  python populate_packages () {
             if ret is False or ret == 0:
                 raise bb.build.FuncFailed("File population failed")
 
+
+
+    for pkg in package_list:
+        pkg_info_data = { 'PKG' : pkg }
+        root = os.path.join(pkgdest, pkg)
+
+        os.chdir(root)
+        pkg_info_data['FILES'] = []
+        import subprocess
+        for path in subprocess.Popen("find . -type f", shell=True, bufsize=16384, stdout=subprocess.PIPE).communicate()[0].rstrip().split("\n"):
+            if len(path) > 0:
+                size = os.stat(path).st_size
+                pkg_info_data['FILES'].append((path, size))
+
+        bb.event.fire(bb.event.MetadataEvent("PackageFileSize",pkg_info_data), d)
+
     os.chdir(workdir)
 
     unshipped = []
@@ -1188,7 +1204,9 @@  python emit_pkgdata() {
         for dfile in (d.getVar('FILERDEPENDSFLIST_' + pkg, True) or "").split():
             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
@@ -1857,7 +1875,7 @@  python do_package () {
     ###########################################################################
 
     # Contunually rexpanding complex expressions is inefficient, particularly when
-    # we write to the datastore and invalidate the expansion cache. This code 
+    # we write to the datastore and invalidate the expansion cache. This code
     # pre-expands some frequently used variables
 
     def expandVar(x, d):