Skip to content

Commit

Permalink
extract_utils: fix generated proprietary file extraction
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Demon000 committed Nov 24, 2024
1 parent d595610 commit a1c41a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion extract_utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
23 changes: 12 additions & 11 deletions extract_utils/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}


Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a1c41a0

Please sign in to comment.