diff --git a/src/fosslight_android/android_binary_analysis.py b/src/fosslight_android/android_binary_analysis.py index 43f1b07..093ac98 100755 --- a/src/fosslight_android/android_binary_analysis.py +++ b/src/fosslight_android/android_binary_analysis.py @@ -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() diff --git a/src/fosslight_android/check_notice_file.py b/src/fosslight_android/check_notice_file.py index 91f0ea5..4f6b9d7 100644 --- a/src/fosslight_android/check_notice_file.py +++ b/src/fosslight_android/check_notice_file.py @@ -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)