releasetools: Allow building AVB-enabled recovery.img.
Bug: 68224784
Test: Enable AVB on aosp_bullhead-userdebug. `m dist`. Note that the
prebuilt vendor.img needs to be AVB-signed first.
Test: `m dist` with aosp_walleye-userdebug.
Change-Id: I18235e4d0dde6af71a96e46ec434480cc9a22bef
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index f80d0ec..75c86cc 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -452,10 +452,12 @@
else:
cmd.extend(["--output", img.name])
+ # "boot" or "recovery", without extension.
+ partition_name = os.path.basename(sourcedir).lower()
+
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
- assert p.returncode == 0, "mkbootimg of %s image failed" % (
- os.path.basename(sourcedir),)
+ assert p.returncode == 0, "mkbootimg of %s image failed" % (partition_name,)
if (info_dict.get("boot_signer", None) == "true" and
info_dict.get("verity_key", None)):
@@ -464,7 +466,7 @@
if two_step_image:
path = "/boot"
else:
- path = "/" + os.path.basename(sourcedir).lower()
+ path = "/" + partition_name
cmd = [OPTIONS.boot_signer_path]
cmd.extend(OPTIONS.boot_signer_args)
cmd.extend([path, img.name,
@@ -476,7 +478,7 @@
# Sign the image if vboot is non-empty.
elif info_dict.get("vboot", None):
- path = "/" + os.path.basename(sourcedir).lower()
+ path = "/" + partition_name
img_keyblock = tempfile.NamedTemporaryFile()
# We have switched from the prebuilt futility binary to using the tool
# (futility-host) built from the source. Override the setting in the old
@@ -503,15 +505,16 @@
avbtool = os.getenv('AVBTOOL') or info_dict["avb_avbtool"]
part_size = info_dict["boot_size"]
cmd = [avbtool, "add_hash_footer", "--image", img.name,
- "--partition_size", str(part_size), "--partition_name", "boot"]
- AppendAVBSigningArgs(cmd, "boot")
+ "--partition_size", str(part_size), "--partition_name",
+ partition_name]
+ AppendAVBSigningArgs(cmd, partition_name)
args = info_dict.get("avb_boot_add_hash_footer_args")
if args and args.strip():
cmd.extend(shlex.split(args))
p = Run(cmd, stdout=subprocess.PIPE)
p.communicate()
assert p.returncode == 0, "avbtool add_hash_footer of %s failed" % (
- os.path.basename(OPTIONS.input_tmp))
+ partition_name,)
img.seek(os.SEEK_SET, 0)
data = img.read()