Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/fosslight_android/android_binary_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,30 +211,29 @@ def set_env_variables_from_result_log():
pass

# FIND a NOTICE file and build out path
pattern_notice = r'\[.*?\]\s*build\s+(([^\s]*?)/obj/NOTICE\.(?:xml(?:\.gz)?|html|txt))'
for line in reversed(android_log_lines):
line = line.strip()
if line.endswith("obj/NOTICE.xml") or line.endswith("obj/NOTICE.html") or line.endswith("obj/NOTICE.txt"):
words = line.split()
build_out_notice_file_path = words[-1]
find_idx = build_out_notice_file_path.find("obj/")
build_out_path = build_out_notice_file_path[:find_idx]
match = re.search(pattern_notice, line)
if match:
build_out_notice_file_path = match.group(1)
build_out_path = match.group(2)
break

if build_out_path == "":
if not build_out_path:
pattern = re.compile(r'.*Installed file list:\s*([^\s]+)')
for line in reversed(android_log_lines):
try:
pattern = re.compile(r'.*Installed file list\s*(.*):\s*(.*)')
matched = pattern.match(line)
if matched is not None:
build_out_path = os.path.dirname(matched.group(2))
build_out_path = os.path.dirname(matched.group(1))
break
except Exception:
pass
if build_out_path == "":
if not build_out_path:
logger.error("Can't find a build output path.")
sys.exit(1)

if build_out_notice_file_path == "":
if not build_out_notice_file_path:
build_out_notice_file_path = os.path.join(build_out_path, "obj")

read_module_info_from_build_output_file()
Expand Down
4 changes: 2 additions & 2 deletions src/fosslight_android/check_notice_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def read_notice_file(notice_file_path):

if os.path.isfile(notice_file_path):
notice_files.append(notice_file_path)
if notice_file_path.endswith(".html") or notice_file_path.endswith(".xml") or notice_file_path.endswith(".txt"):
notice_file_path = os.path.dirname(notice_file_path)
if notice_file_path.endswith((".xml", ".html", ".txt", "xml.gz")):
notice_file_path = os.path.dirname(notice_file_path)

if os.path.isdir(notice_file_path):
additional_notice_files = find_files_by_extension(notice_file_path)
Expand Down