[OE-core] [PATCHv2 6/8] license_class: license_create_manifest improve package file read

Aníbal Limón anibal.limon at linux.intel.com
Tue Nov 4 17:14:58 UTC 2014


Improved package file read using oe.packagedata.read_pkgdatafile
instead of doing itself.

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

diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index f2dd0eb..d462b0a 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.license
+    import oe.packagedata
 
     bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
     bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
@@ -84,25 +85,11 @@ python license_create_manifest() {
         for pkg in pkg_list:
             pkg_info = os.path.join(d.getVar('PKGDATA_DIR', True),
                                     'runtime-reverse', pkg)
-            with open(pkg_info, "r") as pkg_info_file:
-                pkg_dic[pkg] = {}
+            pkg_lic_name = "LICENSE_" + os.path.basename(os.readlink(pkg_info))
 
-                pkg_lic_name = os.path.basename(os.readlink(pkg_info))
-
-                for line in pkg_info_file.read().split("\n"):
-                    if re.match("^PN: .*$", line):
-                        pkg_dic[pkg]["PN"] = re.search("PN: (.*)$", line).group(1)
-
-                    if re.match("^PV: .*$", line):
-                        pkg_dic[pkg]["PV"] = re.search("PV: (.*)$", line).group(1)
-
-                    if re.match("^LICENSE_%s: (.*)$" % re.escape(pkg_lic_name)
-                                , line):
-                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE_%s: (.*)$"
-                                    % pkg_lic_name, line).group(1)
-                    elif re.match("^LICENSE: (.*)$", line):
-                        pkg_dic[pkg]["LICENSE"] = re.search("^LICENSE: (.*)$",
-                                    line).group(1)
+            pkg_dic[pkg] = oe.packagedata.read_pkgdatafile(pkg_info)
+            if not "LICENSE" in pkg_dic[pkg].keys():
+               pkg_dic[pkg]["LICENSE"] = pkg_dic[pkg][pkg_lic_name]
 
     license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
                         d.getVar('IMAGE_NAME', True), 'license.manifest')
-- 
1.9.1




More information about the Openembedded-core mailing list