Add support for /etc/isu/upgrade.cfg 67/298167/6 accepted/tizen/8.0/unified/20231005.093909 accepted/tizen/unified/20230912.013607 tizen_8.0_m2_release
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 1 Sep 2023 11:42:16 +0000 (13:42 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Thu, 7 Sep 2023 12:48:35 +0000 (14:48 +0200)
Configuration file /etc/isu/upgrade.conf specifies what fields will be
checked when verifying the compatiblity of the ISU package during OS
Upgrade.

Fields that should be taken into account should be specified as comma
separated list for option:

    platform_major_version_fields=

Change-Id: I7c0251117516080b6d362991770cc6abff113d5e

packaging/upgrade.spec
scripts/rw-upgrade/update.sh.in

index 527ad7a..023c44e 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:          upgrade
 Summary:       Upgrade support for Tizen
-Version:       8.0.1
+Version:       8.0.2
 Release:       0
 Group:         System
 License:       Apache-2.0
index 5d3739d..d3ed298 100644 (file)
@@ -111,7 +111,20 @@ REMOVE_ISU_PKG()
 REMOVE_UNNECESSARY_ISU_PKGS()
 {
        local OS_RELEASE_NAME
-       OS_RELEASE_NAME=$(grep TZ_BUILD_RELEASE_NAME /etc/tizen-build.conf | awk -F '"' '{print $2}')
+       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 /etc/isu/ -type f -name isu.cfg); do
                PKG_NAME=$(basename "$(dirname "$ISUCFG")")
@@ -120,15 +133,26 @@ REMOVE_UNNECESSARY_ISU_PKGS()
                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_RELEASE_NAME=$(grep -e "^tz_build_release_name" "/opt/isu/$PKG_NAME/isu.cfg" | awk -F "=" '{ gsub(/[ ]+/, ""); print $2}')
-
-               if [ "$OS_RELEASE_NAME" != "$ISU_RELEASE_NAME" ]; then
-                       # Release name of the current image and package are different.
-                       # In that case we remove the ISU package because it may
-                       # not be compatible with this version of the system.
-                       REMOVE_ISU_PKG "$PKG_NAME"
-                       continue
-               fi
+               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"
+                               continue 2
+                       fi
+
+               done
 
                VERSION_COMPARE "$CUR_IMG_VERSION" "$INSTALLED_VERSION"