Add ISU rpk package removal during OS Upgrade 12/309512/9
authorAdam Michalski <a.michalski2@partner.samsung.com>
Thu, 11 Apr 2024 14:15:27 +0000 (16:15 +0200)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Thu, 23 May 2024 14:46:31 +0000 (16:46 +0200)
Removal of the ISU packages from /opt/isu has already been done, but
in addition to that removing files from /opt/usr/globalapps needs to
be done as well.

Change-Id: I10c751fbae0693a1f1510e27ab71151893918d41

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

index 4af6812da79d6d44b8f7ae5e1a355f1719e746df..48d271658de8716f9f5b528f4c825891d0aa0404 100644 (file)
@@ -310,6 +310,39 @@ REMOVE_ISU_PKG()
        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
@@ -333,6 +366,7 @@ REMOVE_UNNECESSARY_ISU_PKGS()
                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}')
@@ -353,6 +387,7 @@ REMOVE_UNNECESSARY_ISU_PKGS()
                                # 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
 
@@ -364,6 +399,7 @@ REMOVE_UNNECESSARY_ISU_PKGS()
                        # 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 e642e7a5543b86fdc5bb794371c3bd6bd44307bb..722af347635acbbef4196cc61340ab5ef86ed841 100644 (file)
@@ -100,11 +100,6 @@ then
        exit
 fi
 
-NOTIFY "----------------------------------------------------------------------"
-NOTIFY "Remove deprecated ISU Packages"
-
-REMOVE_UNNECESSARY_ISU_PKGS
-
 NOTIFY "----------------------------------------------------------------------"
 NOTIFY "System RW update: rw update started"
 
@@ -154,6 +149,12 @@ else
                CURRENT_TASK=$(( ${CURRENT_TASK} + 1 ))
        done
 
+       NOTIFY "----------------------------------------------------------------------"
+       NOTIFY "Remove deprecated ISU Packages"
+
+       PREPARE_PKGMGR_ENV
+       REMOVE_UNNECESSARY_ISU_PKGS
+
        write_version_info
 
        if [ ${UPDATE_PROGRESS_ERR} = "1" ]