diff options
author | Mohammad Samiul Islam <samiul@google.com> | 2020-02-27 17:26:59 +0000 |
---|---|---|
committer | Mohammad Samiul Islam <samiul@google.com> | 2020-03-02 13:34:03 +0000 |
commit | 2cc12eb55f0f322397870f344c9806a959365373 (patch) | |
tree | d17bd7713be3d4f3d1ae065fada8c306696df676 /apexer/apexer.py | |
parent | 6b4bce2a4f3dc0d2e278ef30ae612162b664a483 (diff) |
Add --unsigned_payload_only flag to apexer
The flag instructs apexer to output the payload before it is signed by
avbtool.
The CL also contains new test to ensure that when the unsigned payload
is signed by avbtool, it is same as the payload we get when we unzip an
apex.
Bug: 149993331
Test: atest --host apexer_test
Change-Id: I0c0c29ee2fabaa447f5844e71949a00778b1d935
Diffstat (limited to 'apexer/apexer.py')
-rw-r--r-- | apexer/apexer.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/apexer/apexer.py b/apexer/apexer.py index bbd2d43..a8c92cc 100644 --- a/apexer/apexer.py +++ b/apexer/apexer.py @@ -159,6 +159,12 @@ def ParseArgs(argv): action='store_true', help='Outputs the payload image/zip only.' ) + parser.add_argument( + '--unsigned_payload_only', + action='store_true', + help="""Outputs the unsigned payload image/zip only. Also, setting this flag implies + --payload_only is set too.""" + ) return parser.parse_args(argv) @@ -283,8 +289,11 @@ def ValidateArgs(args): print(args.output + ' already exists. Use --force to overwrite.') return False + if args.unsigned_payload_only: + args.payload_only = True; + if args.payload_type == 'image': - if not args.key: + if not args.key and not args.unsigned_payload_only: print('Missing --key {keyfile} argument!') return False @@ -437,9 +446,10 @@ def CreateApex(args, work_dir): copyfile(args.manifest_json, os.path.join(manifests_dir, 'apex_manifest.json')) if args.payload_type == 'image': - key_name = os.path.basename(os.path.splitext(args.key)[0]) - if args.do_not_check_keyname: + if args.do_not_check_keyname or args.unsigned_payload_only: key_name = manifest_apex.name + else: + key_name = os.path.basename(os.path.splitext(args.key)[0]) if manifest_apex.name != key_name: print("package name '" + manifest_apex.name + @@ -503,6 +513,12 @@ def CreateApex(args, work_dir): cmd.append(img_file) RunCommand(cmd, args.verbose, {'E2FSPROGS_FAKE_TIME': '1'}) + if args.unsigned_payload_only: + shutil.copyfile(img_file, args.output) + if (args.verbose): + print('Created (unsigned payload only) ' + args.output) + return True + cmd = ['avbtool'] cmd.append('add_hashtree_footer') cmd.append('--do_not_generate_fec') |