summaryrefslogtreecommitdiffstats
path: root/scripts/lib/recipetool/create.py
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:45 +0100
commitaee9854734ca3d78ccdb351c16fca4de5f1688e7 (patch)
tree12aaa33c2b828aa9c0cad6c2860996238ff9e2e5 /scripts/lib/recipetool/create.py
parentbb54949b1724988b7956bc542f347f342103fd69 (diff)
downloadpoky-aee9854734ca3d78ccdb351c16fca4de5f1688e7.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. (From OE-Core rev: d5c4979669f125e73c24dcc73fa3c4f3787bbb62) 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>
Diffstat (limited to 'scripts/lib/recipetool/create.py')
-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):
1002 handled.append(('license', licvalues)) 1002 handled.append(('license', licvalues))
1003 return licvalues 1003 return licvalues
1004 1004
1005def get_license_md5sums(d, static_only=False): 1005def get_license_md5sums(d, static_only=False, linenumbers=False):
1006 import bb.utils 1006 import bb.utils
1007 import csv 1007 import csv
1008 md5sums = {} 1008 md5sums = {}
1009 if not static_only: 1009 if not static_only and not linenumbers:
1010 # Gather md5sums of license files in common license dir 1010 # Gather md5sums of license files in common license dir
1011 commonlicdir = d.getVar('COMMON_LICENSE_DIR') 1011 commonlicdir = d.getVar('COMMON_LICENSE_DIR')
1012 for fn in os.listdir(commonlicdir): 1012 for fn in os.listdir(commonlicdir):
@@ -1024,10 +1024,14 @@ def get_license_md5sums(d, static_only=False):
1024 csv_path = os.path.join(path, 'lib', 'recipetool', 'licenses.csv') 1024 csv_path = os.path.join(path, 'lib', 'recipetool', 'licenses.csv')
1025 if os.path.isfile(csv_path): 1025 if os.path.isfile(csv_path):
1026 with open(csv_path, newline='') as csv_file: 1026 with open(csv_path, newline='') as csv_file:
1027 fieldnames = ['md5sum', 'license'] 1027 fieldnames = ['md5sum', 'license', 'beginline', 'endline', 'md5']
1028 reader = csv.DictReader(csv_file, delimiter=',', fieldnames=fieldnames) 1028 reader = csv.DictReader(csv_file, delimiter=',', fieldnames=fieldnames)
1029 for row in reader: 1029 for row in reader:
1030 md5sums[row['md5sum']] = row['license'] 1030 if linenumbers:
1031 md5sums[row['md5sum']] = (
1032 row['license'], row['beginline'], row['endline'], row['md5'])
1033 else:
1034 md5sums[row['md5sum']] = row['license']
1031 1035
1032 return md5sums 1036 return md5sums
1033 1037