cd ${DELTA_DIR}
cp ${COMMON_BINDIR}/unpack.sh ./
-if [ ! -r "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_BIN} ]; then
- fn_extract_files_from_partition rootfs.img
-else
- cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_BIN} .
- cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_DELTAFS_BIN} .
- cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_SUPPORT_DIR}/* .
- cp "${EXTRACTED_FILES_DIR}"/${DELTA_VERIFIER_BIN} .
- cp "${EXTRACTED_FILES_DIR}"/${BLKID_PRINT_BIN} .
- cp "${EXTRACTED_FILES_DIR}"/${RESIZE_DYNPARTS_BIN} .
- cp "${EXTRACTED_FILES_DIR}"/${COPY_BLOCKDEV_BIN} .
+if fn_get_tar_file_names rootfs.img "${OLD_TAR_DIR}"; then
+ # If this binary was not extracted, it means no rootfs related files were,
+ # and we need to extract them now
+ if [ ! -r "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_BIN} ]; then
+ fn_extract_files_from_partition rootfs.img
+ else
+ cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_BIN} .
+ cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_APPLY_DELTAFS_BIN} .
+ cp "${EXTRACTED_FILES_DIR}"/${UPGRADE_SUPPORT_DIR}/* .
+ cp "${EXTRACTED_FILES_DIR}"/${DELTA_VERIFIER_BIN} .
+ cp "${EXTRACTED_FILES_DIR}"/${BLKID_PRINT_BIN} .
+ cp "${EXTRACTED_FILES_DIR}"/${RESIZE_DYNPARTS_BIN} .
+ cp "${EXTRACTED_FILES_DIR}"/${COPY_BLOCKDEV_BIN} .
+ fi
fi
-
if [ ! -r "${HAL_TARG_NAME}" ]; then
# Check if there is hal.img provided
# If not then ok, just the update-info.ini file will not contain model_name information
SYSTEM_PREFIX = os.path.join(TIZEN_PREFIX, "system")
BUILD_PREFIX = "TZ_BUILD_"
+class ConfigFilesExistanceVerfier:
+ def __init__(self, hal_model_config_path, rootfs_model_config_path, tizen_build_config_path):
+ self.hal_model_config_path = hal_model_config_path
+ self.rootfs_model_config_path = rootfs_model_config_path
+ self.tizen_build_config_path = tizen_build_config_path
+
+ self.hal_model_config_exists = os.path.exists(hal_model_config_path) and os.path.isfile(hal_model_config_path)
+ self.rootfs_model_config_exists = os.path.exists(rootfs_model_config_path) and os.path.isfile(rootfs_model_config_path)
+ self.tizen_build_config_exists = os.path.exists(tizen_build_config_path) and os.path.isfile(tizen_build_config_path)
+
+ # rootfs_model_config and tizen_build_config have to be either both found, or both missing.
+ # hal_model_config doesn't have to be found, unless both rootfs_model_config and tizen_build_config are missing
+ def check_if_proper_combination_exists(self):
+ self.is_combination_proper = True
+ self.message = ""
+
+ if self.rootfs_model_config_exists ^ self.tizen_build_config_exists:
+ if not self.rootfs_model_config_exists:
+ self.message = f'One of config files from rootfs.img not found. Missing file: {self.rootfs_model_config_path}'
+ else:
+ self.message = f'One of config files from rootfs.img not found. Missing file: {self.tizen_build_config_path}'
+
+ self.is_combination_proper = False
+ return
+
+ if self.hal_model_config_exists:
+ if self.rootfs_model_config_exists:
+ self.message = f'Config files from both hal.img and rootfs.img will be used'
+ else:
+ self.message = f'Config file from only hal.img will be used'
+ else:
+ if self.rootfs_model_config_exists:
+ self.message = f'Config files form only rootfs.img will be used'
+ else:
+ self.message = f'No config files were found.'
+ self.is_combination_proper = False
+
+ def inform_about_combination(self):
+ if self.is_combination_proper:
+ print(f'{self.message}')
+ else:
+ print(f'{self.message}', file=sys.stderr)
+
# following three could be simpler, but this way its easier in case we add more variables to check
def generate_hal_model_config_set(full_type):
return None
-def generate_main_dict(args):
+def generate_main_dict(args, config_files_existance_verifier):
main_dict = {}
hal_set = generate_hal_model_config_set(args.full_type)
# hal.img is not required. On the other hand, if it is available, the
# resulting update-info.cfg file will also contain information from hal.img
- if hal_set and os.path.exists(args.hal_model_config_path):
+ if hal_set and config_files_existance_verifier.hal_model_config_exists:
hal_dict = get_dict_from_xml_file(args.hal_model_config_path, hal_set)
if not hal_dict:
print(f'{args.hal_model_config_path}: error parsing file', file=sys.stderr)
main_dict.update(hal_dict)
- if rootfs_set:
+ # Similarly to the comment above, rootfs.img is not required.
+ if rootfs_set and config_files_existance_verifier.rootfs_model_config_exists:
rootfs_dict = get_dict_from_xml_file(args.rootfs_model_config_path, rootfs_set)
if not rootfs_dict:
print(f'{args.rootfs_model_config_path}: error parsing file', file=sys.stderr)
main_dict.update(rootfs_dict)
- if tizen_set:
+ if tizen_set and config_files_existance_verifier.tizen_build_config_exists:
tizen_dict = get_dict_from_text_file(args.tizen_build_config_path, tizen_set)
if not tizen_dict:
print(f'{args.tizen_build_config_path}: error parsing file', file=sys.stderr)
if os.path.exists(args.output_file):
parser.error(f'{args.output_file} already exists!')
- for file in [args.rootfs_model_config_path, args.tizen_build_config_path]:
- if not (os.path.exists(file) and os.path.isfile(file)):
- parser.error(f'{file} is not a valid path!')
-
print('--- Generate update info file ---')
- update_data = generate_main_dict(args)
+
+ config_files_existance_verifier = \
+ ConfigFilesExistanceVerfier(args.hal_model_config_path, args.rootfs_model_config_path, args.tizen_build_config_path)
+
+ config_files_existance_verifier.check_if_proper_combination_exists()
+ config_files_existance_verifier.inform_about_combination()
+
+ if not config_files_existance_verifier.is_combination_proper:
+ raise Exception
+
+ update_data = generate_main_dict(args, config_files_existance_verifier)
if not update_data:
# TODO make this exception more verbose
raise Exception