Add new tool to make update-control-server.conf 28/307228/6
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 6 Mar 2024 07:27:25 +0000 (16:27 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Thu, 7 Mar 2024 08:29:32 +0000 (17:29 +0900)
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=<url for delta download>
> user_id=<user id to authenticate delta url>
> api_key=<api key corresponds to the user id above>

Change-Id: I99af101a3ca7a91c83d5d2cc8916f11871e6f814
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
packaging/update-control-generic.spec
tools/scripts/make-update-control-config.sh [new file with mode: 0755]

index c673946311f6b02926b5bd94717191885ce8d274..8ec073b2f0048d1f1e24652539cdd461b903dadd 100644 (file)
@@ -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 (executable)
index 0000000..dae2e6e
--- /dev/null
@@ -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 <delta type> <url to get last ttf-success log> <delta downloading server url> <user id> <api key>"
+       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