[OE-core] [PATCHv3 5/5] license_class: license_create_manifest improvment

Aníbal Limón anibal.limon at linux.intel.com
Fri May 8 20:41:32 UTC 2015


Use image_list_installed_packges instead of open manually the package
manifest and iterate over it.

Signed-off-by: Aníbal Limón <anibal.limon at linux.intel.com>
---
 meta/classes/license.bbclass | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 54ab123..7972c79 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -28,6 +28,7 @@ python write_package_manifest() {
 python license_create_manifest() {
     import re
     import oe.packagedata
+    from oe.rootfs import image_list_installed_packages
 
     bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
     bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
@@ -38,19 +39,15 @@ python license_create_manifest() {
         return 0
 
     pkg_dic = {}
-    package_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
-                        d.getVar('IMAGE_NAME', True), 'package.manifest')
-    with open(package_manifest, "r") as package_file:
-        pkg_list = package_file.read().split()
-        for pkg in pkg_list:
-            pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
-                                    'runtime-reverse', pkg)
-            pkg_name = os.path.basename(os.readlink(pkg_info))
-
-            pkg_dic[pkg_name] = oe.packagedata.read_pkgdatafile(pkg_info)
-            if not "LICENSE" in pkg_dic[pkg_name].keys():
-                pkg_lic_name = "LICENSE_" + pkg_name
-                pkg_dic[pkg_name]["LICENSE"] = pkg_dic[pkg_name][pkg_lic_name]
+    for pkg in image_list_installed_packages(d).split("\n"):
+        pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
+                                'runtime-reverse', pkg)
+        pkg_name = os.path.basename(os.readlink(pkg_info))
+
+        pkg_dic[pkg_name] = oe.packagedata.read_pkgdatafile(pkg_info)
+        if not "LICENSE" in pkg_dic[pkg_name].keys():
+            pkg_lic_name = "LICENSE_" + pkg_name
+            pkg_dic[pkg_name]["LICENSE"] = pkg_dic[pkg_name][pkg_lic_name]
 
     license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
                         d.getVar('IMAGE_NAME', True), 'license.manifest')
-- 
1.8.4.5




More information about the Openembedded-core mailing list