Skip to content

Commit 409b495

Browse files
committed
extract_utils: Fix recovery extract
Change-Id: Ifdc9392fd854db6d207e89a0c619ecea86e8a6d1
1 parent 4135503 commit 409b495

2 files changed

Lines changed: 37 additions & 8 deletions

File tree

extract_utils/bp_builder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ def specific(self):
103103
if self.__partition is None:
104104
return self
105105

106+
if self.__partition == 'recovery':
107+
return self.set('recovery', True)
108+
106109
specific = PARTITION_SPECIFIC_MAP.get(self.__partition)
107110
if specific is None:
108111
return self

extract_utils/makefiles.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@
2828
from extract_utils.fixups_lib import lib_fixups_type, run_libs_fixup
2929
from extract_utils.utils import Color, color_print, file_path_sha1
3030

31-
ALL_PARTITIONS = ['system', 'vendor', 'product', 'system_ext', 'odm']
31+
ALL_PARTITIONS = [
32+
'system',
33+
'vendor',
34+
'product',
35+
'system_ext',
36+
'odm',
37+
'recovery',
38+
]
3239
APEX_PARTITIONS = ['system', 'vendor', 'system_ext']
3340
RFSA_PARTITIONS = ['vendor', 'odm']
3441

@@ -485,6 +492,12 @@ def write_product_packages(
485492
encoder = BpJSONEncoder(legacy=ctx.legacy)
486493
package_names: List[str] = []
487494

495+
def get_part_path(partition: str):
496+
if partition == 'recovery':
497+
return ['recovery', 'system']
498+
else:
499+
return [partition]
500+
488501
def w(
489502
fn: write_package_fn,
490503
file_tree: FileTree,
@@ -509,20 +522,24 @@ def wp(
509522
*args: Any,
510523
**kwargs: Any,
511524
):
512-
file_tree = base_file_tree.filter_prefixed([partition, sub_dir])
525+
file_tree = base_file_tree.filter_prefixed(
526+
get_part_path(partition) + [sub_dir]
527+
)
513528

514529
return w(fn, file_tree, *args, **kwargs)
515530

516531
for part in ALL_PARTITIONS:
532+
part_path = get_part_path(part)
533+
517534
lib_rfsa_tree = None
518535
if part in RFSA_PARTITIONS:
519536
# Extract these first so that they don't end up in lib32
520537
lib_rfsa_tree = base_file_tree.filter_prefixed(
521-
[part, 'lib', 'rfsa']
538+
part_path + ['lib', 'rfsa']
522539
)
523540

524-
lib32_tree = base_file_tree.filter_prefixed([part, 'lib'])
525-
lib64_tree = base_file_tree.filter_prefixed([part, 'lib64'])
541+
lib32_tree = base_file_tree.filter_prefixed(part_path + ['lib'])
542+
lib64_tree = base_file_tree.filter_prefixed(part_path + ['lib64'])
526543

527544
lib_common_tree = CommonFileTree.common_files(lib32_tree, lib64_tree)
528545

@@ -583,9 +600,18 @@ def write_product_copy_files(
583600
out.write('\nPRODUCT_COPY_FILES +=')
584601

585602
for file in files:
586-
target = f'$(TARGET_COPY_OUT_{file.partition.upper()})'
587-
# Remove partition from destination, keeping the slash after it
588-
rel_dst = file.dst[len(file.partition) :]
603+
if file.partition == 'recovery':
604+
target = '$(TARGET_COPY_OUT_RECOVERY)/root'
605+
# 1. Strip 'recovery/' from the start
606+
# 2. Strip 'root/' if it was nested inside (e.g. recovery/root/vendor)
607+
dst = file.dst.removeprefix(f'{file.partition}/').removeprefix(
608+
'root/'
609+
)
610+
rel_dst = f'/{dst}'
611+
else:
612+
target = f'$(TARGET_COPY_OUT_{file.partition.upper()})'
613+
# Remove partition from destination, keeping the slash after it
614+
rel_dst = file.dst[len(file.partition) :]
589615
line = f' \\\n {rel_path}/{file.dst}:{target}{rel_dst}'
590616

591617
out.write(line)

0 commit comments

Comments
 (0)