summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorMartin Jansa <martin.jansa@gmail.com>2013-01-17 12:49:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-28 12:25:34 +0000
commitdc78ef91a2bf01efb8028c9afbe69e506e016265 (patch)
tree3a7c314b993cd5282f7ff0ac7f2a1550e33f0a68 /meta
parent833f8c239aa475b3e0cacbd448a90079ac287468 (diff)
downloadopenembedded-core-dc78ef91a2bf01efb8028c9afbe69e506e016265.tar.gz
openembedded-core-dc78ef91a2bf01efb8028c9afbe69e506e016265.tar.bz2
openembedded-core-dc78ef91a2bf01efb8028c9afbe69e506e016265.zip
license.bbclass: package license texts to PN-lic when LICENSE_CREATE_PACKAGE is enabled
[YOCTO #3743] Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/license.bbclass34
1 files changed, 34 insertions, 0 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 8688bd1e94..d4ebb26d2b 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -6,6 +6,11 @@
LICENSE_DIRECTORY ??= "${DEPLOY_DIR}/licenses"
LICSSTATEDIR = "${WORKDIR}/license-destdir/"
+# Create extra package with license texts and add it to RRECOMMENDS_${PN}
+LICENSE_CREATE_PACKAGE ??= "0"
+LICENSE_PACKAGE_SUFFIX ??= "-lic"
+LICENSE_FILES_DIRECTORY ??= "${datadir}/licenses/"
+
addtask populate_lic after do_patch before do_build
do_populate_lic[dirs] = "${LICSSTATEDIR}/${PN}"
do_populate_lic[cleandirs] = "${LICSSTATEDIR}"
@@ -95,6 +100,35 @@ 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 () {
+ enabled = d.getVar('LICENSE_CREATE_PACKAGE', True)
+ 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)
+ add_package_and_files(d)
+}
+
+def add_package_and_files(d):
+ packages = d.getVar('PACKAGES', True)
+ files = d.getVar('LICENSE_FILES_DIRECTORY', True)
+ pn = d.getVar('PN', True)
+ pn_lic = "%s%s" % (pn, d.getVar('LICENSE_PACKAGE_SUFFIX'))
+ if pn_lic in packages:
+ bb.warn("%s package already existed in %s." % (pn_lic, pn))
+ else:
+ # first in PACKAGES to be sure that nothing else gets LICENSE_FILES_DIRECTORY
+ d.setVar('PACKAGES', "%s %s" % (pn_lic, packages))
+ d.setVar('FILES_' + pn_lic, files)
+ rrecommends_pn = d.getVar('RRECOMMENDS_' + pn, True)
+ if rrecommends_pn:
+ d.setVar('RRECOMMENDS_' + pn, "%s %s" % (pn_lic, rrecommends_pn))
+ else:
+ d.setVar('RRECOMMENDS_' + pn, "%s" % (pn_lic))
+
def copy_license_files(lic_files_paths, destdir):
bb.mkdirhier(destdir)
for (basename, path) in lic_files_paths: