Skip to content
Snippets Groups Projects
Commit 0602aea1 authored by Detlev Casanova's avatar Detlev Casanova Committed by Walter Lozano
Browse files

scripts/generate_bom.py: Drop relaxed search

parent ae40ff60
No related branches found
No related tags found
1 merge request!530generate_bom: Rework scanning to improve reliability
......@@ -158,9 +158,8 @@ class PathDepth():
class BomGenerator():
def __init__(self, bom_dir, relaxed, dpkg_status, verbose, pretty, comments, copyright, copyright_limit):
def __init__(self, bom_dir, dpkg_status, verbose, pretty, comments, copyright, copyright_limit):
self.bom_dir = bom_dir
self.relaxed = relaxed
self.dpkg_status = dpkg_status
self.verbose = verbose
self.pretty = pretty
......@@ -202,25 +201,6 @@ class BomGenerator():
return NO_COPYRIGHT_INFO_FOUND
# Get the license for file by searching a match with the last part
# of the report generated by FOSSolgy as we can't rely on the folder
# used to upload the source code
def get_license_relaxed(self, copyright_info, f_src):
for p in copyright_info.all_files_paragraphs():
for f in p.files:
if f.endswith(f_src):
return self.get_license_str(p)
return NO_LICENSE_INFO_FOUND
def get_copyright_relaxed(self, copyright_info, f_src):
for p in copyright_info.all_files_paragraphs():
for f in p.files:
if f.endswith(f_src):
return self.get_copyright_str(p)
return NO_COPYRIGHT_INFO_FOUND
def get_copyright_file(self, filenames):
if COPYRIGHT_REPORT in filenames:
return COPYRIGHT_REPORT
......@@ -300,17 +280,11 @@ class BomGenerator():
out_copyright.add(NO_COPYRIGHT_INFO_FOUND)
def scan_regular_unit(self, unit_file_path, copyright_info, out_licenses, out_copyright):
if not self.relaxed:
license = self.get_license(copyright_info, unit_file_path)
else:
license = self.get_license_relaxed(copyright_info, unit_file_path)
license = self.get_license(copyright_info, unit_file_path)
out_licenses.add(license)
if self.copyright:
if not self.relaxed:
copyright = self.get_copyright(copyright_info, unit_file_path)
else:
copyright = self.get_copyright_relaxed(copyright_info, unit_file_path)
copyright = self.get_copyright(copyright_info, unit_file_path)
out_copyright.add(copyright)
def scan_units(self, binary_name, package_copyright_files, units):
......@@ -456,8 +430,6 @@ class BomGenerator():
def main(argv):
global RELAXED_SEARCH
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--comments", action='store_true', help="include license comments")
parser.add_argument("-C", "--copyright", action='store_true', help="include copyright information")
......@@ -465,14 +437,13 @@ def main(argv):
help="limit maximum number of characters in copyright information")
parser.add_argument("-d", "--dir", default=DEFAULT_BOM_DIR, help="directory to search for information")
parser.add_argument("-p", "--pretty", action='store_true', help="indent the JSON output")
parser.add_argument("-r", "--relaxed", action='store_true', help="use relaxed search")
parser.add_argument("-s", "--dpkg-status", default=DEFAULT_DPKG_STATUS, help="dpkg status file")
parser.add_argument("-v", "--verbose", type=int, default=VERBOSE_IMAGE,
help="verbose use in output 0: image, 1: package, 2: binary, 3: source")
args = parser.parse_args()
bom_generator = BomGenerator(args.dir, args.relaxed, args.dpkg_status, args.verbose, args.pretty, args.comments,
bom_generator = BomGenerator(args.dir, args.dpkg_status, args.verbose, args.pretty, args.comments,
args.copyright, args.copyright_limit)
bom_generator.check_packages_copyright()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment