From a1c41a0c5ad3bd2347dbf9391174b6f04d89ad01 Mon Sep 17 00:00:00 2001 From: Cosmin Tanislav Date: Sun, 24 Nov 2024 03:32:40 +0200 Subject: [PATCH] extract_utils: fix generated proprietary file extraction Commit 71f352e ("extract_utils: skip parsing generated proprietary file when section is specified") introduced skipping for generated proprietary files. Generated proprietary files were stopped from being parsed if section was set, causing file_list to be empty. This is okay when not regenerating, or when regenerating from an existing dump, but when regenerating from a fresh dump, file_list is only populated after extraction, and the generated proprietary file's partition is needed on extraction. Move the generated proprietary file filtering to get_extract_partitions(). Change-Id: Id88fea9f882983cbe26c510540f1021d0bad3cbb --- extract_utils/main.py | 2 +- extract_utils/module.py | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/extract_utils/main.py b/extract_utils/main.py index e63b8ff4..21d9a109 100644 --- a/extract_utils/main.py +++ b/extract_utils/main.py @@ -145,7 +145,7 @@ def run(self): extract_fns.update(module.extract_fns) extract_partitions.update( - module.get_extract_partitions(), + module.get_extract_partitions(self.__args.section), ) firmware_partitions.update( module.get_firmware_partitions(), diff --git a/extract_utils/module.py b/extract_utils/module.py index 11eee5ed..eeeeb9d2 100644 --- a/extract_utils/module.py +++ b/extract_utils/module.py @@ -378,9 +378,6 @@ def regenerate( self.fix_file_list() def get_partitions(self) -> Set[str]: - if not self.file_list.all_files: - return set() - return {self.partition} @@ -452,10 +449,19 @@ def __init__( if not skip_main_proprietary_file: self.add_proprietary_file('proprietary-files.txt') - def get_partitions(self, kind: ProprietaryFileType): + def get_partitions( + self, + kind: ProprietaryFileType, + section: Optional[str] = None, + ): partitions: List[str] = [] for proprietary_file in self.proprietary_files: + if section is not None and isinstance( + proprietary_file, GeneratedProprietaryFile + ): + continue + if proprietary_file.kind is not kind: continue @@ -478,8 +484,8 @@ def get_files(self, kind: ProprietaryFileType): return files - def get_extract_partitions(self): - return self.get_partitions(ProprietaryFileType.BLOBS) + def get_extract_partitions(self, section: Optional[str]): + return self.get_partitions(ProprietaryFileType.BLOBS, section) def get_firmware_partitions(self): return self.get_partitions(ProprietaryFileType.FIRMWARE) @@ -698,11 +704,6 @@ def parse( section: Optional[str], ): for proprietary_file in self.proprietary_files: - if section is not None and isinstance( - proprietary_file, GeneratedProprietaryFile - ): - continue - if regenerate and isinstance( proprietary_file, GeneratedProprietaryFile,