diff options
author | Brint E. Kriebel <bekit@cyngn.com> | 2016-05-16 18:53:19 -0700 |
---|---|---|
committer | Brint E. Kriebel <bekit@cyngn.com> | 2016-05-17 12:17:45 -0700 |
commit | fbd7c1cdb0b361cf35f7b3323019806e149c6c00 (patch) | |
tree | 0a708d4127b7bd7c45b7a18a78db1d429ffea4f0 /tools | |
parent | ef1f045521a07a2901529b76a20575aff5769e60 (diff) | |
download | build-fbd7c1cdb0b361cf35f7b3323019806e149c6c00.zip build-fbd7c1cdb0b361cf35f7b3323019806e149c6c00.tar.gz build-fbd7c1cdb0b361cf35f7b3323019806e149c6c00.tar.bz2 |
ereleasetools: Allow for custom boot image signing tools
Some boot images will need to be signed using specific tools. Allow
passing the path to this tool through an environment variable.
Change-Id: I958726fdae8d63fe99d639dfa361046b528a087c
Ticket: CYNGNOS-2868
Diffstat (limited to 'tools')
-rw-r--r-- | tools/releasetools/common.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index ac4cdf7..6e49629 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -339,6 +339,7 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): ramdisk_img = tempfile.NamedTemporaryFile() img = tempfile.NamedTemporaryFile() bootimg_key = os.getenv("PRODUCT_PRIVATE_KEY", None) + custom_boot_signer = os.getenv("PRODUCT_BOOT_SIGNER", None) if os.access(fs_config_file, os.F_OK): cmd = ["mkbootfs", "-f", fs_config_file, os.path.join(sourcedir, "RAMDISK")] @@ -427,7 +428,15 @@ def BuildBootableImage(sourcedir, fs_config_file, info_dict=None): assert p.returncode == 0, "mkbootimg of %s image failed" % ( os.path.basename(sourcedir),) - if bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: + if custom_boot_signer and bootimg_key and os.path.exists(bootimg_key): + print("Signing bootable image with custom boot signer...") + img_secure = tempfile.NamedTemporaryFile() + p = Run([custom_boot_signer, img.name, img_secure.name], stdout=subprocess.PIPE) + p.communicate() + assert p.returncode == 0, "signing of bootable image failed" + shutil.copyfile(img_secure.name, img.name) + img_secure.close() + elif bootimg_key and os.path.exists(bootimg_key) and kernel_pagesize > 0: print("Signing bootable image...") bootimg_key_passwords = {} bootimg_key_passwords.update(PasswordManager().GetPasswords(bootimg_key.split())) |