[OE-core] [PATCHv2 1/6] license.bbclass: Split license create manifest
mariano.lopez at linux.intel.com
mariano.lopez at linux.intel.com
Mon Nov 9 14:04:38 UTC 2015
From: Mariano Lopez <mariano.lopez at linux.intel.com>
This changes moves the writing of the licenses to a
separated function that could be called for other packages.
With these change it will be easier to reuse the writing of
the license for the packages deployed but not installed in
the rootfs.
[YOCTO #6772]
Signed-off-by: Mariano Lopez <mariano.lopez at linux.intel.com>
---
meta/classes/license.bbclass | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index c616a20..98f1733 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -26,14 +26,9 @@ 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)
- bad_licenses = expand_wildcard_licenses(d, bad_licenses)
-
build_images_from_feeds = d.getVar('BUILD_IMAGES_FROM_FEEDS', True)
if build_images_from_feeds == "1":
return 0
@@ -49,8 +44,18 @@ python license_create_manifest() {
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),
+ rootfs_license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
d.getVar('IMAGE_NAME', True), 'license.manifest')
+ write_license_files(d, rootfs_license_manifest, pkg_dic)
+}
+
+def write_license_files(d, license_manifest, pkg_dic):
+ import re
+
+ bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
+ bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
+ bad_licenses = expand_wildcard_licenses(d, bad_licenses)
+
with open(license_manifest, "w") as license_file:
for pkg in sorted(pkg_dic):
if bad_licenses:
@@ -98,15 +103,16 @@ python license_create_manifest() {
if copy_lic_manifest == "1":
rootfs_license_dir = os.path.join(d.getVar('IMAGE_ROOTFS', 'True'),
'usr', 'share', 'common-licenses')
- os.makedirs(rootfs_license_dir)
+ bb.utils.mkdirhier(rootfs_license_dir)
rootfs_license_manifest = os.path.join(rootfs_license_dir,
- 'license.manifest')
- os.link(license_manifest, rootfs_license_manifest)
+ os.path.split(license_manifest)[1])
+ if not os.path.exists(rootfs_license_manifest):
+ os.link(license_manifest, rootfs_license_manifest)
if copy_lic_dirs == "1":
for pkg in sorted(pkg_dic):
pkg_rootfs_license_dir = os.path.join(rootfs_license_dir, pkg)
- os.makedirs(pkg_rootfs_license_dir)
+ bb.utils.mkdirhier(pkg_rootfs_license_dir)
pkg_license_dir = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
pkg_dic[pkg]["PN"])
licenses = os.listdir(pkg_license_dir)
@@ -124,14 +130,16 @@ python license_create_manifest() {
if not os.path.exists(rootfs_license):
os.link(pkg_license, rootfs_license)
- os.symlink(os.path.join('..', lic), pkg_rootfs_license)
+ if not os.path.exists(pkg_rootfs_license):
+ os.symlink(os.path.join('..', lic), pkg_rootfs_license)
else:
- if oe.license.license_ok(canonical_license(d,
- lic), bad_licenses) == False:
+ if (oe.license.license_ok(canonical_license(d,
+ lic), bad_licenses) == False or
+ os.path.exists(pkg_rootfs_license)):
continue
os.link(pkg_license, pkg_rootfs_license)
-}
+
python do_populate_lic() {
"""
--
1.8.4.5
More information about the Openembedded-core
mailing list