From: SangYoun Kwak Date: Wed, 8 May 2024 11:21:33 +0000 (+0900) Subject: Modify script for ks to set delta name properly X-Git-Tag: accepted/tizen/unified/20240605.153140~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abf86b5ee9a9cef4300b69b13ac7b725cc2e015d;p=platform%2Fcore%2Fsystem%2Fupgrade-tools.git Modify script for ks to set delta name properly To make delta image name properly, source image version and destination image version are retrieved. Also informations like device(like rpi4) and architectures are retrieved from parameter for the delta image name. Change-Id: If16b8c30d6f9ff317044e0e12656b692350b5b25 Signed-off-by: SangYoun Kwak --- diff --git a/scripts/delta-generation-runscript-kickstart.sh b/scripts/delta-generation-runscript-kickstart.sh index d4549fa..6661a8c 100755 --- a/scripts/delta-generation-runscript-kickstart.sh +++ b/scripts/delta-generation-runscript-kickstart.sh @@ -7,25 +7,99 @@ TARGET='' IMAGE_TYPE='' TIZEN_VERSION='' +IMAGE_USAGE_TYPE='' +ARCH='' +DEVICE_TARGET='' + +SOURCE_IMAGE_VERSION='' +SOURCE_IMAGE_FILE_PATH='' +DESTINATION_IMAGE_VERSION='' +DESTINATION_IMAGE_FILE_PATH='' + UPGRADE_TOOLS_PATH="/upgrade-tools" +parse_image_type() { + IMAGE_USAGE_TYPE=$(echo "${IMAGE_TYPE}" | cut -d'-' -f2) + ARCH=$(echo "${IMAGE_TYPE}" | cut -d'-' -f3) + DEVICE_TARGET=$(echo "${IMAGE_TYPE}" | cut -d'-' -f4) +} + setup_directories() { cd ${UPGRADE_TOOLS_PATH} ./scripts/directory-setup.sh mk_delta } -prepare_old_image() { - local old_img_path="${UPGRADE_TOOLS_PATH}/mk_delta/${TARGET}/data/old_tar/." +get_image_version_boot() { + local img_path=$1 + local img_fname="hal.img" + + cd /tmp + tar xfv "${img_path}" "${img_fname}" > /dev/null 2>&1 + + local mountpoint=$(mktemp -d) + + mount -o ro "${img_fname}" ${mountpoint} + local img_version=$(sed -n 's@^Release=\(.*\);$@\1@p' "${mountpoint}/etc/hal-info.ini") + umount ${mountpoint} + + rm -rf "${mountpoint}" "${img_fname}" + + echo "${img_version}" +} + +get_image_version_platform() { + local img_path=$1 + local img_fname="rootfs.img" + + cd /tmp + tar xfv "${img_path}" "${img_fname}" > /dev/null 2>&1 + + local mountpoint=$(mktemp -d) + + mount -o ro "${img_fname}" ${mountpoint} + local img_version=$(sed -n 's@^Release=\(.*\);$@\1@p' "${mountpoint}/etc/info.ini") + umount ${mountpoint} + + rm -rf "${mountpoint}" "${img_fname}" + + echo "${img_version}" +} + +get_image_version() { + local img_path=$1 + local img_usage_type=$(echo "${IMAGE_TYPE}" | cut -d'-' -f2) + + cd /tmp + + case ${img_usage_type} in + "boot") + get_image_version_boot "${img_path}" + ;; + "headed"|"headless") + get_image_version_platform "${img_path}" + ;; + *) + echo "Image type not supported: ${img_usage_type}" + return 1 + ;; + esac +} + +prepare_source_image() { cd ${UPGRADE_TOOLS_PATH} - ./scripts/delta-generation-download-source-image.sh "${IMAGE_TYPE}" "${TIZEN_VERSION}" - mv ./*.tar.gz "${old_img_path}" + local source_img_file_name=$(./scripts/delta-generation-download-source-image.sh "${IMAGE_TYPE}" "${TIZEN_VERSION}") + SOURCE_IMAGE_FILE_PATH="${UPGRADE_TOOLS_PATH}/mk_delta/${TARGET}/data/old_tar/${source_img_file_name}" + mv ./${source_img_file_name} "${SOURCE_IMAGE_FILE_PATH}" + SOURCE_IMAGE_VERSION=$(get_image_version "${SOURCE_IMAGE_FILE_PATH}") } -prepare_new_image() { - local new_img_path="${UPGRADE_TOOLS_PATH}/mk_delta/${TARGET}/data/new_tar/." +prepare_destination_image() { + local destination_image_file_name="dest_img.tar" + DESTINATION_IMAGE_FILE_PATH="${UPGRADE_TOOLS_PATH}/mk_delta/${TARGET}/data/new_tar/${destination_image_file_name}" cd ${IMG_DIR_PATH} - tar cvf "dest_img.tar" -- * - mv "${IMG_DIR_PATH}/dest_img.tar" "${new_img_path}" + tar cvf "${destination_image_file_name}" -- * + mv "${IMG_DIR_PATH}/${destination_image_file_name}" "${DESTINATION_IMAGE_FILE_PATH}" + DESTINATION_IMAGE_VERSION=$(get_image_version "${DESTINATION_IMAGE_FILE_PATH}") } create_delta() { @@ -34,7 +108,11 @@ create_delta() { cd "${UPGRADE_TOOLS_PATH}/mk_delta/${TARGET}/result" local delta_path=$(find -name 'delta.tar') - cp "${delta_path}" "${IMG_DIR_PATH}/." + gzip ${delta_path} + delta_path="${delta_path}.gz" + + local delta_file_name="IoT--${DEVICE_TARGET}--${IMAGE_USAGE_TYPE}--${ARCH}--${SOURCE_IMAGE_VERSION}@${DESTINATION_IMAGE_VERSION}.tar.gz" + mv "${delta_path}" "${IMG_DIR_PATH}/../out/${delta_file_name}" } TARGET=$1 @@ -49,7 +127,8 @@ if [[ -z ${TARGET} ]] || [[ -z ${IMAGE_TYPE} ]] || [[ -z ${TIZEN_VERSION} ]]; th exit 1 fi +parse_image_type setup_directories -prepare_old_image -prepare_new_image +prepare_source_image +prepare_destination_image create_delta