summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2015-11-13 14:29:18 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:01 +0000
commitd95df11131b60933ce82b7ac96fd2dc2ebc5e1f6 (patch)
treec41aa654995debd132d431162c4629c2afb2b9cc /meta
parentefdab526245e512d9163758fadb971e0aee86710 (diff)
downloadpoky-d95df11131b60933ce82b7ac96fd2dc2ebc5e1f6.tar.gz
license.bbclass: Create image license manifest
This change adds the license_deployed_manifest function that will create the manifest for the packages deployed next to the image but not installed in rootfs. Some examples of these recipes would be the bootloaders, or the kernel. This new function was added to ROOTFS_POSTPROCESS_COMMAND so it will run after every rootfs task. This change also modify the write_license_files because the image manifest is different from the root manifest. [YOCTO #6772] (From OE-Core rev: a58e8e164b888a6e4747ef62a7a43825c4f47c32) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/license.bbclass62
1 files changed, 51 insertions, 11 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass
index 48d457e824..be1e0e7095 100644
--- a/meta/classes/license.bbclass
+++ b/meta/classes/license.bbclass
@@ -25,6 +25,10 @@ python write_package_manifest() {
25 'w+').write(image_list_installed_packages(d)) 25 'w+').write(image_list_installed_packages(d))
26} 26}
27 27
28python write_deploy_manifest() {
29 license_deployed_manifest(d)
30}
31
28python license_create_manifest() { 32python license_create_manifest() {
29 import oe.packagedata 33 import oe.packagedata
30 from oe.rootfs import image_list_installed_packages 34 from oe.rootfs import image_list_installed_packages
@@ -70,16 +74,24 @@ def write_license_files(d, license_manifest, pkg_dic):
70 pkg_dic[pkg]["LICENSES"] = re.sub(' *', ' ', pkg_dic[pkg]["LICENSES"]) 74 pkg_dic[pkg]["LICENSES"] = re.sub(' *', ' ', pkg_dic[pkg]["LICENSES"])
71 pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split() 75 pkg_dic[pkg]["LICENSES"] = pkg_dic[pkg]["LICENSES"].split()
72 76
73 license_file.write("PACKAGE NAME: %s\n" % pkg) 77 if not "IMAGE_MANIFEST" in pkg_dic[pkg]:
74 license_file.write("PACKAGE VERSION: %s\n" % pkg_dic[pkg]["PV"]) 78 # Rootfs manifest
75 license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"]) 79 license_file.write("PACKAGE NAME: %s\n" % pkg)
76 license_file.write("LICENSE: %s\n\n" % pkg_dic[pkg]["LICENSE"]) 80 license_file.write("PACKAGE VERSION: %s\n" % pkg_dic[pkg]["PV"])
77 81 license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"])
78 # If the package doesn't contain any file, that is, its size is 0, the license 82 license_file.write("LICENSE: %s\n\n" % pkg_dic[pkg]["LICENSE"])
79 # isn't relevant as far as the final image is concerned. So doing license check 83
80 # doesn't make much sense, skip it. 84 # If the package doesn't contain any file, that is, its size is 0, the license
81 if pkg_dic[pkg]["PKGSIZE_%s" % pkg] == "0": 85 # isn't relevant as far as the final image is concerned. So doing license check
82 continue 86 # doesn't make much sense, skip it.
87 if pkg_dic[pkg]["PKGSIZE_%s" % pkg] == "0":
88 continue
89 else:
90 # Image manifest
91 license_file.write("RECIPE NAME: %s\n" % pkg_dic[pkg]["PN"])
92 license_file.write("VERSION: %s\n" % pkg_dic[pkg]["PV"])
93 license_file.write("LICENSE: %s\n" % pkg_dic[pkg]["LICENSE"])
94 license_file.write("FILES: %s\n\n" % pkg_dic[pkg]["FILES"])
83 95
84 for lic in pkg_dic[pkg]["LICENSES"]: 96 for lic in pkg_dic[pkg]["LICENSES"]:
85 lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True), 97 lic_file = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
@@ -141,6 +153,34 @@ def write_license_files(d, license_manifest, pkg_dic):
141 os.link(pkg_license, pkg_rootfs_license) 153 os.link(pkg_license, pkg_rootfs_license)
142 154
143 155
156def license_deployed_manifest(d):
157 """
158 Write the license manifest for the deployed recipes.
159 The deployed recipes usually includes the bootloader
160 and extra files to boot the target.
161 """
162
163 dep_dic = {}
164 man_dic = {}
165 lic_dir = d.getVar("LICENSE_DIRECTORY", True)
166
167 dep_dic = get_deployed_dependencies(d)
168 for dep in dep_dic.keys():
169 man_dic[dep] = {}
170 # It is necessary to mark this will be used for image manifest
171 man_dic[dep]["IMAGE_MANIFEST"] = True
172 man_dic[dep]["PN"] = dep
173 man_dic[dep]["FILES"] = \
174 " ".join(get_deployed_files(dep_dic[dep]))
175 with open(os.path.join(lic_dir, dep, "recipeinfo"), "r") as f:
176 for line in f.readlines():
177 key,val = line.split(": ", 1)
178 man_dic[dep][key] = val[:-1]
179
180 image_license_manifest = os.path.join(d.getVar('LICENSE_DIRECTORY', True),
181 d.getVar('IMAGE_NAME', True), 'image_license.manifest')
182 write_license_files(d, image_license_manifest, man_dic)
183
144def get_deployed_dependencies(d): 184def get_deployed_dependencies(d):
145 """ 185 """
146 Get all the deployed dependencies of an image 186 Get all the deployed dependencies of an image
@@ -591,7 +631,7 @@ SSTATETASKS += "do_populate_lic"
591do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}" 631do_populate_lic[sstate-inputdirs] = "${LICSSTATEDIR}"
592do_populate_lic[sstate-outputdirs] = "${LICENSE_DIRECTORY}/" 632do_populate_lic[sstate-outputdirs] = "${LICENSE_DIRECTORY}/"
593 633
594ROOTFS_POSTPROCESS_COMMAND_prepend = "write_package_manifest; license_create_manifest; " 634ROOTFS_POSTPROCESS_COMMAND_prepend = "write_package_manifest; write_deploy_manifest; license_create_manifest; "
595do_rootfs[recrdeptask] += "do_populate_lic" 635do_rootfs[recrdeptask] += "do_populate_lic"
596 636
597do_populate_lic_setscene[dirs] = "${LICSSTATEDIR}/${PN}" 637do_populate_lic_setscene[dirs] = "${LICSSTATEDIR}/${PN}"