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:
parent
cc9124177c
commit
afb08ef40c
@ -36,18 +36,22 @@ __doc__ = sign_target_files_apks.__doc__
|
|||||||
|
|
||||||
from common import File
|
from common import File
|
||||||
|
|
||||||
def RebuildRecovery(image_name, unpack_dir, fs_config_file):
|
def RebuildBootableImage(image_name, prebuilt_name, unpack_dir, tree_subdir):
|
||||||
"""Takes the modified recovery ramdisk and rebuilds the recovery
|
"""Takes the modified ramdisk and rebuilds the recovery or the boot
|
||||||
image"""
|
image"""
|
||||||
|
|
||||||
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 = os.path.join(TARGET_DIR, "ramdisk-recovery.cpio")
|
||||||
ramdisk_cpio_tmp = os.path.join(TARGET_DIR, "ramdisk-recovery.cpio.orig")
|
ramdisk_cpio_tmp = os.path.join(TARGET_DIR, "ramdisk-recovery.cpio.orig")
|
||||||
recovery_kernel_dir = os.path.join(TARGET_DIR, "obj", "KERNEL_RECOVERY_OBJ")
|
if prebuilt_name == "recovery.img":
|
||||||
recovery_kernel_out = os.path.join(recovery_kernel_dir, "arch", "arm", "boot",
|
kernel_dir = os.path.join(TARGET_DIR, "obj", "KERNEL_RECOVERY_OBJ")
|
||||||
"zImage")
|
else:
|
||||||
|
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
|
# temporary move the original ramdisk, move it back later
|
||||||
if os.path.exists(ramdisk_cpio):
|
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)
|
raise OSError(2, 'No such file or directory', ramdisk_cpio)
|
||||||
|
|
||||||
ramdisk = open(ramdisk_cpio, "w")
|
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)
|
p = subprocess.call(cmd, stdout=ramdisk)
|
||||||
if p:
|
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')
|
cross_compile = os.getenv('ARM_EABI_TOOLCHAIN')
|
||||||
subprocess.call(["make", "-C", "kernel/samsung/smdk4412",
|
subprocess.call(["make", "-C", "kernel/samsung/smdk4412",
|
||||||
"O=" + recovery_kernel_dir, "ARCH=arm",
|
"O=" + kernel_dir, "ARCH=arm",
|
||||||
"CROSS_COMPILE=" + cross_compile, "zImage"])
|
"CROSS_COMPILE=" + cross_compile, "zImage"])
|
||||||
if p:
|
if p:
|
||||||
raise ValueError("rebuilding recovery failed: " + str(p))
|
raise ValueError("rebuilding bootable image failed: " + str(p))
|
||||||
|
|
||||||
os.rename(ramdisk_cpio_tmp, ramdisk_cpio)
|
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,
|
def GetBootableImage(name, prebuilt_name, unpack_dir, tree_subdir,
|
||||||
info_dict=None):
|
info_dict=None):
|
||||||
|
|
||||||
if prebuilt_name == "recovery.img":
|
return RebuildBootableImage(name, prebuilt_name, unpack_dir, tree_subdir)
|
||||||
fs_config = "META/" + tree_subdir.lower() + "_filesystem_config.txt"
|
|
||||||
return RebuildRecovery(name, unpack_dir, os.path.join(unpack_dir,
|
|
||||||
fs_config))
|
|
||||||
else:
|
|
||||||
return File.FromLocalFile(name, os.path.join(TARGET_DIR, prebuilt_name))
|
|
||||||
|
|
||||||
common.GetBootableImage = GetBootableImage
|
common.GetBootableImage = GetBootableImage
|
||||||
|
|
||||||
@ -94,3 +93,5 @@ if __name__ == '__main__':
|
|||||||
print(" ERROR: %s" % e)
|
print(" ERROR: %s" % e)
|
||||||
print()
|
print()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
finally:
|
||||||
|
common.Cleanup()
|
||||||
|
Loading…
Reference in New Issue
Block a user