mirror of
https://gitee.com/openharmony/update_packaging_tools
synced 2024-11-23 06:40:03 +00:00
codex
Signed-off-by: unknown <zhangchun39@huawei.com>
This commit is contained in:
parent
0ae3873982
commit
f4132c2411
@ -623,8 +623,7 @@ def increment_image_processing(
|
||||
check_make_map_path(each_img)
|
||||
|
||||
if filecmp.cmp(each_src_image_path, each_tgt_image_path):
|
||||
UPDATE_LOGGER.print_log(
|
||||
"Source Image is the same as Target Image! src image path: %s, tgt image path: %s"
|
||||
UPDATE_LOGGER.print_log("Source Image is the same as Target Image! src image path: %s, tgt image path: %s"
|
||||
% (each_src_image_path, each_tgt_image_path), UPDATE_LOGGER.INFO_LOG)
|
||||
OPTIONS_MANAGER.incremental_img_list.remove(each_img)
|
||||
continue
|
||||
@ -632,12 +631,10 @@ def increment_image_processing(
|
||||
src_generate_map = True
|
||||
tgt_generate_map = True
|
||||
if not os.path.exists(each_src_map_path):
|
||||
src_generate_map = generate_image_map_file(each_src_image_path,
|
||||
each_src_map_path, each_img)
|
||||
src_generate_map = generate_image_map_file(each_src_image_path, each_src_map_path, each_img)
|
||||
|
||||
if not os.path.exists(each_tgt_map_path):
|
||||
tgt_generate_map = generate_image_map_file(each_tgt_image_path,
|
||||
each_tgt_map_path, each_img)
|
||||
tgt_generate_map = generate_image_map_file(each_tgt_image_path, each_tgt_map_path, each_img)
|
||||
|
||||
if not src_generate_map or not tgt_generate_map:
|
||||
if increment_image_diff_processing(each_img, each_src_image_path, each_tgt_image_path,
|
||||
|
@ -92,8 +92,7 @@ def create_input_package(
|
||||
os.mkdir(package_name_path)
|
||||
|
||||
if not is_miss_image:
|
||||
create_file(os.path.join(package_name_path, "system.img"),
|
||||
get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "system.img"), get_target_vendor_data())
|
||||
|
||||
# Judge the type of input package and generate the corresponding vendor.img
|
||||
if package_type == "target":
|
||||
@ -104,56 +103,41 @@ def create_input_package(
|
||||
print("Unknown package type!")
|
||||
raise RuntimeError
|
||||
if not is_miss_image:
|
||||
create_file(os.path.join(package_name_path, "vendor.img"),
|
||||
vendor_content)
|
||||
create_file(os.path.join(package_name_path, "vendor.img"), vendor_content)
|
||||
if not is_miss_updater_binary:
|
||||
create_file(os.path.join(package_name_path, "updater_binary"),
|
||||
UPDATER_BINARY_DATA)
|
||||
create_file(os.path.join(package_name_path, "updater_binary"), UPDATER_BINARY_DATA)
|
||||
# updater upgrade package
|
||||
if is_su:
|
||||
create_file(os.path.join(package_name_path, "uImage"),
|
||||
get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater.img"),
|
||||
get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater_b.img"),
|
||||
get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater_uImage"),
|
||||
get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "uImage"), get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater.img"), get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater_b.img"), get_target_vendor_data())
|
||||
create_file(os.path.join(package_name_path, "updater_uImage"), get_target_vendor_data())
|
||||
# Create updater_config dir.
|
||||
updater_config_path = "./%s/updater_config" % package_name
|
||||
if not os.path.exists(updater_config_path):
|
||||
os.mkdir(updater_config_path)
|
||||
create_file(os.path.join(updater_config_path, "BOARD.list"),
|
||||
BOARD_LIST_DATA)
|
||||
create_file(os.path.join(updater_config_path, "BOARD.list"), BOARD_LIST_DATA)
|
||||
if not is_miss_version_list:
|
||||
create_file(os.path.join(updater_config_path, "VERSION.mbn"),
|
||||
VERSION_MBN_DATA)
|
||||
create_file(os.path.join(updater_config_path, "VERSION.mbn"), VERSION_MBN_DATA)
|
||||
# Judge the type of input package and
|
||||
xml_content = \
|
||||
create_updater_specified_config_file(
|
||||
has_userdata, is_updater_partitions, package_type)
|
||||
create_updater_specified_config_file(has_userdata, is_updater_partitions, package_type)
|
||||
|
||||
if is_inc_full_none:
|
||||
xml_content = xml_content.replace("SYSTEM_MARK", "")
|
||||
xml_content = xml_content.replace(
|
||||
"COMPONENT_MARK", "").encode()
|
||||
xml_content = xml_content.replace("COMPONENT_MARK", "").encode()
|
||||
else:
|
||||
xml_content = xml_content.replace(
|
||||
"SYSTEM_MARK", SYSTEM_COMPONENT_STR)
|
||||
xml_content = xml_content.replace(
|
||||
"COMPONENT_MARK", COMPONENT_STR_FULL).encode()
|
||||
xml_content = xml_content.replace("SYSTEM_MARK", SYSTEM_COMPONENT_STR)
|
||||
xml_content = xml_content.replace("COMPONENT_MARK", COMPONENT_STR_FULL).encode()
|
||||
|
||||
create_file(
|
||||
os.path.join(updater_config_path, "updater_specified_config.xml"),
|
||||
xml_content)
|
||||
create_file(os.path.join(updater_config_path, "updater_specified_config.xml"), xml_content)
|
||||
# Create partition_file.xml.
|
||||
if is_updater_partitions:
|
||||
create_file("./partition_file.xml", UPDATER_PARTITIONS_XML_DATA)
|
||||
# Create rsa_private_key2048.pem.
|
||||
create_file("./rsa_private_key2048.pem", RSA_PRIVATE_KEY_DATA)
|
||||
# Create zip package.
|
||||
with zipfile.ZipFile('./%s.zip' % package_name,
|
||||
'w', zipfile.ZIP_DEFLATED) as package_zip:
|
||||
with zipfile.ZipFile('./%s.zip' % package_name, 'w', zipfile.ZIP_DEFLATED) as package_zip:
|
||||
package_zip.write(package_name_path)
|
||||
for home, dirs, files in os.walk(package_name_path):
|
||||
for each_file_name in files:
|
||||
|
@ -33,6 +33,46 @@ from update_package import build_update_package
|
||||
from update_package import get_component_list
|
||||
|
||||
|
||||
def fail_test_case_1():
|
||||
OPTIONS_MANAGER.hash_algorithm = 'sha256'
|
||||
OPTIONS_MANAGER.target_package_config_dir = \
|
||||
"./test_target_package/updater_config"
|
||||
OPTIONS_MANAGER.target_package_dir = \
|
||||
"./test_target_package/"
|
||||
with open(VERSION_MBN_PATH) as om_second_f:
|
||||
OPTIONS_MANAGER.total_script_file_obj = om_second_f
|
||||
OPTIONS_MANAGER.full_img_list = []
|
||||
OPTIONS_MANAGER.opera_script_file_name_dic = {}
|
||||
OPTIONS_MANAGER.private_key = "../"
|
||||
OPTIONS_MANAGER.product = 'Hi3516'
|
||||
prelude_script = PreludeScript()
|
||||
verse_script = VerseScript()
|
||||
refrain_script = RefrainScript()
|
||||
ending_script = EndingScript()
|
||||
check_re = build_update_package(
|
||||
False, 'test_dir', prelude_script, verse_script,
|
||||
refrain_script, ending_script)
|
||||
return check_re
|
||||
|
||||
|
||||
def fail_test_case_2():
|
||||
OPTIONS_MANAGER.hash_algorithm = 'sha256'
|
||||
OPTIONS_MANAGER.target_package_config_dir = ""
|
||||
OPTIONS_MANAGER.target_package_dir = \
|
||||
"./test_target_package/"
|
||||
with open(VERSION_MBN_PATH) as om_third_f:
|
||||
OPTIONS_MANAGER.total_script_file_obj = om_third_f
|
||||
OPTIONS_MANAGER.full_img_list = []
|
||||
OPTIONS_MANAGER.opera_script_file_name_dic = {}
|
||||
OPTIONS_MANAGER.private_key = "../"
|
||||
OPTIONS_MANAGER.product = 'Hi3516'
|
||||
verse_script = VerseScript()
|
||||
check_re = build_update_package(
|
||||
False, 'test_dir', prelude_script, verse_script,
|
||||
refrain_script, ending_script)
|
||||
return check_re
|
||||
|
||||
|
||||
class TestUpdatePackage(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@ -74,40 +114,10 @@ class TestUpdatePackage(unittest.TestCase):
|
||||
create_input_package(
|
||||
"test_target_package", package_type="source")
|
||||
|
||||
OPTIONS_MANAGER.hash_algorithm = 'sha256'
|
||||
OPTIONS_MANAGER.target_package_config_dir = \
|
||||
"./test_target_package/updater_config"
|
||||
OPTIONS_MANAGER.target_package_dir = \
|
||||
"./test_target_package/"
|
||||
with open(VERSION_MBN_PATH) as om_second_f:
|
||||
OPTIONS_MANAGER.total_script_file_obj = om_second_f
|
||||
OPTIONS_MANAGER.full_img_list = []
|
||||
OPTIONS_MANAGER.opera_script_file_name_dic = {}
|
||||
OPTIONS_MANAGER.private_key = "../"
|
||||
OPTIONS_MANAGER.product = 'Hi3516'
|
||||
prelude_script = PreludeScript()
|
||||
verse_script = VerseScript()
|
||||
refrain_script = RefrainScript()
|
||||
ending_script = EndingScript()
|
||||
check_re = build_update_package(
|
||||
False, 'test_dir', prelude_script, verse_script,
|
||||
refrain_script, ending_script)
|
||||
check_re = fail_test_case_1()
|
||||
self.assertEqual(check_re, False)
|
||||
|
||||
OPTIONS_MANAGER.hash_algorithm = 'sha256'
|
||||
OPTIONS_MANAGER.target_package_config_dir = ""
|
||||
OPTIONS_MANAGER.target_package_dir = \
|
||||
"./test_target_package/"
|
||||
with open(VERSION_MBN_PATH) as om_third_f:
|
||||
OPTIONS_MANAGER.total_script_file_obj = om_third_f
|
||||
OPTIONS_MANAGER.full_img_list = []
|
||||
OPTIONS_MANAGER.opera_script_file_name_dic = {}
|
||||
OPTIONS_MANAGER.private_key = "../"
|
||||
OPTIONS_MANAGER.product = 'Hi3516'
|
||||
verse_script = VerseScript()
|
||||
check_re = build_update_package(
|
||||
False, 'test_dir', prelude_script, verse_script,
|
||||
refrain_script, ending_script)
|
||||
check_re = fail_test_case_2()
|
||||
self.assertEqual(check_re, False)
|
||||
|
||||
if os.path.exists(VERSION_MBN_PATH):
|
||||
|
Loading…
Reference in New Issue
Block a user