Skip to contentSkip to conversation

license.bbclass: fix the code of installing and packaging license files

PATCH New [email protected] 1 participant 2 messages Dec 10, 2013

lore
Share & tools
lore
#0 lore raw

cover license.bbclass: fix the code of installing and packaging license files

From: Chen Qi <[email protected]>

The following changes since commit 184038bedb20f74ba4dcad6ef2d92e87a9ba5f9a:

bitbake: fetch2/git: Ensure check is made in the correct directory (2013-12-06 14:10:15 +0000)

are available in the git repository at:

git://git.pokylinux.org/poky-contrib ChenQi/license-rebuild
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=ChenQi/license-rebuild

Chen Qi (1):
license.bbclass: fix the code of installing and packaging license
files

 meta/classes/license.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 license.bbclass: fix the code of installing and packaging license files

From: Chen Qi <[email protected]>

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]

---
 meta/classes/license.bbclass |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)
meta/classes/license.bbclass +21 -4
index 7fe47b2..d35071c 100644
@@ -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 = oe.data.typed_value('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 "
+
+# When LICENSE_FILES_DIRECTORY or LICENSE_CREATE_PACKAGE changes, it should
+# only affect target packages
+python __anonymous() {
+    # The dependency of do_install should only apply for target packages...
+    if bb.data.inherits_class('native', d) or bb.data.inherits_class('nativesdk', d) or \
+       bb.data.inherits_class('cross', d) or bb.data.inherits_class('crosssdk', d) or \
+       bb.data.inherits_class('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 = oe.data.typed_value('LICENSE_CREATE_PACKAGE', d)
+    if d.getVar('CLASSOVERRIDE', True) == 'class-target' and enabled:
         add_package_and_files(d)
 }
 
Signature · 1 line
1.7.9.5