Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 48 additions & 45 deletions tools/gen_ota_zip.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,15 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder):
fd.write(str + "\n")
user_begin_script.close()

i = 0
patch_size_list = []
while i < bin_list_cnt:
for i in range(bin_list_cnt):
patch_size_list.append(speed_dict[bin_list[i]] *
get_file_size('%s/patch/%spatch' % (tmp_folder, bin_list[i][:-3])))
i += 1

i = 0
bin_size_list = []
while i < bin_list_cnt:
for i in range(bin_list_cnt):
bin_size_list.append(speed_dict[bin_list[i]] *
get_file_size('%s/%s' % (args.bin_path[1],bin_list[i])))
i += 1

for file in newpartition_list:
bin_size_list.append(speed_dict[file] * get_file_size('%s/%s' % (args.bin_path[1], file)))
Expand All @@ -105,17 +101,13 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder):
max_progress = 100 - args.user_end_script_progress
ota_progress_list = []

i = 0
while i < bin_list_cnt:
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))
i += 1

j = 0
while j < len(newpartition_list):
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))
j += 1

ota_progress_list[-1] = max_progress
str = \
Expand All @@ -131,8 +123,7 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder):
''' % (bin_list[bin_list_cnt - 1])
fd.write(str)

i = 0
while i < bin_list_cnt:
for i in range(bin_list_cnt):
str = \
'''
echo "generate %s"%s
Expand All @@ -152,7 +143,6 @@ def gen_diff_ota_sh(patch_path, bin_list, newpartition_list, args, tmp_folder):
if i + 1 < bin_list_cnt:
str += ' setprop ota.progress.next %d\n' % (ota_progress_list[i + 1])
fd.write(str)
i += 1

str = \
'''
Expand Down Expand Up @@ -289,6 +279,27 @@ def gen_diff_ota(args):
logger.info("%s, signature success!" % args.output)
os.rename(sign_output, args.output)

def gen_progress_list(start, end, path, bin_list):
bin_cnt = len(bin_list)
ota_progress = start
progress_list = []
size_list = []

if end <= start:
logger.error("Generate progress list error %d %d" % (start, end))
exit(22)

for i in range(bin_cnt):
size_list.append(speed_dict[bin_list[i]] *
get_file_size('%s/%s' % (path, bin_list[i])))

for i in range(bin_cnt):
ota_progress += float(size_list[i] / sum(size_list)) * (end - start)
progress_list.append(math.floor(ota_progress))

progress_list[-1] = end
return progress_list

def gen_full_sh(path_list, bin_list, args, tmp_folder):
path_cnt = len(path_list)
fd = open('%s/ota.sh' % (tmp_folder),'w')
Expand All @@ -301,50 +312,43 @@ def gen_full_sh(path_list, bin_list, args, tmp_folder):
fd.write(str + "\n")
user_begin_script.close()

i = 0
size_list = []
while i < path_cnt:
size_list.append(speed_dict[bin_list[i]] *
get_file_size('%s/%s' % (args.bin_path[0], bin_list[i])))
i += 1

ota_progress = 30.0
max_progress = 100 - args.user_end_script_progress
ota_progress_list = []
verify_list = []
verify_path = []
for i in range(path_cnt):
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])
verify_list.append(bin_list[i])
verify_path.append(path_list[i])

i = 0
while i < path_cnt:
ota_progress += float(size_list[i] / sum(size_list)) * (max_progress - 30.0)
ota_progress_list.append(math.floor(ota_progress))
i += 1
verify_progress_list = gen_progress_list(30.0, 40.0, args.bin_path[0], verify_list)
ota_progress_list = gen_progress_list(45.0, 100 - args.user_end_script_progress, args.bin_path[0], bin_list)

ota_progress_list[-1] = max_progress
str = \
'''set +e
setprop ota.progress.current 30
setprop ota.progress.next %d
''' % (ota_progress_list[0])
''' % (verify_progress_list[0])
fd.write(str)

i = 0
while i < path_cnt:
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 += \
for i in range(len(verify_list)):
str = \
'''
avb_verify -U /ota/%s %s /etc/key.avb
if [ $? -ne 0 ]
then
echo "check %s version failed!"%s
echo "Check %s version failed!"%s
setprop ota.progress.current -1
exit
reboot
fi
''' % (bin_list[i], path_list[i], bin_list[i], args.otalog)
setprop ota.progress.current %d
''' % (verify_list[i], verify_path[i], verify_list[i], args.otalog, verify_progress_list[i])
str += 'setprop ota.progress.next %d\n' % ( verify_progress_list[i + 1] if i + 1 < len(verify_list) else ota_progress_list[0])
fd.write(str)

str += \
for i in range(path_cnt):
str = \
'''
echo "install %s"%s
time " dd if=/ota/%s of=%s bs=%s verify"
Expand All @@ -360,7 +364,6 @@ def gen_full_sh(path_list, bin_list, args, tmp_folder):
if i + 1 < path_cnt:
str += 'setprop ota.progress.next %d\n' % (ota_progress_list[i + 1])
fd.write(str)
i += 1

if args.user_end_script:
user_end_script = open(args.user_end_script,"r")
Expand Down
Loading