diff options
author | Martin Jansa <martin.jansa@gmail.com> | 2013-01-17 12:49:43 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-28 12:29:29 +0000 |
commit | 2daab0b3a233f8e322e024338b158e0b0a16967f (patch) | |
tree | 2afcf1669f1d3bfd123f853d2911c7194790d8a8 | |
parent | b2869b6810728a5f003ddad335fd7f6512181a57 (diff) | |
download | poky-2daab0b3a233f8e322e024338b158e0b0a16967f.tar.gz |
license.bbclass: extract functionality to find license files to separate function
* move it from do_populate_lic to find_license_files so we can reuse it
to populate license in package itself
[YOCTO #3743]
(From OE-Core rev: 833f8c239aa475b3e0cacbd448a90079ac287468)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/license.bbclass | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/meta/classes/license.bbclass b/meta/classes/license.bbclass index cd18e198d4..8688bd1e94 100644 --- a/meta/classes/license.bbclass +++ b/meta/classes/license.bbclass | |||
@@ -88,6 +88,25 @@ python do_populate_lic() { | |||
88 | """ | 88 | """ |
89 | Populate LICENSE_DIRECTORY with licenses. | 89 | Populate LICENSE_DIRECTORY with licenses. |
90 | """ | 90 | """ |
91 | lic_files_paths = find_license_files(d) | ||
92 | |||
93 | # The base directory we wrangle licenses to | ||
94 | destdir = os.path.join(d.getVar('LICSSTATEDIR', True), d.getVar('PN', True)) | ||
95 | copy_license_files(lic_files_paths, destdir) | ||
96 | } | ||
97 | |||
98 | def copy_license_files(lic_files_paths, destdir): | ||
99 | bb.mkdirhier(destdir) | ||
100 | for (basename, path) in lic_files_paths: | ||
101 | ret = bb.copyfile(path, os.path.join(destdir, basename)) | ||
102 | # If the copy didn't occur, something horrible went wrong and we fail out | ||
103 | if not ret: | ||
104 | bb.warn("%s could not be copied for some reason. It may not exist. WARN for now." % path) | ||
105 | |||
106 | def find_license_files(d): | ||
107 | """ | ||
108 | Creates list of files used in LIC_FILES_CHKSUM and generic LICENSE files. | ||
109 | """ | ||
91 | import shutil | 110 | import shutil |
92 | import oe.license | 111 | import oe.license |
93 | 112 | ||
@@ -108,12 +127,12 @@ python do_populate_lic() { | |||
108 | # All the license files for the package | 127 | # All the license files for the package |
109 | lic_files = d.getVar('LIC_FILES_CHKSUM', True) | 128 | lic_files = d.getVar('LIC_FILES_CHKSUM', True) |
110 | pn = d.getVar('PN', True) | 129 | pn = d.getVar('PN', True) |
111 | # The base directory we wrangle licenses to | ||
112 | destdir = os.path.join(d.getVar('LICSSTATEDIR', True), pn) | ||
113 | # The license files are located in S/LIC_FILE_CHECKSUM. | 130 | # The license files are located in S/LIC_FILE_CHECKSUM. |
114 | srcdir = d.getVar('S', True) | 131 | srcdir = d.getVar('S', True) |
115 | # Directory we store the generic licenses as set in the distro configuration | 132 | # Directory we store the generic licenses as set in the distro configuration |
116 | generic_directory = d.getVar('COMMON_LICENSE_DIR', True) | 133 | generic_directory = d.getVar('COMMON_LICENSE_DIR', True) |
134 | # List of basename, path tuples | ||
135 | lic_files_paths = [] | ||
117 | license_source_dirs = [] | 136 | license_source_dirs = [] |
118 | license_source_dirs.append(generic_directory) | 137 | license_source_dirs.append(generic_directory) |
119 | try: | 138 | try: |
@@ -159,20 +178,12 @@ python do_populate_lic() { | |||
159 | # we really should copy to generic_ + spdx_generic, however, that ends up messing the manifest | 178 | # we really should copy to generic_ + spdx_generic, however, that ends up messing the manifest |
160 | # audit up. This should be fixed in emit_pkgdata (or, we actually got and fix all the recipes) | 179 | # audit up. This should be fixed in emit_pkgdata (or, we actually got and fix all the recipes) |
161 | 180 | ||
162 | bb.copyfile(os.path.join(license_source, spdx_generic), os.path.join(os.path.join(d.getVar('LICSSTATEDIR', True), pn), "generic_" + license_type)) | 181 | lic_files_paths.append(("generic_" + license_type, os.path.join(license_source, spdx_generic))) |
163 | if not os.path.isfile(os.path.join(os.path.join(d.getVar('LICSSTATEDIR', True), pn), "generic_" + license_type)): | ||
164 | # If the copy didn't occur, something horrible went wrong and we fail out | ||
165 | bb.warn("%s for %s could not be copied for some reason. It may not exist. WARN for now." % (spdx_generic, pn)) | ||
166 | else: | 182 | else: |
167 | # And here is where we warn people that their licenses are lousy | 183 | # And here is where we warn people that their licenses are lousy |
168 | bb.warn("%s: No generic license file exists for: %s in any provider" % (pn, license_type)) | 184 | bb.warn("%s: No generic license file exists for: %s in any provider" % (pn, license_type)) |
169 | pass | 185 | pass |
170 | 186 | ||
171 | try: | ||
172 | bb.mkdirhier(destdir) | ||
173 | except: | ||
174 | pass | ||
175 | |||
176 | if not generic_directory: | 187 | if not generic_directory: |
177 | raise bb.build.FuncFailed("COMMON_LICENSE_DIR is unset. Please set this in your distro config") | 188 | raise bb.build.FuncFailed("COMMON_LICENSE_DIR is unset. Please set this in your distro config") |
178 | 189 | ||
@@ -180,16 +191,13 @@ python do_populate_lic() { | |||
180 | # No recipe should have an invalid license file. This is checked else | 191 | # No recipe should have an invalid license file. This is checked else |
181 | # where, but let's be pedantic | 192 | # where, but let's be pedantic |
182 | bb.note(pn + ": Recipe file does not have license file information.") | 193 | bb.note(pn + ": Recipe file does not have license file information.") |
183 | return True | 194 | return lic_files_paths |
184 | 195 | ||
185 | for url in lic_files.split(): | 196 | for url in lic_files.split(): |
186 | (type, host, path, user, pswd, parm) = bb.decodeurl(url) | 197 | (type, host, path, user, pswd, parm) = bb.decodeurl(url) |
187 | # We want the license file to be copied into the destination | 198 | # We want the license filename and path |
188 | srclicfile = os.path.join(srcdir, path) | 199 | srclicfile = os.path.join(srcdir, path) |
189 | ret = bb.copyfile(srclicfile, os.path.join(destdir, os.path.basename(path))) | 200 | lic_files_paths.append((os.path.basename(path), srclicfile)) |
190 | # If the copy didn't occur, something horrible went wrong and we fail out | ||
191 | if not ret: | ||
192 | bb.warn("%s could not be copied for some reason. It may not exist. WARN for now." % srclicfile) | ||
193 | 201 | ||
194 | v = FindVisitor() | 202 | v = FindVisitor() |
195 | try: | 203 | try: |
@@ -199,7 +207,7 @@ python do_populate_lic() { | |||
199 | except SyntaxError: | 207 | except SyntaxError: |
200 | bb.warn("%s: Failed to parse it's LICENSE field." % (d.getVar('PF', True))) | 208 | bb.warn("%s: Failed to parse it's LICENSE field." % (d.getVar('PF', True))) |
201 | 209 | ||
202 | } | 210 | return lic_files_paths |
203 | 211 | ||
204 | def return_spdx(d, license): | 212 | def return_spdx(d, license): |
205 | """ | 213 | """ |