diff --git a/tools/gen_ota_zip.py b/tools/gen_ota_zip.py index 4fbffe0..519112e 100755 --- a/tools/gen_ota_zip.py +++ b/tools/gen_ota_zip.py @@ -99,15 +99,15 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder): ota_progress = 30.0 max_progress = 100 - args.user_end_script_progress + gen_progress = (max_progress - ota_progress) * float(sum(bin_size_list[:bin_list_cnt]) / sum (bin_size_list)) ota_progress_list = [] for i in range(bin_list_cnt): - ota_progress += float(patch_size_list[i] / sum(patch_size_list)) * (max_progress - 30) - ota_progress_list.append(math.floor(ota_progress)) + ota_progress_list.insert(len(ota_progress_list) // 2, math.floor(ota_progress + float(sum(patch_size_list[:i + 1]) / sum(patch_size_list)) * gen_progress * 0.1)) + ota_progress_list.append(math.floor(ota_progress + gen_progress * 0.1 + float(sum(patch_size_list[:i + 1]) / sum(patch_size_list)) * gen_progress * 0.9)) for j in range(len(newpartition_list)): - ota_progress += float(bin_size_list[i + j] / sum(bin_size_list)) * (max_progress - 70) - ota_progress_list.append(math.floor(ota_progress)) + ota_progress_list.append(math.floor(ota_progress + gen_progress + float(sum(bin_size_list[bin_list_cnt:bin_list_cnt + j + 1]) / sum(bin_size_list[bin_list_cnt:])) * (max_progress - ota_progress - gen_progress))) ota_progress_list[-1] = max_progress str = \ @@ -117,39 +117,28 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder): ''' % (ota_progress_list[0]) fd.write(str) - str = \ -'''if [ ! -e /ota/%s ] -then -''' % (bin_list[bin_list_cnt - 1]) - fd.write(str) - - for i in range(bin_list_cnt): + bin_list_cnt *= 2 + for i, j in zip(list(range(bin_list_cnt // 2)) * 2, range(bin_list_cnt)): str = \ ''' - echo "generate %s"%s - time "ddelta_apply %s %s/ /ota/%spatch" - if [ $? -ne 0 ] - then - echo "ddelta_apply %s failed"%s - setprop ota.progress.current -1 - exit - fi - - setprop ota.progress.current %d +echo "generate %s"%s +time "ddelta_apply %s %s/ /ota/%spatch %s" +if [ $? -ne 0 ] +then + echo "ddelta_apply %s failed"%s + setprop ota.progress.current -1 + reboot +fi + +setprop ota.progress.current %d ''' % (bin_list[i], args.otalog, - patch_path[i], args.ota_tmp, bin_list[i][:-3], + patch_path[i], args.ota_tmp, bin_list[i][:-3], "precheck" if j < bin_list_cnt // 2 else "", bin_list[i][:-4], args.otalog, - ota_progress_list[i]) - if i + 1 < bin_list_cnt: - str += ' setprop ota.progress.next %d\n' % (ota_progress_list[i + 1]) + ota_progress_list[j]) + if j + 1 < bin_list_cnt: + str += 'setprop ota.progress.next %d\n' % (ota_progress_list[j + 1]) fd.write(str) - str = \ -''' -fi -''' - fd.write(str) - i = 0 for file in newpartition_list: str = \