diff options
author | Huang Jianan <huangjianan@oppo.com> | 2021-04-29 15:24:50 +0800 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2021-09-27 21:17:05 +0800 |
commit | 6100d11267549ce4374ad2b0d032cda82484e217 (patch) | |
tree | 06c52ab78b8c81e6adf4f503fd06c77c2ca21df2 | |
parent | 2bd23cf8487291303978857bd481b676087657e0 (diff) |
[master] releasetools: Avoid to print undefined image_size and partition_size
If dynamic partitioning is enabled and the partition size is not set,
we will get a KeyError before image_size or partition_size is calculated
when we try to catch exception in BuildImageMkfs.
Bug: 186704243
Test: build_image.py can correctly throw exception
Change-Id: I3d8c143ad5603d07fe94afb8bb911ead244f0bf7
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
-rwxr-xr-x | tools/releasetools/build_image.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index a992ad632d..7f49845860 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -374,13 +374,14 @@ def BuildImageMkfs(in_dir, prop_dict, out_file, target_out, fs_config): in_dir, du_str, int(prop_dict.get("partition_reserved_size", 0)), int(prop_dict.get("partition_reserved_size", 0)) // BYTES_IN_MB)) - print( - "The max image size for filesystem files is {} bytes ({} MB), out of a " - "total partition size of {} bytes ({} MB).".format( - int(prop_dict["image_size"]), - int(prop_dict["image_size"]) // BYTES_IN_MB, - int(prop_dict["partition_size"]), - int(prop_dict["partition_size"]) // BYTES_IN_MB)) + if ("image_size" in prop_dict and "partition_size" in prop_dict): + print( + "The max image size for filesystem files is {} bytes ({} MB), " + "out of a total partition size of {} bytes ({} MB).".format( + int(prop_dict["image_size"]), + int(prop_dict["image_size"]) // BYTES_IN_MB, + int(prop_dict["partition_size"]), + int(prop_dict["partition_size"]) // BYTES_IN_MB)) raise if run_e2fsck and prop_dict.get("skip_fsck") != "true": |