Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bcd0bca authored by Wei Li's avatar Wei Li
Browse files

Check if an installed file exists and report error if not.

So far there is only one case happened in b/277039235 that an installed file in that product is moved to another directory in LOCAL_POST_INSTALL_CMD. The team agreed to convert to Android.bp, but better to add a check and report the error.

Resend this to check symlinks using os.path.islink(), which doesn't follow the link. os.path.isfile() follows symlinks and returns false since the symlinks are for devices and could not be resolved on host file systems.

Bug: 277039235
Test: m sbom
Test: build/soong/tests/sbom_test.sh
Change-Id: Ia9f1cd24dc974a3e41487bc17c9c76a26d419395
parent 0bb86d05
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -87,6 +87,7 @@ ISSUE_NO_METADATA = 'No metadata generated in Make for installed files:'
ISSUE_NO_METADATA_FILE = 'No METADATA file found for installed file:'
ISSUE_METADATA_FILE_INCOMPLETE = 'METADATA file incomplete:'
ISSUE_UNKNOWN_SECURITY_TAG_TYPE = 'Unknown security tag type:'
ISSUE_INSTALLED_FILE_NOT_EXIST = 'Non-exist installed files:'
INFO_METADATA_FOUND_FOR_PACKAGE = 'METADATA file found for packages:'


@@ -601,7 +602,8 @@ def main():
    ISSUE_NO_METADATA_FILE: [],
    ISSUE_METADATA_FILE_INCOMPLETE: [],
    ISSUE_UNKNOWN_SECURITY_TAG_TYPE: [],
      INFO_METADATA_FOUND_FOR_PACKAGE: []
    ISSUE_INSTALLED_FILE_NOT_EXIST: [],
    INFO_METADATA_FOUND_FOR_PACKAGE: [],
  }

  # Scan the metadata in CSV file and create the corresponding package and file records in SPDX
@@ -619,6 +621,10 @@ def main():

      if not installed_file_has_metadata(installed_file_metadata, report):
        continue
      file_path = args.product_out_dir + '/' + installed_file
      if not (os.path.islink(file_path) or os.path.isfile(file_path)):
        report[ISSUE_INSTALLED_FILE_NOT_EXIST].append(installed_file)
        continue

      file_id = new_file_id(installed_file)
      product_files.append(new_file_record(file_id, installed_file, checksum(installed_file)))