Reland "unpack_bootimg: Create symlink as alternate vendor ramdisk names" am: a08985e112 am: fd6c83c7c4
Original change: https://android-review.googlesource.com/c/platform/system/tools/mkbootimg/+/1669629
Change-Id: I63e97d1e27f7696ce89d5a0e83c2d715088b5dd8
diff --git a/unpack_bootimg.py b/unpack_bootimg.py
index 61adc7c..7209137 100755
--- a/unpack_bootimg.py
+++ b/unpack_bootimg.py
@@ -428,6 +428,7 @@
num_boot_header_pages + num_boot_ramdisk_pages + num_boot_dtb_pages)
vendor_ramdisk_table = []
+ vendor_ramdisk_symlinks = []
for idx in range(vendor_ramdisk_table_entry_num):
entry_offset = vendor_ramdisk_table_offset + (
vendor_ramdisk_table_entry_size * idx)
@@ -446,6 +447,7 @@
image_info_list.append((ramdisk_offset_base + ramdisk_offset,
ramdisk_size, output_ramdisk_name))
+ vendor_ramdisk_symlinks.append((output_ramdisk_name, ramdisk_name))
vendor_ramdisk_table.append(
(output_ramdisk_name, ramdisk_size, ramdisk_offset,
ramdisk_type, ramdisk_name, board_id))
@@ -468,6 +470,19 @@
for image_info in image_info_list:
extract_image(image_info[0], image_info[1], args.boot_img,
os.path.join(args.out, image_info[2]))
+
+ if info.header_version > 3:
+ vendor_ramdisk_by_name_dir = os.path.join(
+ args.out, 'vendor-ramdisk-by-name')
+ create_out_dir(vendor_ramdisk_by_name_dir)
+ for src, dst in vendor_ramdisk_symlinks:
+ src_pathname = os.path.join('..', src)
+ dst_pathname = os.path.join(
+ vendor_ramdisk_by_name_dir, f'ramdisk_{dst}')
+ if os.path.lexists(dst_pathname):
+ os.remove(dst_pathname)
+ os.symlink(src_pathname, dst_pathname)
+
info.image_dir = args.out
# Saves the arguments to be reused in mkbootimg.py later.