Loading tools/releasetools/validate_target_files.py +13 −11 Original line number Diff line number Diff line Loading @@ -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. """ import common import logging import os.path import re import sparse_img import sys import common import sparse_img def _GetImage(which, tmpdir): assert which in ('system', 'vendor') Loading Loading @@ -64,7 +65,7 @@ def _ReadFile(file_name, unpacked_name, round_up=False): def ValidateFileAgainstSha1(input_tmp, file_name, file_path, expected_sha1): """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) assert os.path.exists(unpacked_name) actual_sha1 = _ReadFile(file_name, unpacked_name, False).sha1 Loading Loading @@ -147,10 +148,10 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): script_path = 'SYSTEM/bin/install-recovery.sh' 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 logging.info('Checking {}'.format(script_path)) logging.info('Checking %s', script_path) with open(os.path.join(input_tmp, script_path), 'r') as script: lines = script.read().strip().split('\n') assert len(lines) >= 6 Loading Loading @@ -182,7 +183,8 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): boot_info = applypatch_argv[boot_info_index].strip().split(':') assert len(boot_info) == 4 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 expected_recovery_sha1 = applypatch_argv[recovery_sha1_index] Loading @@ -191,7 +193,7 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): file_path='IMAGES/recovery.img', expected_sha1=expected_recovery_sha1) logging.info('Done checking {}'.format(script_path)) logging.info('Done checking %s', script_path) def main(argv): Loading Loading
tools/releasetools/validate_target_files.py +13 −11 Original line number Diff line number Diff line Loading @@ -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. """ import common import logging import os.path import re import sparse_img import sys import common import sparse_img def _GetImage(which, tmpdir): assert which in ('system', 'vendor') Loading Loading @@ -64,7 +65,7 @@ def _ReadFile(file_name, unpacked_name, round_up=False): def ValidateFileAgainstSha1(input_tmp, file_name, file_path, expected_sha1): """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) assert os.path.exists(unpacked_name) actual_sha1 = _ReadFile(file_name, unpacked_name, False).sha1 Loading Loading @@ -147,10 +148,10 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): script_path = 'SYSTEM/bin/install-recovery.sh' 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 logging.info('Checking {}'.format(script_path)) logging.info('Checking %s', script_path) with open(os.path.join(input_tmp, script_path), 'r') as script: lines = script.read().strip().split('\n') assert len(lines) >= 6 Loading Loading @@ -182,7 +183,8 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): boot_info = applypatch_argv[boot_info_index].strip().split(':') assert len(boot_info) == 4 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 expected_recovery_sha1 = applypatch_argv[recovery_sha1_index] Loading @@ -191,7 +193,7 @@ def ValidateInstallRecoveryScript(input_tmp, info_dict): file_path='IMAGES/recovery.img', expected_sha1=expected_recovery_sha1) logging.info('Done checking {}'.format(script_path)) logging.info('Done checking %s', script_path) def main(argv): Loading