From: Mateusz Moscicki Date: Thu, 11 May 2023 11:49:03 +0000 (+0200) Subject: rw-upgrade: Remove deprecated ISU Pkgs after OS upgrade X-Git-Tag: accepted/tizen/unified/20230822.043319~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94d0e467e4b9eda7ebdac91d165627415d698259;p=platform%2Fcore%2Fsystem%2Fupgrade.git rw-upgrade: Remove deprecated ISU Pkgs after OS upgrade Change-Id: Ibe1a96ce2f29a64348a02ab95172e17c69870f66 --- diff --git a/scripts/rw-upgrade/update.sh.in b/scripts/rw-upgrade/update.sh.in index 43653e2..26d965a 100644 --- a/scripts/rw-upgrade/update.sh.in +++ b/scripts/rw-upgrade/update.sh.in @@ -73,6 +73,55 @@ PROGRESS() echo "$1" > ${PROGRESS_DIR}/progress } +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_UNNECESSARY_ISU_PKGS() +{ + for ISUCFG in $(find /etc/isu/ -type f -name isu.cfg); do + PKG_NAME=$(basename "$(dirname "$ISUCFG")") + if [ ! -d "/opt/isu/$PKG_NAME" ]; then + 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}') + + 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 + rm -rf "/opt/isu/$PKG_NAME" + fi + done +} + # This result file will be used for Platform Update Control API to get update result. UPDATE_RESULT_FILE=${UPDATE_DATA_DIR}/result UPI_RW_UPDATE_ERROR_NONE=00 @@ -100,6 +149,11 @@ then exit fi +NOTIFY "----------------------------------------------------------------------" +NOTIFY "Remove deprecated ISU Packages" + +REMOVE_UNNECESSARY_ISU_PKGS + NOTIFY "----------------------------------------------------------------------" NOTIFY "System RW update: rw update started"