mirror of
https://gitee.com/openharmony/update_packaging_tools
synced 2024-11-23 06:40:03 +00:00
change the location of the patch and verify files
Signed-off-by: lizhao <lizhao104@huawei.com>
This commit is contained in:
parent
286585c7be
commit
dbf8d0bbf1
@ -564,8 +564,7 @@ def increment_image_diff_processing(
|
||||
"""
|
||||
patch_file_obj = tempfile.NamedTemporaryFile(
|
||||
prefix="%s_patch.dat-" % partition, mode='wb')
|
||||
OPTIONS_MANAGER.incremental_image_file_obj_list.append(
|
||||
patch_file_obj)
|
||||
OPTIONS_MANAGER.incremental_image_file_obj_dict[partition] = patch_file_obj
|
||||
cmd = [DIFF_EXE_PATH]
|
||||
|
||||
cmd.extend(['-s', src_image_path, '-d', tgt_image_path,
|
||||
@ -618,7 +617,6 @@ def increment_image_processing(
|
||||
"src image path: %s, tgt image path: %s" %
|
||||
(each_src_image_path, each_tgt_image_path),
|
||||
UPDATE_LOGGER.INFO_LOG)
|
||||
OPTIONS_MANAGER.component_info_dict.pop(each_img)
|
||||
OPTIONS_MANAGER.incremental_img_name_list.remove(each_img)
|
||||
first_block_check_cmd = verse_script.first_block_check(each_img)
|
||||
abort_cmd = verse_script.abort(each_img)
|
||||
@ -675,9 +673,9 @@ def increment_image_processing(
|
||||
patch_package_process.PatchProcess(
|
||||
each_img, tgt_image_class, src_image_class, actions_list)
|
||||
patch_process.patch_process()
|
||||
patch_process.package_patch_zip.package_patch_zip()
|
||||
patch_process.write_script(each_img, script_check_cmd_list,
|
||||
script_write_cmd_list, verse_script)
|
||||
OPTIONS_MANAGER.incremental_block_file_obj_dict[each_img] = patch_process.package_patch_zip
|
||||
if block_diff > 0:
|
||||
if not check_patch_file(patch_process):
|
||||
UPDATE_LOGGER.print_log(
|
||||
|
@ -28,6 +28,7 @@ from utils import FILE_MAP_ZERO_KEY
|
||||
from utils import FILE_MAP_NONZERO_KEY
|
||||
from utils import FILE_MAP_COPY_KEY
|
||||
from utils import MAX_BLOCKS_PER_GROUP
|
||||
from utils import UPDATE_BIN_FILE_NAME
|
||||
|
||||
|
||||
class FullUpdateImage:
|
||||
@ -72,12 +73,11 @@ class FullUpdateImage:
|
||||
full_image_file_obj_list.append(each_img)
|
||||
UPDATE_LOGGER.print_log(
|
||||
"Image %s full processing completed" % img_name)
|
||||
if not self.no_zip:
|
||||
# No zip mode (no script command)
|
||||
image_write_cmd = \
|
||||
self.verse_script.image_write(each_name, img_name, each_img.name)
|
||||
cmd = '%s_WRITE_FLAG%s' % (each_name, image_write_cmd)
|
||||
self.verse_script.add_command(cmd=cmd)
|
||||
if not self.no_zip:
|
||||
# No zip mode (no script command)
|
||||
image_write_cmd = self.verse_script.full_image_update(UPDATE_BIN_FILE_NAME)
|
||||
cmd = '%s_WRITE_FLAG%s' % (UPDATE_BIN_FILE_NAME, image_write_cmd)
|
||||
self.verse_script.add_command(cmd=cmd)
|
||||
|
||||
UPDATE_LOGGER.print_log(
|
||||
"All full image processing completed! image count: %d" %
|
||||
|
@ -524,8 +524,6 @@ class PackagePatchZip:
|
||||
|
||||
self.partition_file_obj = tempfile.NamedTemporaryFile(
|
||||
dir=OPTIONS_MANAGER.target_package, prefix="partition_patch-")
|
||||
OPTIONS_MANAGER.incremental_image_file_obj_list.append(
|
||||
self.partition_file_obj)
|
||||
|
||||
def get_file_obj(self):
|
||||
"""
|
||||
@ -534,20 +532,10 @@ class PackagePatchZip:
|
||||
return self.new_dat_file_obj, self.patch_dat_file_obj, \
|
||||
self.transfer_list_file_obj
|
||||
|
||||
def package_patch_zip(self):
|
||||
"""
|
||||
Compress the partition diff patch calculation data as *.zip package.
|
||||
"""
|
||||
self.partition_file_obj.seek(0)
|
||||
self.patch_dat_file_obj.seek(0)
|
||||
self.new_dat_file_obj.seek(0)
|
||||
self.transfer_list_file_obj.seek(0)
|
||||
|
||||
with zipfile.ZipFile(self.partition_file_obj.name, 'w', zipfile.ZIP_DEFLATED) as zip_file:
|
||||
# add new.dat to {partition}.zip
|
||||
zip_file.write(self.new_dat_file_obj.name, self.partition_new_dat_file_name)
|
||||
# add patch.dat to {partition}.zip
|
||||
zip_file.write(self.patch_dat_file_obj.name, self.partition_patch_dat_file_name)
|
||||
# add transfer.list to {partition}.zip
|
||||
zip_file.write(self.transfer_list_file_obj.name, self.partition_transfer_file_name)
|
||||
UPDATE_LOGGER.print_log("Create %s.zip success!" % self.partition)
|
||||
def package_block_patch(self, zip_file):
|
||||
# add new.dat to ota.zip
|
||||
zip_file.write(self.new_dat_file_obj.name, self.partition_new_dat_file_name)
|
||||
# add patch.dat to ota.zip
|
||||
zip_file.write(self.patch_dat_file_obj.name, self.partition_patch_dat_file_name)
|
||||
# add transfer.list to ota.zip
|
||||
zip_file.write(self.transfer_list_file_obj.name, self.partition_transfer_file_name)
|
||||
|
@ -30,6 +30,7 @@ from utils import PARTITION_FILE
|
||||
from utils import TOTAL_SCRIPT_FILE_NAME
|
||||
from utils import SCRIPT_FILE_NAME
|
||||
from utils import SCRIPT_KEY_LIST
|
||||
from utils import UPDATE_BIN_FILE_NAME
|
||||
|
||||
|
||||
class Script:
|
||||
@ -230,6 +231,10 @@ class VerseScript(Script):
|
||||
"""
|
||||
cmd = 'update_partitions("/%s");\n' % PARTITION_FILE
|
||||
return cmd
|
||||
|
||||
def full_image_update(self, update_file_name):
|
||||
cmd = 'update_from_bin("%s");\n' % update_file_name
|
||||
return cmd
|
||||
|
||||
|
||||
class RefrainScript(Script):
|
||||
@ -292,17 +297,23 @@ def get_progress_value(distributable_value=100):
|
||||
"get progress value failed! > getting progress value failed!",
|
||||
UPDATE_LOGGER.ERROR_LOG)
|
||||
return False
|
||||
for idx, _ in enumerate(incremental_img_list):
|
||||
for partition in incremental_img_list:
|
||||
# Obtain the size of the incremental image file.
|
||||
file_obj = OPTIONS_MANAGER.incremental_image_file_obj_list[idx]
|
||||
each_img_size = os.path.getsize(file_obj.name)
|
||||
if partition in OPTIONS_MANAGER.incremental_image_file_obj_dict:
|
||||
file_obj = OPTIONS_MANAGER.incremental_image_file_obj_dict[partition]
|
||||
each_img_size = os.path.getsize(file_obj.name)
|
||||
else:
|
||||
new_dat_file_obj, patch_dat_file_obj, transfer_list_file_obj =\
|
||||
OPTIONS_MANAGER.incremental_block_file_obj_dict[partition].get_file_obj()
|
||||
each_img_size = os.path.getsize(new_dat_file_obj.name) + os.path.getsize(patch_dat_file_obj.name)
|
||||
file_size_list.append(each_img_size)
|
||||
|
||||
total_full_img_size = 0
|
||||
for idx, _ in enumerate(full_img_list):
|
||||
# Obtain the size of the full image file.
|
||||
file_obj = OPTIONS_MANAGER.full_image_file_obj_list[idx]
|
||||
each_img_size = os.path.getsize(file_obj.name)
|
||||
file_size_list.append(each_img_size)
|
||||
total_full_img_size += os.path.getsize(file_obj.name)
|
||||
file_size_list.append(total_full_img_size)
|
||||
|
||||
proportion_value_list = get_proportion_value_list(
|
||||
file_size_list, distributable_value=distributable_value)
|
||||
@ -310,7 +321,7 @@ def get_progress_value(distributable_value=100):
|
||||
adjusted_proportion_value_list = adjust_proportion_value_list(
|
||||
proportion_value_list, distributable_value)
|
||||
|
||||
all_img_list = incremental_img_list + full_img_list
|
||||
all_img_list = incremental_img_list + [UPDATE_BIN_FILE_NAME]
|
||||
current_progress = 40
|
||||
for idx, each_img in enumerate(all_img_list):
|
||||
temp_progress = current_progress + adjusted_proportion_value_list[idx]
|
||||
|
@ -38,6 +38,7 @@ from utils import UPDATE_EXE_FILE_NAME
|
||||
from utils import TOTAL_SCRIPT_FILE_NAME
|
||||
from utils import EXTEND_COMPONENT_LIST
|
||||
from utils import LINUX_HASH_ALGORITHM_DICT
|
||||
from utils import UPDATE_BIN_FILE_NAME
|
||||
from utils import BUILD_TOOLS_FILE_NAME
|
||||
from utils import SIGN_PACKAGE_EVENT
|
||||
from utils import GENERATE_SIGNED_DATA_EVENT
|
||||
@ -103,23 +104,15 @@ def create_update_bin():
|
||||
component_dict = OPTIONS_MANAGER.component_info_dict
|
||||
full_image_file_obj_list = OPTIONS_MANAGER.full_image_file_obj_list
|
||||
full_img_list = OPTIONS_MANAGER.full_img_list
|
||||
incremental_img_list = OPTIONS_MANAGER.incremental_img_list
|
||||
incremental_image_file_obj_list = \
|
||||
OPTIONS_MANAGER.incremental_image_file_obj_list
|
||||
|
||||
all_image_file_obj_list = \
|
||||
incremental_image_file_obj_list + full_image_file_obj_list
|
||||
if not OPTIONS_MANAGER.not_l2:
|
||||
if OPTIONS_MANAGER.partition_file_obj is not None:
|
||||
all_image_name = \
|
||||
EXTEND_COMPONENT_LIST + EXTEND_OPTIONAL_COMPONENT_LIST + \
|
||||
incremental_img_list + full_img_list
|
||||
EXTEND_COMPONENT_LIST + EXTEND_OPTIONAL_COMPONENT_LIST + full_img_list
|
||||
else:
|
||||
all_image_name = \
|
||||
EXTEND_COMPONENT_LIST + incremental_img_list + full_img_list
|
||||
all_image_name = EXTEND_COMPONENT_LIST + full_img_list
|
||||
else:
|
||||
all_image_name = \
|
||||
incremental_img_list + full_img_list
|
||||
all_image_name = full_img_list
|
||||
sort_component_dict = collect.OrderedDict()
|
||||
for each_image_name in all_image_name:
|
||||
sort_component_dict[each_image_name] = \
|
||||
@ -128,7 +121,7 @@ def create_update_bin():
|
||||
head_list = get_head_list(len(component_dict), head_value_list)
|
||||
|
||||
component_list = get_component_list(
|
||||
all_image_file_obj_list, component_dict)
|
||||
full_image_file_obj_list, component_dict)
|
||||
|
||||
save_patch = update_bin_obj.name.encode("utf-8")
|
||||
if OPTIONS_MANAGER.private_key == ON_SERVER:
|
||||
@ -456,7 +449,14 @@ def build_update_package(no_zip, update_package, prelude_script,
|
||||
zip_file.write(OPTIONS_MANAGER.update_bin_obj.name, "update.bin")
|
||||
# add build_tools.zip to update package
|
||||
zip_file.write(OPTIONS_MANAGER.build_tools_zip_obj.name, BUILD_TOOLS_FILE_NAME)
|
||||
zip_file.close()
|
||||
zip_file.write(OPTIONS_MANAGER.version_mbn_file_path, "version_list")
|
||||
zip_file.write(OPTIONS_MANAGER.board_list_file_path, "board_list")
|
||||
|
||||
for package_patch_zip in OPTIONS_MANAGER.incremental_block_file_obj_dict.values():
|
||||
package_patch_zip.package_block_patch(zip_file)
|
||||
|
||||
for partition, patch_obj in OPTIONS_MANAGER.incremental_image_file_obj_dict.items():
|
||||
zip_file.write(patch_obj.name, partition + ".patch.dat")
|
||||
|
||||
signed_package = os.path.join(
|
||||
update_package, "%s.zip" % update_file_name)
|
||||
|
6
utils.py
6
utils.py
@ -33,6 +33,7 @@ from build_pkcs7 import sign_ota_package
|
||||
operation_path = os.path.dirname(os.path.realpath(__file__))
|
||||
PRODUCT = 'hi3516'
|
||||
BUILD_TOOLS_FILE_NAME = 'build_tools.zip'
|
||||
UPDATE_BIN_FILE_NAME = "update.bin"
|
||||
UPDATE_EXE_FILE_NAME = "updater_binary"
|
||||
|
||||
SCRIPT_KEY_LIST = ['prelude', 'verse', 'refrain', 'ending']
|
||||
@ -178,7 +179,8 @@ class OptionsManager:
|
||||
|
||||
# Incremental processing parameters
|
||||
self.incremental_content_len_list = []
|
||||
self.incremental_image_file_obj_list = []
|
||||
self.incremental_image_file_obj_dict = {}
|
||||
self.incremental_block_file_obj_dict = {}
|
||||
self.incremental_temp_file_obj_list = []
|
||||
self.src_image = None
|
||||
self.tgt_image = None
|
||||
@ -301,7 +303,7 @@ def parse_update_config(xml_path):
|
||||
|
||||
if not OPTIONS_MANAGER.not_l2:
|
||||
expand_component(component_dict)
|
||||
if isinstance(component_info, OrderedDict):
|
||||
if isinstance(component_info, OrderedDict) or isinstance(component_info, dict):
|
||||
component_info = [component_info]
|
||||
if component_info is None:
|
||||
ret_params = [[], {}, [], [], '', [], False]
|
||||
|
Loading…
Reference in New Issue
Block a user