summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2021-10-08 09:48:30 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 11:48:35 +0100
commitd5c4979669f125e73c24dcc73fa3c4f3787bbb62 (patch)
tree81bef2185522ae84252c0a92249c4159476959e4
parent0548a5d8eeee682a6e250ddc1886279f52747db2 (diff)
downloadopenembedded-core-contrib-d5c4979669f125e73c24dcc73fa3c4f3787bbb62.tar.gz
recipetool: Add support for linenumbers to licenses.csv
Add support for linenumbers (begin and end lines) to licenses.csv. Add an optional linenumbers parameter to get_license_md5sums to support different use cases. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/recipetool/create.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index a8c4cdef4a..277266be4e 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -1002,11 +1002,11 @@ def handle_license_vars(srctree, lines_before, handled, extravalues, d):
handled.append(('license', licvalues))
return licvalues
-def get_license_md5sums(d, static_only=False):
+def get_license_md5sums(d, static_only=False, linenumbers=False):
import bb.utils
import csv
md5sums = {}
- if not static_only:
+ if not static_only and not linenumbers:
# Gather md5sums of license files in common license dir
commonlicdir = d.getVar('COMMON_LICENSE_DIR')
for fn in os.listdir(commonlicdir):
@@ -1024,10 +1024,14 @@ def get_license_md5sums(d, static_only=False):
csv_path = os.path.join(path, 'lib', 'recipetool', 'licenses.csv')
if os.path.isfile(csv_path):
with open(csv_path, newline='') as csv_file:
- fieldnames = ['md5sum', 'license']
+ fieldnames = ['md5sum', 'license', 'beginline', 'endline', 'md5']
reader = csv.DictReader(csv_file, delimiter=',', fieldnames=fieldnames)
for row in reader:
- md5sums[row['md5sum']] = row['license']
+ if linenumbers:
+ md5sums[row['md5sum']] = (
+ row['license'], row['beginline'], row['endline'], row['md5'])
+ else:
+ md5sums[row['md5sum']] = row['license']
return md5sums