Patchwork [1/1] license.bbclass: fix the code of installing and packaging license files

mail settings
Date Dec. 10, 2013, 5:18 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/63109/
State New
Headers show

Comments - Dec. 10, 2013, 5:18 a.m.
From: Chen Qi <>

Previously, enabling and disabling 'LICENSE_CREATE_PACKAGE' doesn't cause
rerun of the packaging process. As a result, if this variable was enabled
before, then the generated packages would still require the '-lic' packages
even if the variable is now disabled.

Ideally, the packaging process should rerun if the value of the variable
LICENSE_CREATE_PACKAGE is modified. And as this variable also triggers
the installation of license files, the do_install task should also rerun
if the variable is modified. On the other hand, the tasks should not rerun
for native packages and nativesdk packages, because installing and packaging
the license files only applies to the target packages.

This patch achieves the above behavior.

[YOCTO #5635]

Signed-off-by: Chen Qi <>
 meta/classes/license.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)


diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 7fe47b2..d35071c 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -98,15 +98,32 @@  python do_populate_lic() {
     copy_license_files(lic_files_paths, destdir)
-# it would be better to copy them in do_install_append, but find_license_filesa is python
-python perform_packagecopy_prepend () {
+# Copy license files in do_install if necessary
+python install_lic_files() {
     enabled ='LICENSE_CREATE_PACKAGE', d)
     if d.getVar('CLASSOVERRIDE', True) == 'class-target' and enabled:
         lic_files_paths = find_license_files(d)
-        # LICENSE_FILES_DIRECTORY starts with '/' so os.path.join cannot be used to join D and LICENSE_FILES_DIRECTORY
         destdir = d.getVar('D', True) + os.path.join(d.getVar('LICENSE_FILES_DIRECTORY', True), d.getVar('PN', True))
         copy_license_files(lic_files_paths, destdir)
+do_install[postfuncs] += "install_lic_files "
+# only affect target packages
+python __anonymous() {
+    # The dependency of do_install should only apply for target packages...
+    if'native', d) or'nativesdk', d) or \
+'cross', d) or'crosssdk', d) or \
+'cross-canadian', d):
+        return
+    d.appendVarFlag('do_install', 'vardeps', 'LICENSE_CREATE_PACKAGE LICENSE_FILES_DIRECTORY')
+# Set up license packages if necessary
+python perform_packagecopy_prepend () {
+    enabled ='LICENSE_CREATE_PACKAGE', d)
+    if d.getVar('CLASSOVERRIDE', True) == 'class-target' and enabled: