2828from extract_utils .fixups_lib import lib_fixups_type , run_libs_fixup
2929from 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+ ]
3239APEX_PARTITIONS = ['system' , 'vendor' , 'system_ext' ]
3340RFSA_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 ('\n PRODUCT_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