Separate ISU data migration part from system RW-upgrade script 51/314951/2 accepted/tizen/unified/20240807.010724 accepted/tizen/unified/dev/20240807.093029 accepted/tizen/unified/toolchain/20240812.133118 accepted/tizen/unified/x/20240807.014257 accepted/tizen/unified/x/asan/20240813.231407
authorAdam Michalski <a.michalski2@partner.samsung.com>
Tue, 23 Jul 2024 11:50:57 +0000 (13:50 +0200)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Wed, 31 Jul 2024 08:44:31 +0000 (10:44 +0200)
This commit is the first in the pair of commits that are going to
move ISU data migration part from the main OS-Upgrade script to
the component RW-upgrade scripts (/usr/share/upgrade/scripts/).

Change-Id: I400e03e12a800c984efee01544083ba2248851ac

scripts/rw-upgrade/rw-update-macro.inc
scripts/rw-upgrade/update.sh.in

index 48d271658de8716f9f5b528f4c825891d0aa0404..9fc58a196840c222838094354bb512199fe2ab6b 100644 (file)
@@ -274,132 +274,3 @@ COMMIT_CHANGES()
 
        return 0
 }
-
-VERSION_COMPARE() {
-       local IFS='.'
-       ver_a=($1)
-       ver_b=($2)
-
-       local n
-       if [[ ${#ver_a[@]} > ${#ver_b[@]} ]]; then
-               n=${#ver_a[@]}
-       else
-               n=${#ver_b[@]}
-       fi
-       for ((i=0; i < n; i++)); do
-               if [[ $i -ge ${#ver_a[@]} ]]; then
-                       ver_a[$i]=0
-               fi
-               if [[ $i -ge ${#ver_b[@]} ]]; then
-                       ver_b[$i]=0
-               fi
-       done
-       for ((i=0; i < ${#ver_a[@]}; i++)); do
-               if (( ver_a[i] > ver_b[i] )); then
-                       return 1
-               elif (( ver_a[i] < ver_b[i] )); then
-                       return 2
-               fi
-       done
-       return 0
-}
-
-REMOVE_ISU_PKG()
-{
-       local PKG_NAME=$1
-       rm -rf "/opt/isu/$PKG_NAME"
-}
-
-TRY_START_SERVICE()
-{
-       local SERVICE=$1
-       local DESIRED_STATE=$2
-
-       systemctl start "$SERVICE"
-
-       if [ "$(systemctl is-active $SERVICE)" != "$DESIRED_STATE" ]; then
-               echo "Couldn't start service: $SERVICE"
-       fi
-}
-
-PREPARE_PKGMGR_ENV()
-{
-       TRY_START_SERVICE pkgmgr-info active
-       # "systemctl is-active" will output "inactive" for a oneshot unit
-       # that's currently not running but was successful last time it ran
-       TRY_START_SERVICE security-manager-rules-loader inactive
-       TRY_START_SERVICE security-manager active
-       TRY_START_SERVICE ac.service active
-       TRY_START_SERVICE package-manager active
-}
-
-REMOVE_ISU_APP_PKG()
-{
-       local PKG_NAME="$1"
-       local APP_NAME="org.tizen.isu.$PKG_NAME"
-       local APP_DIR="/opt/usr/globalapps/$APP_NAME"
-       if [ -d "$APP_DIR" ]; then
-               /usr/bin/pkgcmd -u -n "$APP_NAME"
-       fi
-}
-
-REMOVE_UNNECESSARY_ISU_PKGS()
-{
-       local OS_RELEASE_NAME
-       local UPGRADE_CFG_PATH=/etc/isu/upgrade.cfg
-       OS__tz_build_release_name=$(grep TZ_BUILD_RELEASE_NAME /etc/tizen-build.conf | awk -F '"' '{print $2}')
-       OS__tz_build_arch=$(grep TZ_BUILD_ARCH /etc/tizen-build.conf | awk -F '=' '{print $2}')
-       OS__model_name=$(sed -n  -e '/.*model_name.*/s!.*<key[^>]*>\(.*\)</key>!\1!gp' /etc/config/model-config.xml)
-       OS__manufacturer=$(sed -n  -e '/.*manufacturer.*/s!.*<key[^>]*>\(.*\)</key>!\1!gp' /etc/config/model-config.xml)
-       OS__device_type=$(sed -n  -e '/.*device_type.*/s!.*<key[^>]*>\(.*\)</key>!\1!gp' /etc/config/model-config.xml)
-
-       local platform_major_version_fields="tz_build_release_name tz_build_arch model_name device_type"
-       if [ -f "${UPGRADE_CFG_PATH}" ]; then
-               fields_from_file=$(grep -e ^platform_major_version_fields "${UPGRADE_CFG_PATH}" | cut -f2 -d= | sed -e 's/,/ /g')
-               if [ -n "${fields_from_file}" ]; then
-                       platform_major_version_fields="$fields_from_file"
-               fi
-       fi
-
-       for ISUCFG in $(find /opt/isu/ -maxdepth 2 -type f -name isu.cfg); do
-               PKG_NAME=$(basename "$(dirname "$ISUCFG")")
-               if [ ! -d "/etc/isu/$PKG_NAME" ]; then
-                       NOTIFY "Platform image does not contain information about ${PKG_NAME} - unable to verify which is newer (ISU or Platform). Dropping ISU package ${PKG_NAME}."
-                       REMOVE_ISU_PKG "$PKG_NAME"
-                       REMOVE_ISU_APP_PKG "$PKG_NAME"
-                       continue
-               fi
-               CUR_IMG_VERSION=$(grep -e "^version" "/etc/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               INSTALLED_VERSION=$(grep -e "^version" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               ISU__tz_build_release_name=$(grep -e "^tz_build_release_name" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               ISU__tz_build_arch=$(grep -e "^tz_build_arch" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               ISU__model_name=$(grep -e "^model_name" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               ISU__manufacturer=$(grep -e "^manufacturer" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-               ISU__device_type=$(grep -e "^device_type" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-
-
-               for field in $platform_major_version_fields; do
-                       os_value=OS__$field
-                       isu_value=ISU__$field
-                       if [ "${!os_value}" != "${!isu_value}" ]; then
-                               # One of the values defined in /opt/isu/upgrade.cfg is different.
-                               # In that case we remove the ISU package because it may
-                               # not be compatible with this version of the system.
-                               NOTIFY "${field} value is different for OS and ISU - removing incompatible ${PKG_NAME} ISU package"
-                               REMOVE_ISU_PKG "$PKG_NAME"
-                               REMOVE_ISU_APP_PKG "$PKG_NAME"
-                               continue 2
-                       fi
-
-               done
-
-               VERSION_COMPARE "$CUR_IMG_VERSION" "$INSTALLED_VERSION"
-
-               if [[ $? != 2 ]]; then
-                       # Package from the current image is newer than the one installed
-                       # so we can remove the installed one
-                       REMOVE_ISU_PKG "$PKG_NAME"
-                       REMOVE_ISU_APP_PKG "$PKG_NAME"
-               fi
-       done
-}
index f9dba2d084af8ae20bcc32c87873d2159e00ff9f..92a4a36b065dbe0d2a8249c689f30bb1b8e116b2 100644 (file)
@@ -150,12 +150,6 @@ else
                CURRENT_TASK=$(( ${CURRENT_TASK} + 1 ))
        done
 
-       NOTIFY "----------------------------------------------------------------------"
-       NOTIFY "Remove deprecated ISU Packages"
-
-       PREPARE_PKGMGR_ENV
-       REMOVE_UNNECESSARY_ISU_PKGS
-
        write_version_info
 fi