From: Adam Michalski Date: Tue, 23 Jul 2024 11:50:57 +0000 (+0200) Subject: Separate ISU data migration part from system RW-upgrade script X-Git-Tag: accepted/tizen/unified/20240807.010724^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44e80d34b30e6f97d0a00ea4ccb3f78e283e2520;p=platform%2Fcore%2Fsystem%2Fupgrade.git Separate ISU data migration part from system RW-upgrade script 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 --- diff --git a/scripts/rw-upgrade/rw-update-macro.inc b/scripts/rw-upgrade/rw-update-macro.inc index 48d2716..9fc58a1 100644 --- a/scripts/rw-upgrade/rw-update-macro.inc +++ b/scripts/rw-upgrade/rw-update-macro.inc @@ -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!.*]*>\(.*\)!\1!gp' /etc/config/model-config.xml) - OS__manufacturer=$(sed -n -e '/.*manufacturer.*/s!.*]*>\(.*\)!\1!gp' /etc/config/model-config.xml) - OS__device_type=$(sed -n -e '/.*device_type.*/s!.*]*>\(.*\)!\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 -} diff --git a/scripts/rw-upgrade/update.sh.in b/scripts/rw-upgrade/update.sh.in index f9dba2d..92a4a36 100644 --- a/scripts/rw-upgrade/update.sh.in +++ b/scripts/rw-upgrade/update.sh.in @@ -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