aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-28 21:00:43 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-02-28 21:00:43 +0000
commit5b2973d47425fed7182338ac598b801cf7baf021 (patch)
treedd04663d716d4adaa91ed752188a49343d4d8ae5
parent7c5fc412e814b2c5e27fca1e3db7ef9fecec6b7f (diff)
parentf759fc4c18b53485f2dccd0057ed1593be753eca (diff)
downloadavb-simpleperf-release.tar.gz
Snap for 11510257 from f759fc4c18b53485f2dccd0057ed1593be753eca to simpleperf-releasesimpleperf-release
Change-Id: I699f3d24e18bf719af936707c3c0ea9aa82b9d8d
-rwxr-xr-xavbtool.py10
-rw-r--r--test/avbtool_unittest.cc2
2 files changed, 8 insertions, 4 deletions
diff --git a/avbtool.py b/avbtool.py
index 5be377f..e46d042 100755
--- a/avbtool.py
+++ b/avbtool.py
@@ -3441,7 +3441,10 @@ class Avb(object):
print('{}'.format(partition_size - max_metadata_size))
return
- image = ImageHandler(image_filename)
+ # If we aren't appending the vbmeta footer to the input image we can
+ # open it in read-only mode.
+ image = ImageHandler(image_filename,
+ read_only=do_not_append_vbmeta_image)
# If there's already a footer, truncate the image to its original
# size. This way 'avbtool add_hash_footer' is idempotent (modulo
@@ -4382,8 +4385,7 @@ class AvbTool(object):
sub_parser = subparsers.add_parser('add_hash_footer',
help='Add hashes and footer to image.')
sub_parser.add_argument('--image',
- help='Image to add hashes to',
- type=argparse.FileType('rb+'))
+ help='Image to add hashes to')
sub_parser.add_argument('--partition_size',
help='Partition size',
type=parse_number)
@@ -4818,7 +4820,7 @@ class AvbTool(object):
def add_hash_footer(self, args):
"""Implements the 'add_hash_footer' sub-command."""
args = self._fixup_common_args(args)
- self.avb.add_hash_footer(args.image.name if args.image else None,
+ self.avb.add_hash_footer(args.image,
args.partition_size, args.dynamic_partition_size,
args.partition_name, args.hash_algorithm,
args.salt, args.chain_partition,
diff --git a/test/avbtool_unittest.cc b/test/avbtool_unittest.cc
index 93cae41..753aaca 100644
--- a/test/avbtool_unittest.cc
+++ b/test/avbtool_unittest.cc
@@ -656,6 +656,8 @@ void AvbToolTest::AddHashFooterTest(bool sparse_image) {
EXPECT_EQ(static_cast<size_t>(erased_footer_file_size), rootfs_size);
// Check that --do_not_append_vbmeta_image works as intended.
+ // In this case we don't modify the input image so it should work read-only.
+ EXPECT_COMMAND(0, "chmod a-w %s", rootfs_path.value().c_str());
EXPECT_COMMAND(0,
"./avbtool.py add_hash_footer --salt d00df00d "
"--hash_algorithm sha256 --image %s "