Merge changes I1f645008,Ic68c019f am: 015f83137d
am: 3f759a23ce
Change-Id: Id4801bb75a8f2805a9340aade61646a0b79568a2
This commit is contained in:
commit
d532b602fd
|
@ -39,6 +39,7 @@ Usage: check_target_file_signatures [flags] target_files
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -52,6 +53,8 @@ if sys.hexversion < 0x02070000:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
# Work around a bug in Python's zipfile module that prevents opening of zipfiles
|
# Work around a bug in Python's zipfile module that prevents opening of zipfiles
|
||||||
# if any entry has an extra field of between 1 and 3 bytes (which is common with
|
# if any entry has an extra field of between 1 and 3 bytes (which is common with
|
||||||
# zipaligned APKs). This overrides the ZipInfo._decodeExtra() method (which
|
# zipaligned APKs). This overrides the ZipInfo._decodeExtra() method (which
|
||||||
|
@ -415,6 +418,8 @@ def main(argv):
|
||||||
common.Usage(__doc__)
|
common.Usage(__doc__)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
common.InitLogging()
|
||||||
|
|
||||||
ALL_CERTS.FindLocalCerts()
|
ALL_CERTS.FindLocalCerts()
|
||||||
|
|
||||||
Push("input target_files:")
|
Push("input target_files:")
|
||||||
|
|
|
@ -50,7 +50,8 @@ class Options(object):
|
||||||
if base_out_path is None:
|
if base_out_path is None:
|
||||||
base_search_path = "out"
|
base_search_path = "out"
|
||||||
else:
|
else:
|
||||||
base_search_path = os.path.join(base_out_path, os.path.basename(os.getcwd()))
|
base_search_path = os.path.join(base_out_path,
|
||||||
|
os.path.basename(os.getcwd()))
|
||||||
|
|
||||||
platform_search_path = {
|
platform_search_path = {
|
||||||
"linux2": os.path.join(base_search_path, "host/linux-x86"),
|
"linux2": os.path.join(base_search_path, "host/linux-x86"),
|
||||||
|
@ -552,11 +553,7 @@ def GetAvbChainedPartitionArg(partition, info_dict, key=None):
|
||||||
"""
|
"""
|
||||||
if key is None:
|
if key is None:
|
||||||
key = info_dict["avb_" + partition + "_key_path"]
|
key = info_dict["avb_" + partition + "_key_path"]
|
||||||
avbtool = os.getenv('AVBTOOL') or info_dict["avb_avbtool"]
|
pubkey_path = ExtractAvbPublicKey(key)
|
||||||
pubkey_path = MakeTempFile(prefix="avb-", suffix=".pubkey")
|
|
||||||
RunAndCheckOutput(
|
|
||||||
[avbtool, "extract_public_key", "--key", key, "--output", pubkey_path])
|
|
||||||
|
|
||||||
rollback_index_location = info_dict[
|
rollback_index_location = info_dict[
|
||||||
"avb_" + partition + "_rollback_index_location"]
|
"avb_" + partition + "_rollback_index_location"]
|
||||||
return "{}:{}:{}".format(partition, rollback_index_location, pubkey_path)
|
return "{}:{}:{}".format(partition, rollback_index_location, pubkey_path)
|
||||||
|
@ -2123,6 +2120,21 @@ def ExtractPublicKey(cert):
|
||||||
return pubkey
|
return pubkey
|
||||||
|
|
||||||
|
|
||||||
|
def ExtractAvbPublicKey(key):
|
||||||
|
"""Extracts the AVB public key from the given public or private key.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
key: The input key file, which should be PEM-encoded public or private key.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The path to the extracted AVB public key file.
|
||||||
|
"""
|
||||||
|
output = MakeTempFile(prefix='avb-', suffix='.avbpubkey')
|
||||||
|
RunAndCheckOutput(
|
||||||
|
['avbtool', 'extract_public_key', "--key", key, "--output", output])
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
|
def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
|
||||||
info_dict=None):
|
info_dict=None):
|
||||||
"""Generates the recovery-from-boot patch and writes the script to output.
|
"""Generates the recovery-from-boot patch and writes the script to output.
|
||||||
|
|
|
@ -102,6 +102,7 @@ import base64
|
||||||
import copy
|
import copy
|
||||||
import errno
|
import errno
|
||||||
import gzip
|
import gzip
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -121,6 +122,8 @@ if sys.hexversion < 0x02070000:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
OPTIONS = common.OPTIONS
|
OPTIONS = common.OPTIONS
|
||||||
|
|
||||||
OPTIONS.extra_apks = {}
|
OPTIONS.extra_apks = {}
|
||||||
|
@ -180,11 +183,8 @@ def GetApkFileInfo(filename, compressed_extension, skipped_prefixes):
|
||||||
|
|
||||||
# skipped_prefixes should be one of set/list/tuple types. Other types such as
|
# skipped_prefixes should be one of set/list/tuple types. Other types such as
|
||||||
# str shouldn't be accepted.
|
# str shouldn't be accepted.
|
||||||
assert (isinstance(skipped_prefixes, tuple) or
|
assert isinstance(skipped_prefixes, (set, list, tuple)), \
|
||||||
isinstance(skipped_prefixes, set) or
|
"Invalid skipped_prefixes input type: {}".format(type(skipped_prefixes))
|
||||||
isinstance(skipped_prefixes, list)), \
|
|
||||||
"Invalid skipped_prefixes input type: {}".format(
|
|
||||||
type(skipped_prefixes))
|
|
||||||
|
|
||||||
compressed_apk_extension = (
|
compressed_apk_extension = (
|
||||||
".apk" + compressed_extension if compressed_extension else None)
|
".apk" + compressed_extension if compressed_extension else None)
|
||||||
|
@ -816,7 +816,7 @@ def GetCodenameToApiLevelMap(input_tf_zip):
|
||||||
result = dict()
|
result = dict()
|
||||||
for codename in codenames:
|
for codename in codenames:
|
||||||
codename = codename.strip()
|
codename = codename.strip()
|
||||||
if len(codename) > 0:
|
if codename:
|
||||||
result[codename] = api_level
|
result[codename] = api_level
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -926,6 +926,8 @@ def main(argv):
|
||||||
common.Usage(__doc__)
|
common.Usage(__doc__)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
common.InitLogging()
|
||||||
|
|
||||||
input_zip = zipfile.ZipFile(args[0], "r")
|
input_zip = zipfile.ZipFile(args[0], "r")
|
||||||
output_zip = zipfile.ZipFile(args[1], "w",
|
output_zip = zipfile.ZipFile(args[1], "w",
|
||||||
compression=zipfile.ZIP_DEFLATED,
|
compression=zipfile.ZIP_DEFLATED,
|
||||||
|
|
|
@ -491,6 +491,13 @@ class CommonApkUtilsTest(test_utils.ReleaseToolsTestCase):
|
||||||
wrong_input = os.path.join(self.testdata_dir, 'testkey.pk8')
|
wrong_input = os.path.join(self.testdata_dir, 'testkey.pk8')
|
||||||
self.assertRaises(AssertionError, common.ExtractPublicKey, wrong_input)
|
self.assertRaises(AssertionError, common.ExtractPublicKey, wrong_input)
|
||||||
|
|
||||||
|
def test_ExtractAvbPublicKey(self):
|
||||||
|
privkey = os.path.join(self.testdata_dir, 'testkey.key')
|
||||||
|
pubkey = os.path.join(self.testdata_dir, 'testkey.pubkey.pem')
|
||||||
|
with open(common.ExtractAvbPublicKey(privkey)) as privkey_fp, \
|
||||||
|
open(common.ExtractAvbPublicKey(pubkey)) as pubkey_fp:
|
||||||
|
self.assertEqual(privkey_fp.read(), pubkey_fp.read())
|
||||||
|
|
||||||
def test_ParseCertificate(self):
|
def test_ParseCertificate(self):
|
||||||
cert = os.path.join(self.testdata_dir, 'testkey.x509.pem')
|
cert = os.path.join(self.testdata_dir, 'testkey.x509.pem')
|
||||||
|
|
||||||
|
@ -1218,7 +1225,7 @@ super_group_foo_group_size={group_foo_size}
|
||||||
dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
|
dp_diff.WriteScript(self.script, output_zip, write_verify_script=True)
|
||||||
|
|
||||||
self.assertNotIn("block_image_update", str(self.script),
|
self.assertNotIn("block_image_update", str(self.script),
|
||||||
"Removed partition should not be patched.")
|
"Removed partition should not be patched.")
|
||||||
|
|
||||||
lines = self.get_op_list(self.output_path)
|
lines = self.get_op_list(self.output_path)
|
||||||
self.assertEqual(lines, ["remove foo"])
|
self.assertEqual(lines, ["remove foo"])
|
||||||
|
|
Loading…
Reference in New Issue