Fix migration script by review 87/309587/4
authordyamy-lee <dyamy.lee@samsung.com>
Fri, 12 Apr 2024 09:18:21 +0000 (18:18 +0900)
committerdyamy-lee <dyamy.lee@samsung.com>
Wed, 17 Apr 2024 11:02:57 +0000 (20:02 +0900)
It changes checking condition as SRC_PREV_ENGINE_PATH and it defines before use.
It fixes missed '/' when making path between get_rw_path and usr.
It changes destination path checking only from 7.0 to 8.0.
It changes DST_CONF_PATH with full path.
It changes checking exist of each SRC path.

Change-Id: I5fba34ab441ae4347f08f70951f8afb50d05e28d

script/migration/tts.sh

index 1ff57e389b4f49f93b116ee3292ecc2cb0e88603..3319b4149663312b4bce13acf0dbcad34fe6b6c0 100644 (file)
@@ -12,52 +12,53 @@ source "$UPDATE_EXEC_PATH/common/error_handle.inc"
 function tts_migration() {
     log I "TTS Migration config files"
 
-    local SRC_PATH=$(get_old_rw_path)/usr/data/.voice/tts
-    local DST_PATH=$(get_rw_path)/usr/data/.voice/tts
+    local SRC_PATH=$(get_old_rw_path)/usr/data/.voice/tts/
+    local DST_PATH=$(get_rw_path)/usr/data/.voice/tts/
     local SRC_CONF_PATH=$(get_old_rw_path)/usr/data/.voice/tts-config.xml
-    local DST_CONF_PATH=$(get_rw_path)/usr/data/.voice/
-
-    if [ ! -e $DST_PATH ]; then
-        log I "TTS Migration set destination path"
-        mkdir -p -m 0775 $(get_rw_path)/usr/data/.voice
-        chsmack -t $(get_rw_path)/usr/data/.voice
-        chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice
-        mkdir -p $(get_rw_path)usr/data/.voice/tts/engine-info
-        chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice/tts
-        chsmack -t $(get_rw_path)/usr/data/.voice/tts/engine-info
-        chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice/tts/engine-info
-        chown -R ui_fw:users $(get_rw_path)/usr/data/.voice
-    fi
+    local DST_CONF_PATH=$(get_rw_path)/usr/data/.voice/tts-config.xml
+    local SRC_PREV_ENGINE_PATH=$(get_old_rw_path)/usr/home/owner/share/.voice/tts/1.0/engine-info/
 
-    if [ -e $SRC_PREV_CONF_PATH ]; then
+    if [ -e $SRC_PREV_ENGINE_PATH ]; then
+        VERSON=$(get_old_platform_version)
+        log I "Previous Version is $VERSION"
         log I "TTS Migration 7.0 only START"
-        SRC_PREV_ENGINE_PATH=$(get_old_rw_path)/usr/home/owner/share/.voice/tts/1.0/engine-info
-        DST_NEW_ENGINE_PATH=$(get_rw_path)/usr/data/.voice/tts/engine-info
         SRC_PREV_CONF_PATH=$(get_old_rw_path)/usr/home/owner/share/.voice/tts-config.xml
-
-        if [ ! -e $SRC_PREV_ENGINE_PATH ]; then
-            log E "TTS Migration ERROR : No orignal Data"
-            return
-        fi
-
-        ## change backgound_volume_ratio value type from float to integer in 8.0
-        background_volume_ratio=$(awk -F '<|>' '/background-volume-ratio/{print $3}' $SRC_PREV_CONF_PATH)
-        log I "bg volume = $background_volume_ratio"
-        if [[ "${background_volume_ratio}" =~ ^[0-9]+$ ]]; then
-            integer_volume_ratio=${background_volume_ratio}
-        else
-            integer_volume_ratio=$(echo $background_volume_ratio | awk '{printf "%.2f\n", $1}' | awk '{$1=$1*100; print $1}')
+        DST_NEW_ENGINE_PATH=$(get_rw_path)/usr/data/.voice/tts/engine-info/
+
+        # each 7.0 and after 8.0 has different location about configuration. It needs new path.
+        if [ ! -e $(get_rw_path)/usr/data/.voice/tts/engine-info ]; then
+            log I "TTS Migration set destination path for only Tizen 7.0"
+            mkdir -p -m 0775 $(get_rw_path)/usr/data/.voice
+            chsmack -t $(get_rw_path)/usr/data/.voice
+            chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice
+            mkdir -p $(get_rw_path)/usr/data/.voice/tts/engine-info
+            chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice/tts
+            chsmack -t $(get_rw_path)/usr/data/.voice/tts/engine-info
+            chsmack -a "User::App::Shared" $(get_rw_path)/usr/data/.voice/tts/engine-info
+            chown -R ui_fw:users $(get_rw_path)/usr/data/.voice
         fi
 
-        log I "after change bg volume = $integer_volume_ratio"
-        sed -i "s/<background-volume-ratio>[^<]*<\/background-volume-ratio>/<background-volume-ratio>${integer_volume_ratio}\<\/background-volume-ratio>/" $SRC_PREV_CONF_PATH
-
-
         mig_copy $SRC_PREV_ENGINE_PATH $DST_NEW_ENGINE_PATH || error_handle "default_data" $LINENO
-        mig_copy $SRC_PREV_CONF_PATH $DST_CONF_PATH || error_handle "default_data" $LINENO
+
+        # The 'tts-config.xml' file may or may not exist, depending on the condition
+        if [ -e $SRC_PREV_CONF_PATH ]; then
+            ## change backgound_volume_ratio value type from float to integer in 8.0
+            background_volume_ratio=$(awk -F '<|>' '/background-volume-ratio/{print $3}' $SRC_PREV_CONF_PATH)
+            log I "bg volume = $background_volume_ratio"
+            if [[ "${background_volume_ratio}" =~ ^[0-9]+$ ]]; then
+                integer_volume_ratio=${background_volume_ratio}
+            else
+                integer_volume_ratio=$(echo $background_volume_ratio | awk '{printf "%.2f\n", $1}' | awk '{$1=$1*100; print $1}')
+            fi
+
+            log I "after change bg volume = $integer_volume_ratio"
+            sed -i "s/<background-volume-ratio>[^<]*<\/background-volume-ratio>/<background-volume-ratio>${integer_volume_ratio}\<\/background-volume-ratio>/" $SRC_PREV_CONF_PATH
+
+            mig_copy $SRC_PREV_CONF_PATH $DST_CONF_PATH || error_handle "default_data" $LINENO
+            chmod 664 $(get_rw_path)/usr/data/.voice/tts-config.xml
+        fi
 
         chown -R ui_fw:users $(get_rw_path)/usr/data/.voice
-        chmod 664 $(get_rw_path)/usr/data/.voice/tts-config.xml
 
         log I "TTS Migration 7.0 only END"
     else
@@ -69,7 +70,12 @@ function tts_migration() {
         fi
 
         mig_copy $SRC_PATH $DST_PATH || error_handle "default_data" $LINENO
-        mig_copy $SRC_CONF_PATH $DST_CONF_PATH || error_handle "default_data" $LINENO
+
+        # The 'tts-config.xml' file may or may not exist, depending on the condition
+        if [ -e $SRC_CONF_PATH ]; then
+            mig_copy $SRC_CONF_PATH $DST_CONF_PATH || error_handle "default_data" $LINENO
+        fi
+
         log I "TTS Migration after 8.0 END"
     fi
 }