[OE-core] [PATCH 3/3] package: fire an event with file sizes

Alex DAMIAN alexandru.damian at intel.com
Tue Sep 24 16:36:07 UTC 2013


From: Alexandru DAMIAN <alexandru.damian at 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 at intel.com>
---
 meta/classes/package.bbclass | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

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):
-- 
1.8.1.2




More information about the Openembedded-core mailing list