From 7f1a1df95f50de46737e591248bbe809f3a728bf Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Wed, 6 Mar 2024 16:27:25 +0900 Subject: [PATCH] Add new tool to make update-control-server.conf make-update-control-config.sh creates config file (/opt/usr/update-control-server.conf) for downloading delta file. update-control-server.conf contains: * URL for delta download * user id for authentication * api key for authentication Informations above are provided in section. Below is an example of update-control-server.conf: > [BART] > delta_url= > user_id= > api_key= Change-Id: I99af101a3ca7a91c83d5d2cc8916f11871e6f814 Signed-off-by: SangYoun Kwak --- packaging/update-control-generic.spec | 3 + tools/scripts/make-update-control-config.sh | 82 +++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 tools/scripts/make-update-control-config.sh diff --git a/packaging/update-control-generic.spec b/packaging/update-control-generic.spec index c673946..8ec073b 100644 --- a/packaging/update-control-generic.spec +++ b/packaging/update-control-generic.spec @@ -43,6 +43,8 @@ export CFLAGS+=" -Wno-stringop-truncation" %install %make_install +mkdir -p %{buildroot}/%{_bindir} +install -m 0755 tools/scripts/make-update-control-config.sh %{buildroot}/%{_bindir}/make-update-control-config.sh %post /sbin/ldconfig @@ -53,3 +55,4 @@ export CFLAGS+=" -Wno-stringop-truncation" %manifest %{name}.manifest %license LICENSE %{SYSTEM_PLUGIN_LIBDIR}/libplugin-backend-update-control.so* +%{_bindir}/make-update-control-config.sh diff --git a/tools/scripts/make-update-control-config.sh b/tools/scripts/make-update-control-config.sh new file mode 100755 index 0000000..dae2e6e --- /dev/null +++ b/tools/scripts/make-update-control-config.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +RESULT_FILE_PATH='/opt/usr/update-control-server.conf' + +DELTA_TYPE="" +TTF_LAST_SUCCESS_LOG="" +FOTA_FROM_URL_BASE="" +USER_ID="" +API_KEY="" + +function get_device_type { + system-info-tool --get "http://tizen.org/system/device_type" | cut -d' ' -f2 | cut -d'=' -f2 2> /dev/null +} + +function get_device_model { + system-info-tool --get "http://tizen.org/system/model_name" | cut -d' ' -f2 | cut -d'=' -f2 2> /dev/null +} + +function get_device_arch { + sed --quiet 's/^BUILD_ID=.*-\([^-]\+\)$/\1/p' /etc/tizen-release +} + +function get_device_release_name { + sed --quiet 's/^TZ_BUILD_RELEASE_NAME="\(.*\)"$/\1/p' /etc/tizen-build.conf | tr '/' '_' +} + +function get_device_image_version { + sed --quiet 's/^Release=\(.*\);$/\1/p' /etc/info.ini +} + +function get_latest_success_image_version { + local arch=$1 + local tizen_image_fname_regex='tizen-unified_\([0-9]\{8\}\.[0-9]\{6\}\)_tizen-headed-'${arch}'\.tar\.gz' + + # ex) 20240216.120214 + curl ${TTF_LAST_SUCCESS_LOG} -s | + grep -as wget | + sed -n "s/.*${tizen_image_fname_regex}.*/\\1/p" 2>/dev/null +} + +function make_update_control_config { + local device_type=$(get_device_type) + local device_model=$(get_device_model) + local arch=$(get_device_arch) + local release_name=$(get_device_release_name) + + local image_version_from=$(get_device_image_version) + local image_version_to=$(get_latest_success_image_version ${arch}) + + if [[ -z ${image_version_from} ]]; then + echo "Failed to get \"from\" image version." + return 1 + fi + + if [[ -z ${image_version_to} ]]; then + echo "Failed to get \"to\" image version." + return 1 + fi + + local delta_fname="${device_type}--${device_model}--${DELTA_TYPE}--${arch}--${image_version_from}@${image_version_to}.tar.gz" + local delta_url="${FOTA_FROM_URL_BASE}/${release_name}/${delta_fname}" + + :> ${RESULT_FILE_PATH} + echo "[BART]" >> ${RESULT_FILE_PATH} + echo "delta_url=${delta_url}" >> ${RESULT_FILE_PATH} + echo "user_id=${USER_ID}" >> ${RESULT_FILE_PATH} + echo "api_key=${API_KEY}" >> ${RESULT_FILE_PATH} +} + +if [[ $# -ne 5 ]]; then + echo "usage: $0 " + exit 1 +fi + +DELTA_TYPE=$1 +TTF_LAST_SUCCESS_LOG=$2 +FOTA_FROM_URL_BASE=$3 +USER_ID=$4 +API_KEY=$5 + +make_update_control_config +exit 0 -- 2.34.1