Merge "releasetools: Make validate_target_files.py pylint clean." am: a4c7d59afc
am: 41a3a414f0
am: dc68afc7f0
Change-Id: Ic5ea0d13816cfa889608e48414e34763b61c8112
This commit is contained in:
commit
91391637f9
|
@ -23,13 +23,14 @@ It performs checks to ensure the integrity of the input zip.
|
||||||
same check also applies to the vendor image if present.
|
same check also applies to the vendor image if present.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import common
|
|
||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import sparse_img
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import common
|
||||||
|
import sparse_img
|
||||||
|
|
||||||
|
|
||||||
def _GetImage(which, tmpdir):
|
def _GetImage(which, tmpdir):
|
||||||
assert which in ('system', 'vendor')
|
assert which in ('system', 'vendor')
|
||||||
|
@ -64,13 +65,13 @@ def _ReadFile(file_name, unpacked_name, round_up=False):
|
||||||
def ValidateFileAgainstSha1(input_tmp, file_name, file_path, expected_sha1):
|
def ValidateFileAgainstSha1(input_tmp, file_name, file_path, expected_sha1):
|
||||||
"""Check if the file has the expected SHA-1."""
|
"""Check if the file has the expected SHA-1."""
|
||||||
|
|
||||||
logging.info('Validating the SHA-1 of {}'.format(file_name))
|
logging.info('Validating the SHA-1 of %s', file_name)
|
||||||
unpacked_name = os.path.join(input_tmp, file_path)
|
unpacked_name = os.path.join(input_tmp, file_path)
|
||||||
assert os.path.exists(unpacked_name)
|
assert os.path.exists(unpacked_name)
|
||||||
actual_sha1 = _ReadFile(file_name, unpacked_name, False).sha1
|
actual_sha1 = _ReadFile(file_name, unpacked_name, False).sha1
|
||||||
assert actual_sha1 == expected_sha1, \
|
assert actual_sha1 == expected_sha1, \
|
||||||
'SHA-1 mismatches for {}. actual {}, expected {}'.format(
|
'SHA-1 mismatches for {}. actual {}, expected {}'.format(
|
||||||
file_name, actual_sha1, expected_sha1)
|
file_name, actual_sha1, expected_sha1)
|
||||||
|
|
||||||
|
|
||||||
def ValidateFileConsistency(input_zip, input_tmp):
|
def ValidateFileConsistency(input_zip, input_tmp):
|
||||||
|
@ -147,10 +148,10 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict):
|
||||||
|
|
||||||
script_path = 'SYSTEM/bin/install-recovery.sh'
|
script_path = 'SYSTEM/bin/install-recovery.sh'
|
||||||
if not os.path.exists(os.path.join(input_tmp, script_path)):
|
if not os.path.exists(os.path.join(input_tmp, script_path)):
|
||||||
logging.info('{} does not exist in input_tmp'.format(script_path))
|
logging.info('%s does not exist in input_tmp', script_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.info('Checking {}'.format(script_path))
|
logging.info('Checking %s', script_path)
|
||||||
with open(os.path.join(input_tmp, script_path), 'r') as script:
|
with open(os.path.join(input_tmp, script_path), 'r') as script:
|
||||||
lines = script.read().strip().split('\n')
|
lines = script.read().strip().split('\n')
|
||||||
assert len(lines) >= 6
|
assert len(lines) >= 6
|
||||||
|
@ -168,7 +169,7 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict):
|
||||||
expected_recovery_sha1 = applypatch_argv[3].strip()
|
expected_recovery_sha1 = applypatch_argv[3].strip()
|
||||||
assert expected_recovery_check_sha1 == expected_recovery_sha1
|
assert expected_recovery_check_sha1 == expected_recovery_sha1
|
||||||
ValidateFileAgainstSha1(input_tmp, 'recovery.img',
|
ValidateFileAgainstSha1(input_tmp, 'recovery.img',
|
||||||
'SYSTEM/etc/recovery.img', expected_recovery_sha1)
|
'SYSTEM/etc/recovery.img', expected_recovery_sha1)
|
||||||
else:
|
else:
|
||||||
# We're patching boot.img to get recovery.img where bonus_args is optional
|
# We're patching boot.img to get recovery.img where bonus_args is optional
|
||||||
if applypatch_argv[1] == "-b":
|
if applypatch_argv[1] == "-b":
|
||||||
|
@ -182,16 +183,17 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict):
|
||||||
boot_info = applypatch_argv[boot_info_index].strip().split(':')
|
boot_info = applypatch_argv[boot_info_index].strip().split(':')
|
||||||
assert len(boot_info) == 4
|
assert len(boot_info) == 4
|
||||||
ValidateFileAgainstSha1(input_tmp, file_name='boot.img',
|
ValidateFileAgainstSha1(input_tmp, file_name='boot.img',
|
||||||
file_path='IMAGES/boot.img', expected_sha1=boot_info[3])
|
file_path='IMAGES/boot.img',
|
||||||
|
expected_sha1=boot_info[3])
|
||||||
|
|
||||||
recovery_sha1_index = boot_info_index + 2
|
recovery_sha1_index = boot_info_index + 2
|
||||||
expected_recovery_sha1 = applypatch_argv[recovery_sha1_index]
|
expected_recovery_sha1 = applypatch_argv[recovery_sha1_index]
|
||||||
assert expected_recovery_check_sha1 == expected_recovery_sha1
|
assert expected_recovery_check_sha1 == expected_recovery_sha1
|
||||||
ValidateFileAgainstSha1(input_tmp, file_name='recovery.img',
|
ValidateFileAgainstSha1(input_tmp, file_name='recovery.img',
|
||||||
file_path='IMAGES/recovery.img',
|
file_path='IMAGES/recovery.img',
|
||||||
expected_sha1=expected_recovery_sha1)
|
expected_sha1=expected_recovery_sha1)
|
||||||
|
|
||||||
logging.info('Done checking {}'.format(script_path))
|
logging.info('Done checking %s', script_path)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
Loading…
Reference in New Issue