Fork 0

releasetools: also rebuild the boot image

This ensures that the right release key is also embedded in the
recovery that is part of the boot image.

Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
This commit is contained in:
Wolfgang Wiedmeyer 2017-02-15 01:50:45 +01:00
parent cc9124177c
commit afb08ef40c
No known key found for this signature in database
GPG Key ID: 5816A24C10757FC4
1 changed files with 19 additions and 18 deletions

View File

@ -36,18 +36,22 @@ __doc__ = sign_target_files_apks.__doc__
from common import File
def RebuildRecovery(image_name, unpack_dir, fs_config_file):
"""Takes the modified recovery ramdisk and rebuilds the recovery
def RebuildBootableImage(image_name, prebuilt_name, unpack_dir, tree_subdir):
"""Takes the modified ramdisk and rebuilds the recovery or the boot
recovery_ramdisk_dir = os.path.join(unpack_dir, "RECOVERY", "RAMDISK")
ramdisk_dir = os.path.join(unpack_dir, "RECOVERY", "RAMDISK")
ramdisk_cpio = os.path.join(TARGET_DIR, "ramdisk-recovery.cpio")
ramdisk_cpio_tmp = os.path.join(TARGET_DIR, "ramdisk-recovery.cpio.orig")
recovery_kernel_dir = os.path.join(TARGET_DIR, "obj", "KERNEL_RECOVERY_OBJ")
recovery_kernel_out = os.path.join(recovery_kernel_dir, "arch", "arm", "boot",
if prebuilt_name == "recovery.img":
kernel_dir = os.path.join(TARGET_DIR, "obj", "KERNEL_RECOVERY_OBJ")
kernel_dir = os.path.join(TARGET_DIR, "obj", "KERNEL_OBJ")
print("Rebuilding the recovery image...")
kernel_out = os.path.join(kernel_dir, "arch", "arm", "boot", "zImage")
fs_config_file = os.path.join(unpack_dir, "META", "recovery_filesystem_config.txt")
print("Rebuilding the bootable image...")
# temporary move the original ramdisk, move it back later
if os.path.exists(ramdisk_cpio):
@ -57,32 +61,27 @@ def RebuildRecovery(image_name, unpack_dir, fs_config_file):
raise OSError(2, 'No such file or directory', ramdisk_cpio)
ramdisk = open(ramdisk_cpio, "w")
cmd = ["mkbootfs", "-f", fs_config_file, recovery_ramdisk_dir]
cmd = ["mkbootfs", "-f", fs_config_file, ramdisk_dir]
p = subprocess.call(cmd, stdout=ramdisk)
if p:
raise ValueError("mkbootfs of %s failed" % recovery_ramdisk_dir)
raise ValueError("mkbootfs of %s failed" % ramdisk_dir)
cross_compile = os.getenv('ARM_EABI_TOOLCHAIN')
subprocess.call(["make", "-C", "kernel/samsung/smdk4412",
"O=" + recovery_kernel_dir, "ARCH=arm",
"O=" + kernel_dir, "ARCH=arm",
"CROSS_COMPILE=" + cross_compile, "zImage"])
if p:
raise ValueError("rebuilding recovery failed: " + str(p))
raise ValueError("rebuilding bootable image failed: " + str(p))
os.rename(ramdisk_cpio_tmp, ramdisk_cpio)
return File.FromLocalFile(image_name, recovery_kernel_out)
return File.FromLocalFile(image_name, kernel_out)
def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir,
if prebuilt_name == "recovery.img":
fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
return RebuildRecovery(name, unpack_dir, os.path.join(unpack_dir,
return File.FromLocalFile(name, os.path.join(TARGET_DIR, prebuilt_name))
return RebuildBootableImage(name, prebuilt_name, unpack_dir, tree_subdir)
common.GetBootableImage = GetBootableImage
@ -94,3 +93,5 @@ if __name__ == '__main__':
print(" ERROR: %s" % e)