diff options
author | Jiyong Park <jiyong@google.com> | 2018-12-27 15:09:17 +0900 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2018-12-27 15:39:34 -0800 |
commit | 9c3defa5622638e9192a4fe5050728d0cfe0d210 (patch) | |
tree | e50775994a13b0e420ccf091f277c81ac6a63e87 /apexer/apexer.py | |
parent | 97f17542f296d29e68e2bab4fc429802addffda3 (diff) |
Add --pubkey option to bundle public key with APEX
The public key file is embedded in the zip container of the APEX with
the name 'apex_pubkey'. In debuggable builds, the bundled public key
will be used as a fallback when no matching public key is found in the
built-in partitions (e.g. /system/etc/security/apex).
This is useful for testing-purpose APEXes; the public key for the APEXes
do not need to be force installed on the device, which requires rooting.
Bug: 122047804
Test: add 'installable: false' to the apex_key
'com.android.apex.test_package.key'. mma under
/system/apex/apexd/apexd_testdata. unzip the built APEX. The public key
(renamed to apex_pubkey) is found in the zip container.
Change-Id: I07be3be8ae763c12dc0541fec2b172b5f11bbafd
Diffstat (limited to 'apexer/apexer.py')
-rw-r--r-- | apexer/apexer.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/apexer/apexer.py b/apexer/apexer.py index c15b6da..cf4064a 100644 --- a/apexer/apexer.py +++ b/apexer/apexer.py @@ -63,6 +63,8 @@ def ParseArgs(argv): '"image" APEXS.') parser.add_argument('--key', help='path to the private key file. Required for "image" APEXs.') + parser.add_argument('--pubkey', + help='path to the public key file. Used to bundle the public key in APEX for testing.') parser.add_argument('input_dir', metavar='INPUT_DIR', help='the directory having files to be packaged') parser.add_argument('output', metavar='OUTPUT', @@ -306,6 +308,10 @@ def CreateApex(args, work_dir): # without mounting the image shutil.copyfile(args.manifest, os.path.join(content_dir, 'apex_manifest.json')) + # copy the public key, if specified + if args.pubkey: + shutil.copyfile(args.pubkey, os.path.join(content_dir, "apex_pubkey")) + apk_file = os.path.join(work_dir, 'apex.apk') cmd = ['aapt2'] cmd.append('link') |