diff --git a/tools/gen_ota_zip.py b/tools/gen_ota_zip.py index 39234c2..74bc3a2 100755 --- a/tools/gen_ota_zip.py +++ b/tools/gen_ota_zip.py @@ -11,6 +11,7 @@ import filecmp import configparser import re +import subprocess program_description = \ ''' @@ -43,6 +44,7 @@ patch_path = [] bin_list = [] tools_path='' +avbtool_path=os.path.abspath(os.path.dirname(sys.argv[0]) + '/../../../../external/avb/avb/avbtool') speed_dict = {} logging.basicConfig(format = "[%(levelname)s]%(message)s") logger = logging.getLogger() @@ -326,7 +328,12 @@ def gen_full_sh(path_list, bin_list, args, tmp_folder): i = 0 while i < path_cnt: - str = \ + str = '' + ret = subprocess.Popen("%s info_image --image %s/%s --rollback_index" % (avbtool_path, args.bin_path[0], bin_list[i]), shell=True, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL); + idx = ret.communicate() + if (ret.returncode == 0) and (int(idx[0]) != 0): + logger.debug("Enabled update verification for %s" % bin_list[i]) + str += \ ''' avb_verify -U /ota/%s %s /etc/key.avb if [ $? -ne 0 ] @@ -538,6 +545,9 @@ def gen_full_ota(args): if inputstr != 'Y' and inputstr != 'y': exit() + if not os.path.exists(avbtool_path): + logger.error("avbtool: %s: No such file or directory", avbtool_path) + exit() if len((args.bin_path)) == 2: os.chdir(tools_path) if not os.path.exists("ddelta_generate"):