summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
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 @@
6LICENSE_DIRECTORY ??= "${DEPLOY_DIR}/licenses" 6LICENSE_DIRECTORY ??= "${DEPLOY_DIR}/licenses"
7LICSSTATEDIR = "${WORKDIR}/license-destdir/" 7LICSSTATEDIR = "${WORKDIR}/license-destdir/"
8 8
9# Create extra package with license texts and add it to RRECOMMENDS_${PN}
10LICENSE_CREATE_PACKAGE ??= "0"
11LICENSE_PACKAGE_SUFFIX ??= "-lic"
12LICENSE_FILES_DIRECTORY ??= "${datadir}/licenses/"
13
9addtask populate_lic after do_patch before do_build 14addtask populate_lic after do_patch before do_build
10do_populate_lic[dirs] = "${LICSSTATEDIR}/${PN}" 15do_populate_lic[dirs] = "${LICSSTATEDIR}/${PN}"
11do_populate_lic[cleandirs] = "${LICSSTATEDIR}" 16do_populate_lic[cleandirs] = "${LICSSTATEDIR}"
@@ -95,6 +100,35 @@ python do_populate_lic() {
95 copy_license_files(lic_files_paths, destdir) 100 copy_license_files(lic_files_paths, destdir)
96} 101}
97 102
103# it would be better to copy them in do_install_append, but find_license_filesa is python
104python perform_packagecopy_prepend () {
105 enabled = d.getVar('LICENSE_CREATE_PACKAGE', True)
106 if d.getVar('CLASSOVERRIDE', True) == 'class-target' and enabled:
107 lic_files_paths = find_license_files(d)
108
109 # LICENSE_FILES_DIRECTORY starts with '/' so os.path.join cannot be used to join D and LICENSE_FILES_DIRECTORY
110 destdir = d.getVar('D', True) + os.path.join(d.getVar('LICENSE_FILES_DIRECTORY', True), d.getVar('PN', True))
111 copy_license_files(lic_files_paths, destdir)
112 add_package_and_files(d)
113}
114
115def add_package_and_files(d):
116 packages = d.getVar('PACKAGES', True)
117 files = d.getVar('LICENSE_FILES_DIRECTORY', True)
118 pn = d.getVar('PN', True)
119 pn_lic = "%s%s" % (pn, d.getVar('LICENSE_PACKAGE_SUFFIX'))
120 if pn_lic in packages:
121 bb.warn("%s package already existed in %s." % (pn_lic, pn))
122 else:
123 # first in PACKAGES to be sure that nothing else gets LICENSE_FILES_DIRECTORY
124 d.setVar('PACKAGES', "%s %s" % (pn_lic, packages))
125 d.setVar('FILES_' + pn_lic, files)
126 rrecommends_pn = d.getVar('RRECOMMENDS_' + pn, True)
127 if rrecommends_pn:
128 d.setVar('RRECOMMENDS_' + pn, "%s %s" % (pn_lic, rrecommends_pn))
129 else:
130 d.setVar('RRECOMMENDS_' + pn, "%s" % (pn_lic))
131
98def copy_license_files(lic_files_paths, destdir): 132def copy_license_files(lic_files_paths, destdir):
99 bb.mkdirhier(destdir) 133 bb.mkdirhier(destdir)
100 for (basename, path) in lic_files_paths: 134 for (basename, path) in lic_files_paths: