Add support for the "Online Update" accepted/tizen/unified/20240430.020633 accepted/tizen/unified/toolchain/20240508.012353 accepted/tizen/unified/x/20240430.094814 accepted/tizen/unified/x/20240507.051009
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Wed, 17 Apr 2024 10:09:32 +0000 (12:09 +0200)
committerChanwoo Choi <cw00.choi@samsung.com>
Fri, 26 Apr 2024 05:52:08 +0000 (14:52 +0900)
"Online Update" is a new type of OS Update.
After "reboot fota" the normal boot will be performed, and in addition
the following targets will be run:

* online-update-pre.target - this target startup is reached very realy -
  after mouting the file system and before starting services. Within
  this target, changes to permission and directory structure, for
  example, should take place.

* online-update.target - this target is started after the basic services
  (like dlog, dbus) are started. Data migration of services should take
  place within this target.

If a service requires data migration after an upgrade, it should provide
a service that will perform the migration at the appropriate time of
system startup. For example:

  [Unit]
  Description=Bluetooth upgrade service
  ConditionKernelCommandLine=bootmode=fota
  Before=online-update.target bluetooth-share.service
  After=opt.mount
  DefaultDependencies=no

  [Service]
  Type=oneshot
  ExecStart=/usr/share/upgrade/scripts/bluetooth-share/bluetooth-share_upgrade.sh
  SmackProcessLabel=System

  [Install]
  RequiredBy=online-update.target

The lines:

  Before=online-update.target bluetooth-share.service
  After=opt.mount

are responsible for starting the service at the right time.

The old upgrade type is still supported. If the system is booted like
this:

    /usr/lib/systemd/systemd --unit=system-update.target

the old upgrade (Offline) will be performed. And if it runs like this:

   /usr/lib/systemd/system --unit=online-update.target

then the new upgrade (Online) will be performed.

Change-Id: I691af6c500da66fb537fd744e40fec2e7a607242

17 files changed:
packaging/upgrade.spec
scripts/rw-upgrade/CMakeLists.txt
scripts/rw-upgrade/online-update-failure.service [new file with mode: 0644]
scripts/rw-upgrade/online-update-failure.target [new file with mode: 0644]
scripts/rw-upgrade/online-update-pre.service.in [new file with mode: 0644]
scripts/rw-upgrade/online-update-pre.sh.in [new file with mode: 0644]
scripts/rw-upgrade/online-update-pre.target [new file with mode: 0644]
scripts/rw-upgrade/online-update-success.service [new file with mode: 0644]
scripts/rw-upgrade/online-update-success.sh.in [new file with mode: 0644]
scripts/rw-upgrade/online-update-verify.service.in [new file with mode: 0644]
scripts/rw-upgrade/online-update-verify.sh.in [new file with mode: 0644]
scripts/rw-upgrade/online-update.service.in [new file with mode: 0644]
scripts/rw-upgrade/online-update.sh.in [new file with mode: 0644]
scripts/rw-upgrade/online-update.target [new file with mode: 0644]
scripts/rw-upgrade/rw-update-macro.inc
scripts/rw-upgrade/update-finalize.service [deleted file]
scripts/rw-upgrade/update.sh.in

index a28a103c7a48b2c54f37d4e47fa8b7c7b2778b7c..f1551ca6b7e73e5a050612f4804e60b14c68b446 100644 (file)
@@ -94,6 +94,9 @@ ctest -V %{?_smp_mflags}
 
 mkdir -p %{buildroot}%{upgrade_support_dir}
 install -m 755 scripts/upgrade-support/* %{buildroot}%{upgrade_support_dir}
+mkdir -p %{buildroot}%{upgrade_scripts_dir}/online-update-scripts-pre
+mkdir -p %{buildroot}%{upgrade_scripts_dir}/online-update-scripts
+mkdir -p %{buildroot}%{upgrade_scripts_dir}/online-update-verify
 
 %define fota_dir /opt/usr/data/fota
 mkdir -p %{buildroot}%{fota_dir}
@@ -108,10 +111,15 @@ mkdir -p %{buildroot}%{_unitdir}/recovery.service.wants
 install -m 644 scripts/clone_partitions/clone_partitions_recovery.service %{buildroot}%{_unitdir}
 ln -s ../clone_partitions_recovery.service %{buildroot}%{_unitdir}/recovery.service.wants/
 
+
 # rw-update
 mkdir -p %{buildroot}%{_unitdir}/system-update.target.wants
 mkdir -p %{buildroot}%{_unitdir}/local-fs.target.wants
 mkdir -p %{buildroot}%{_unitdir}/delayed.target.wants
+mkdir -p %{buildroot}%{_unitdir}/online-update-pre.target.requires
+mkdir -p %{buildroot}%{_unitdir}/online-update.target.requires
+mkdir -p %{buildroot}%{_unitdir}/online-update-failure.target.requires
+mkdir -p %{buildroot}%{_unitdir}/online-update-success.service.requires
 ln -s ../getty.target %{buildroot}%{_unitdir}/system-update.target.wants
 ln -s ../cynara.socket %{buildroot}%{_unitdir}/system-update.target.wants
 ln -s ../dbus.socket %{buildroot}%{_unitdir}/system-update.target.wants
@@ -120,7 +128,14 @@ ln -s ../offline-update.service %{buildroot}%{_unitdir}/system-update.target.wan
 ln -s ../udev-trigger-dmbow@.service %{buildroot}%{_unitdir}/system-update.target.wants/udev-trigger-dmbow@user.service
 ln -s ../data-checkpoint.service %{buildroot}%{_unitdir}/local-fs.target.wants/data-checkpoint.service
 ln -s ../update-post.service %{buildroot}%{_unitdir}/system-update.target.wants
-ln -s ../update-finalize.service %{buildroot}%{_unitdir}/delayed.target.wants
+
+ln -s ../default.target %{buildroot}%{_unitdir}/online-update.target.requires
+ln -s ../online-update-pre.target %{buildroot}%{_unitdir}/online-update.target.requires
+ln -s ../online-update-pre.service %{buildroot}%{_unitdir}/online-update-pre.target.requires
+ln -s ../online-update.service %{buildroot}%{_unitdir}/online-update.target.requires
+ln -s ../online-update-verify.service %{buildroot}%{_unitdir}/online-update-success.service.requires
+ln -s ../online-update-success.service %{buildroot}%{_unitdir}/delayed.target.wants
+ln -s ../online-update-failure.service %{buildroot}%{_unitdir}/online-update-failure.target.requires
 
 %posttrans engine
 newrulesfile=99-sdb-switch.rules
@@ -164,7 +179,6 @@ fi
 # rw-upgrade
 %{_unitdir}/data-checkpoint.service
 %{_unitdir}/local-fs.target.wants/data-checkpoint.service
-%{_unitdir}/delayed.target.wants/update-finalize.service
 %{_unitdir}/offline-update.service
 %{_unitdir}/system-update.target.wants/cynara.socket
 %{_unitdir}/system-update.target.wants/dbus.socket
@@ -175,8 +189,22 @@ fi
 %{_unitdir}/system-update.target.wants/update-post.service
 %{_unitdir}/udev-sdb-init.service
 %{_unitdir}/udev-trigger-dmbow@.service
-%{_unitdir}/update-finalize.service
 %{_unitdir}/update-post.service
+%{_unitdir}/online-update-pre.target
+%{_unitdir}/online-update-pre.target.requires/online-update-pre.service
+%{_unitdir}/online-update-pre.service
+%{_unitdir}/online-update.target
+%{_unitdir}/online-update.target.requires/online-update.service
+%{_unitdir}/online-update.target.requires/online-update-pre.target
+%{_unitdir}/online-update.target.requires/default.target
+%{_unitdir}/online-update.service
+%{_unitdir}/online-update-failure.target
+%{_unitdir}/online-update-failure.target.requires/online-update-failure.service
+%{_unitdir}/online-update-failure.service
+%{_unitdir}/online-update-verify.service
+%{_unitdir}/online-update-success.service
+%{_unitdir}/online-update-success.service.requires/online-update-verify.service
+%{_unitdir}/delayed.target.wants/online-update-success.service
 %{upgrade_scripts_dir}/99-sdb-switch.rules
 %{upgrade_scripts_dir}/install-sdb-rule.sh
 %{upgrade_scripts_dir}/record-version.sh
@@ -187,6 +215,13 @@ fi
 %{upgrade_scripts_dir}/update-post.sh
 %{upgrade_scripts_dir}/update.sh
 %{upgrade_scripts_dir}/update-verify.sh
+%{upgrade_scripts_dir}/online-update-pre.sh
+%{upgrade_scripts_dir}/online-update.sh
+%{upgrade_scripts_dir}/online-update-scripts-pre/
+%{upgrade_scripts_dir}/online-update-scripts/
+%{upgrade_scripts_dir}/online-update-verify/
+%{upgrade_scripts_dir}/online-update-verify.sh
+%{upgrade_scripts_dir}/online-update-success.sh
 
 %files -n parse-dynparts
 %manifest upgrade.manifest
index b27a2956ecaaadea6d83b38f49fcebb50891ef5c..f31fc22e060b6de01c2a03d12f8812fe06b2ce7c 100644 (file)
@@ -6,14 +6,28 @@ CONFIGURE_FILE(record-version.sh.in       record-version.sh    @ONLY)
 CONFIGURE_FILE(udev-sdb-init.service.in   udev-sdb-init.service   @ONLY)
 CONFIGURE_FILE(offline-update.service.in  offline-update.service  @ONLY)
 CONFIGURE_FILE(data-checkpoint.service.in data-checkpoint.service @ONLY)
+CONFIGURE_FILE(online-update-pre.sh.in    online-update-pre.sh @ONLY)
+CONFIGURE_FILE(online-update-pre.service.in online-update-pre.service @ONLY)
+CONFIGURE_FILE(online-update.service.in   online-update.service   @ONLY)
+CONFIGURE_FILE(online-update.sh.in        online-update.sh     @ONLY)
+CONFIGURE_FILE(online-update-verify.service.in online-update-verify.service @ONLY)
+CONFIGURE_FILE(online-update-verify.sh.in online-update-verify.sh @ONLY)
+CONFIGURE_FILE(online-update-success.sh.in online-update-success.sh   @ONLY)
 
 INSTALL(FILES
        udev-sdb-init.service
        offline-update.service
        data-checkpoint.service
        update-post.service
-       update-finalize.service
        udev-trigger-dmbow@.service
+       online-update-pre.target
+       online-update-pre.service
+       online-update.target
+       online-update.service
+       online-update-failure.target
+       online-update-failure.service
+       online-update-verify.service
+       online-update-success.service
        DESTINATION ${UNIT_DIR})
 
 INSTALL(FILES
@@ -30,5 +44,9 @@ INSTALL(FILES
        update-post.sh
        update-finalize.sh
        update-verify.sh
+       online-update-pre.sh
+       online-update.sh
+       online-update-verify.sh
+       online-update-success.sh
        DESTINATION ${UPGRADE_SCRIPTS_DIR}
        PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
diff --git a/scripts/rw-upgrade/online-update-failure.service b/scripts/rw-upgrade/online-update-failure.service
new file mode 100644 (file)
index 0000000..0f0fe0b
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=System Update failure - reboot
+DefaultDependencies=no
+Before=online-update-failure.target
+ConditionKernelCommandLine=bootmode=fota
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStartPre=-/bin/device_board_set_upgrade_status -1
+ExecStart=/usr/sbin/reboot -f
+StandardOutput=tty
+StandardError=tty
+RemainAfterExit=yes
+
diff --git a/scripts/rw-upgrade/online-update-failure.target b/scripts/rw-upgrade/online-update-failure.target
new file mode 100644 (file)
index 0000000..98006dd
--- /dev/null
@@ -0,0 +1,4 @@
+[Unit]
+Description=Online Update: failure
+DefaultDependencies=no
+ConditionKernelCommandLine=bootmode=fota
diff --git a/scripts/rw-upgrade/online-update-pre.service.in b/scripts/rw-upgrade/online-update-pre.service.in
new file mode 100644 (file)
index 0000000..d14978f
--- /dev/null
@@ -0,0 +1,17 @@
+[Unit]
+Description=System update script service
+DefaultDependencies=no
+Conflicts=shutdown.target
+Requires=data-checkpoint.service
+After=data-checkpoint.service
+Before=online-update-pre.target
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStartPre=/bin/rm -f @UPGRADE_VAR_DIR@/log/system-rw-update.log
+ExecStart=@UPGRADE_SCRIPTS_DIR@/online-update-pre.sh
+StandardOutput=tty
+StandardError=tty
+RemainAfterExit=yes
+
diff --git a/scripts/rw-upgrade/online-update-pre.sh.in b/scripts/rw-upgrade/online-update-pre.sh.in
new file mode 100644 (file)
index 0000000..04f66f8
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+COLOR_ERROR='\033[01;31m'
+RW_MACRO=@UPGRADE_SCRIPTS_DIR@/rw-update-macro.inc
+SCRIPTS_DIR="@UPGRADE_SCRIPTS_DIR@/online-update-scripts-pre"
+SHELL=/bin/bash
+
+source $RW_MACRO
+
+shopt -s nullglob
+
+ERROR()
+{
+       LOG_TEXT=$1
+       echo -e "${COLOR_ERROR}${LOG_TEXT}${COLOR_RESET}"
+}
+
+# Restore rpm db
+rm -rf /var/lib/rpm/*
+restore_backup_file -f /opt/var/lib/rpm
+
+# Permission Update for shared directories
+/etc/gumd/useradd.d/91_user-dbspace-permissions.post owner
+
+for SCRIPT in $SCRIPTS_DIR/*; do
+       if ! $SHELL "$SCRIPT"; then
+               ERROR "Script $SCRIPT failed - update considered unsuccessful"
+               exit 1
+       fi
+done
+
diff --git a/scripts/rw-upgrade/online-update-pre.target b/scripts/rw-upgrade/online-update-pre.target
new file mode 100644 (file)
index 0000000..992941f
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=System Update - before starting the system
+DefaultDependencies=no
+Before=sysinit.target sockets.target
+After=local-fs.target
+Conflicts=shutdown.target
+OnFailure=online-update-failure.target
+OnFailureJobMode=replace-irreversibly
diff --git a/scripts/rw-upgrade/online-update-success.service b/scripts/rw-upgrade/online-update-success.service
new file mode 100644 (file)
index 0000000..11f19f2
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=Finalize OS update
+DefaultDependencies=no
+After=system-delayed-target-done.service online-update-verify.service
+Conflicts=shutdown.target online-update-failure.target reboot.target
+ConditionKernelCommandLine=bootmode=fota
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStart=/usr/share/upgrade/online-update-success.sh
+RemainAfterExit=true
+StandardOutput=tty
+StandardError=tty
diff --git a/scripts/rw-upgrade/online-update-success.sh.in b/scripts/rw-upgrade/online-update-success.sh.in
new file mode 100644 (file)
index 0000000..24e2938
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+RW_MACRO=@UPGRADE_SCRIPTS_DIR@/rw-update-macro.inc
+HAL_SET_UPGRADE_STATUS=/usr/bin/device_board_set_upgrade_status
+
+SCRIPT_NAME=$(basename $0)
+CRITICAL_LOG()
+{
+       LOG="[$SCRIPT_NAME]$1"
+       dlogsend -k "$LOG"
+       if [ "$2" != "" ]; then
+               echo "$LOG" >> "$2"
+       fi
+       echo "$LOG"
+}
+
+SET_UPGRADE_STATUS()
+{
+       ${HAL_SET_UPGRADE_STATUS} "$1"
+       if [ $? -eq 0 ]; then
+               CRITICAL_LOG "set_upgrade_status success: ${1}"
+       else
+               CRITICAL_LOG "set_upgrade_status failed: ${1}"
+       fi
+}
+
+if [ -f $RW_MACRO ];
+then
+       source $RW_MACRO
+else
+       ERROR "FAIL: Upgrade macro does not exist"
+       UPDATE_PREPARE_ERR=1
+fi
+
+if [ -z ${UPDATE_PREPARE_ERR+x} ]; then
+       /usr/bin/device_board_clear_boot_mode
+       if ! COMMIT_CHANGES; then
+               ERROR "FAIL: Commit changes error"
+               reboot -f fota
+       fi
+
+       /usr/bin/device_board_clear_partition_ab_cloned
+       /usr/bin/device_board_set_boot_success
+       SET_UPGRADE_STATUS 100
+else
+       reboot -f fota
+fi
diff --git a/scripts/rw-upgrade/online-update-verify.service.in b/scripts/rw-upgrade/online-update-verify.service.in
new file mode 100644 (file)
index 0000000..546e5c2
--- /dev/null
@@ -0,0 +1,15 @@
+[Unit]
+Description=System Update: verify
+DefaultDependencies=no
+After=online-update.target system-delayed-target-done.service
+ConditionKernelCommandLine=bootmode=fota
+Conflicts=shutdown.target
+OnFailure=online-update-failure.target
+OnFailureJobMode=replace-irreversibly
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStart=@UPGRADE_SCRIPTS_DIR@/online-update-verify.sh
+RemainAfterExit=true
+
diff --git a/scripts/rw-upgrade/online-update-verify.sh.in b/scripts/rw-upgrade/online-update-verify.sh.in
new file mode 100644 (file)
index 0000000..e9f46f7
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+VERIFY_SCRIPTS_DIR="@UPGRADE_SCRIPTS_DIR@/online-update-verify"
+SHELL=/bin/bash
+
+shopt -s nullglob
+
+ERROR()
+{
+    LOG_TEXT=$1
+    echo -e "${COLOR_ERROR}${LOG_TEXT}${COLOR_RESET}"
+}
+
+for SCRIPT in $VERIFY_SCRIPTS_DIR/*; do
+    if ! $SHELL "$SCRIPT"; then
+        ERROR "Script $SCRIPT failed - update considered unsuccessful"
+        exit 1
+    fi
+done
+
diff --git a/scripts/rw-upgrade/online-update.service.in b/scripts/rw-upgrade/online-update.service.in
new file mode 100644 (file)
index 0000000..5e4c170
--- /dev/null
@@ -0,0 +1,14 @@
+[Unit]
+Description=System update script service
+DefaultDependencies=no
+After=basic.target
+Before=online-update.target
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System::Privileged
+ExecStart=@UPGRADE_SCRIPTS_DIR@/online-update.sh
+StandardOutput=tty
+StandardError=tty
+RemainAfterExit=yes
+
diff --git a/scripts/rw-upgrade/online-update.sh.in b/scripts/rw-upgrade/online-update.sh.in
new file mode 100644 (file)
index 0000000..c2e2753
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+COLOR_ERROR='\033[01;31m'
+COLOR_DEBUG='\033[01;34m'
+COLOR_NOTIFY='\033[01;33m'
+COLOR_RESET='\033[00;00m'
+RW_MACRO=@UPGRADE_SCRIPTS_DIR@/rw-update-macro.inc
+SCRIPTS_DIR="@UPGRADE_SCRIPTS_DIR@/online-update-scripts"
+UPDATE_DATA_DIR=/opt/data/update
+SDB_RULE=${UPDATE_DATA_DIR}/99-sdb-switch.rules
+source $RW_MACRO
+
+shopt -s nullglob
+
+SCRIPT_NAME=$(basename $0)
+
+DEBUG()
+{
+       LOG_TEXT=$1
+       echo -e "${COLOR_DEBUG}${LOG_TEXT}${COLOR_RESET}"
+}
+
+ERROR()
+{
+       LOG_TEXT=$1
+       echo -e "${COLOR_ERROR}${LOG_TEXT}${COLOR_RESET}"
+}
+
+NOTIFY()
+{
+       LOG_TEXT=$1
+       echo -e "${COLOR_NOTIFY}${LOG_TEXT}${COLOR_RESET}"
+}
+
+CRITICAL_LOG()
+{
+       LOG="[$SCRIPT_NAME]$1"
+       dlogsend -k "$LOG"
+       if [ "$2" != "" ]; then
+               echo "$LOG" >> "$2"
+       fi
+       echo "$LOG"
+}
+
+NOTIFY "----------------------------------------------------------------------"
+NOTIFY "Remove deprecated ISU Packages"
+
+REMOVE_UNNECESSARY_ISU_PKGS
+
+get_version_info
+DEBUG "Version OLD: ${OLD_VER}, NEW: ${NEW_VER}"
+
+for SCRIPT in $SCRIPTS_DIR/*; do
+       if ! $SHELL "$SCRIPT"; then
+               ERROR "Script $SCRIPT failed - update considered unsuccessful"
+               exit 1
+       fi
+done
+
+write_version_info
+
+if [ -e ${SDB_RULE} ]; then
+       rm ${SDB_RULE}
+fi
diff --git a/scripts/rw-upgrade/online-update.target b/scripts/rw-upgrade/online-update.target
new file mode 100644 (file)
index 0000000..6641d1b
--- /dev/null
@@ -0,0 +1,8 @@
+[Unit]
+Description=System Update
+DefaultDependencies=no
+Before=multi-user.target
+After=basic.target online-update-pre.target
+Conflicts=shutdown.target
+OnFailure=online-update-failure.target
+OnFailureJobMode=replace-irreversibly
index 9fc58a196840c222838094354bb512199fe2ab6b..4af6812da79d6d44b8f7ae5e1a355f1719e746df 100644 (file)
@@ -274,3 +274,96 @@ 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"
+}
+
+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"
+                       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"
+                               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"
+               fi
+       done
+}
diff --git a/scripts/rw-upgrade/update-finalize.service b/scripts/rw-upgrade/update-finalize.service
deleted file mode 100644 (file)
index 2a059c6..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Finalize OS update
-DefaultDependencies=no
-After=system-delayed-target-done.service
-ConditionKernelCommandLine=bootmode=fota
-
-[Service]
-Type=oneshot
-SmackProcessLabel=System
-ExecStart=/usr/share/upgrade/update-finalize.sh
-RemainAfterExit=true
-
index 401b38c4da3aab16ea2df680ee49adaf07609a51..e642e7a5543b86fdc5bb794371c3bd6bd44307bb 100644 (file)
@@ -73,99 +73,6 @@ 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_ISU_PKG()
-{
-       local PKG_NAME=$1
-       rm -rf "/opt/isu/$PKG_NAME"
-}
-
-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"
-                       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"
-                               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"
-               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
@@ -273,4 +180,4 @@ then
        rm ${STATUS_FILE}
        COMMIT_CHANGES
 fi
-#Reboot by update-finalize.service
+#Reboot by update-post.service