[1/1] license.bbclass: fix the code of installing and packaging license files
Details
Commit Message
@@ -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)
}