From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 3/4] license_class: Added LICENSE_PRIORITY support
Date: Wed, 29 Oct 2014 12:34:15 -0600 [thread overview]
Message-ID: <1414607656-12144-4-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1414607656-12144-1-git-send-email-anibal.limon@linux.intel.com>
Now you can specify LICENSE_PRIORITY for license manifest creation.
This means that if you have LICENSE expression with OR's only one
license is selected based on LICENSE_PRIORITY and INCOMPATIBLE_LICENSE.
[YOCTO #6757]
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
meta/classes/license.bbclass | 47 ++++++++++++++++++++++++++++++++++++++------
meta/conf/documentation.conf | 1 +
2 files changed, 42 insertions(+), 6 deletions(-)
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index c11ef1c..a055660 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -33,10 +33,45 @@ python license_create_manifest() {
bad_licenses = (d.getVar("INCOMPATIBLE_LICENSE", True) or "").split()
bad_licenses = map(lambda l: canonical_license(d, l), bad_licenses)
+ priority_licenses = (d.getVar("LICENSE_PRIORITY", True) or "").split()
+ priority_licenses = map(lambda l: canonical_license(d, l), priority_licenses)
+ priority_licenses.reverse()
+
+ # Get license priority based on index,
+ # INCOMPATIBLE_LICENSE entries have negative weight.
+ # Licenses not listed have a weight of 0.
+ # LICENSE_PRIORITY entries have a positive weight.
+ def get_license_priority(license):
+ # If you want to exclude license named generically 'X', we
+ # surely want to exclude 'X+' as well. In consequence, we
+ # will exclude a trailing '+' character from LICENSE in
+ # case INCOMPATIBLE_LICENSE is not a 'X+' license.
+ for bl in bad_licenses:
+ lic = license
+ if not re.search('\+$', bl):
+ lic = re.sub('\+', '', license)
+
+ if lic == bl:
+ return -1 * (bad_licenses.index(lic) + 1)
+
+ if license in priority_licenses:
+ return priority_licenses.index(license) + 1
+ else:
+ return 0
+
# Handles an "or" or two license sets provided by
- # flattened_licenses(), pick one that works if possible.
- def choose_lic_set(a, b):
- return a if all(license_ok(bad_licenses, lic) for lic in a) else b
+ # flattened_licenses(), pick one that works based on
+ # LICENSE_PRIORITY and INCOMPATIBLE_LICENSE.
+ def choose_lic_set(alpha, beta):
+ alpha_canonical = [canonical_license(d, l) for l in alpha]
+ beta_canonical = [canonical_license(d, l) for l in beta]
+ alpha_weight = sum(get_license_priority(a) for a in alpha_canonical)
+ beta_weight = sum(get_license_priority(b) for b in beta_canonical)
+
+ if alpha_weight >= beta_weight:
+ return alpha
+ else:
+ return beta
build_images_from_feeds = d.getVar('BUILD_IMAGES_FROM_FEEDS', True)
if build_images_from_feeds == "1":
@@ -80,12 +115,12 @@ python license_create_manifest() {
license_file.write("LICENSE:")
try:
- licenses = oe.license.flattened_licenses(pkg_dic[pkg]["LICENSE"]
- , choose_lic_set)
+ pkg_dic[pkg]["FLATTENED_LICENSE"] = oe.license.flattened_licenses(
+ pkg_dic[pkg]["LICENSE"], choose_lic_set)
except oe.license.LicenseError as exc:
bb.fatal('%s: %s' % (d.getVar('P', True), exc))
- for lic in licenses:
+ for lic in pkg_dic[pkg]["FLATTENED_LICENSE"]:
lic = re.sub('\+', '', lic)
lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
pkg_dic[pkg]["PN"], "generic_%s" % lic)
diff --git a/meta/conf/documentation.conf b/meta/conf/documentation.conf
index 66ec093..d2b3057 100644
--- a/meta/conf/documentation.conf
+++ b/meta/conf/documentation.conf
@@ -220,6 +220,7 @@ IMAGE_ROOTFS_SIZE[doc] = "Defines the size in Kbytes for the generated image."
IMAGE_TYPES[doc] = "Specifies the complete list of supported image types by default."
INC_PR[doc] = "Helps define the recipe revision for recipes that share a common include file."
INCOMPATIBLE_LICENSE[doc] = "Specifies a space-separated list of license names (as they would appear in LICENSE) that should be excluded from the build."
+LICENSE_PRIORITY[doc] = "Space separated list of licenses in priority order, highest to lowest."
INHIBIT_DEFAULT_DEPS[doc] = "Prevents the default dependencies, namely the C compiler and standard C library (libc), from being added to DEPENDS."
INHIBIT_PACKAGE_STRIP[doc] = "If set to "1", causes the build to not strip binaries in resulting packages."
INHERIT[doc] = "Causes the named class to be inherited at this point during parsing. The variable is only valid in configuration files."
--
1.9.1
next prev parent reply other threads:[~2014-10-29 18:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 18:34 [PATCH 0/4] license_class: Added support for LICENSE_PRIORITY in manifest creation Aníbal Limón
2014-10-29 18:34 ` [PATCH 1/4] license_class: Reimplemented manifest creation in python Aníbal Limón
2014-10-29 21:28 ` Richard Purdie
2014-10-30 23:08 ` Aníbal Limón
2014-10-29 18:34 ` [PATCH 2/4] license_class: Added support for INCOMPATIBLE_LICENSE into license_create_manifest Aníbal Limón
2014-10-29 18:34 ` Aníbal Limón [this message]
2014-10-29 18:34 ` [PATCH 4/4] license_class: Fix remove + trim in license_create_manifest Aníbal Limón
2015-02-24 16:00 ` [PATCH 0/4] license_class: Added support for LICENSE_PRIORITY in manifest creation Paul Eggleton
2015-02-24 16:05 ` Aníbal Limón
2015-02-24 17:08 ` Flanagan, Elizabeth
2015-02-26 16:34 ` Flanagan, Elizabeth
2015-02-26 17:50 ` Richard Purdie
2015-02-27 16:27 ` Aníbal Limón
2015-02-27 16:31 ` Paul Eggleton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1414607656-12144-4-git-send-email-anibal.limon@linux.intel.com \
--to=anibal.limon@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox