summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/license_finder.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/meta/lib/oe/license_finder.py b/meta/lib/oe/license_finder.py
index d5030c033e..96961658e8 100644
--- a/meta/lib/oe/license_finder.py
+++ b/meta/lib/oe/license_finder.py
@@ -191,12 +191,18 @@ def crunch_license(licfile):
191 return md5val, lictext 191 return md5val, lictext
192 192
193 193
194def find_license_files(srctree): 194def find_license_files(srctree, first_only=False):
195 """
196 Search srctree for files that look like they could be licenses.
197 If first_only is True, only return the first file found.
198 """
195 licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*', 'e[dp]l-v10'] 199 licspecs = ['*LICEN[CS]E*', 'COPYING*', '*[Ll]icense*', 'LEGAL*', '[Ll]egal*', '*GPL*', 'README.lic*', 'COPYRIGHT*', '[Cc]opyright*', 'e[dp]l-v10']
196 skip_extensions = (".html", ".js", ".json", ".svg", ".ts", ".go", ".sh") 200 skip_extensions = (".html", ".js", ".json", ".svg", ".ts", ".go", ".sh")
197 licfiles = [] 201 licfiles = []
198 for root, dirs, files in os.walk(srctree): 202 for root, dirs, files in os.walk(srctree):
199 for fn in files: 203 # Sort files so that LICENSE is before LICENSE.subcomponent, which is
204 # meaningful if first_only is set.
205 for fn in sorted(files):
200 if fn.endswith(skip_extensions): 206 if fn.endswith(skip_extensions):
201 continue 207 continue
202 for spec in licspecs: 208 for spec in licspecs:
@@ -204,6 +210,8 @@ def find_license_files(srctree):
204 fullpath = os.path.join(root, fn) 210 fullpath = os.path.join(root, fn)
205 if not fullpath in licfiles: 211 if not fullpath in licfiles:
206 licfiles.append(fullpath) 212 licfiles.append(fullpath)
213 if first_only:
214 return licfiles
207 215
208 return licfiles 216 return licfiles
209 217
@@ -233,8 +241,8 @@ def match_licenses(licfiles, srctree, d):
233 return licenses 241 return licenses
234 242
235 243
236def find_licenses(srctree, d): 244def find_licenses(srctree, d, first_only=False):
237 licfiles = find_license_files(srctree) 245 licfiles = find_license_files(srctree, first_only)
238 licenses = match_licenses(licfiles, srctree, d) 246 licenses = match_licenses(licfiles, srctree, d)
239 247
240 # FIXME should we grab at least one source file with a license header and add that too? 248 # FIXME should we grab at least one source file with a license header and add that too?