From: SangYoun Kwak Date: Mon, 22 Jul 2024 06:48:15 +0000 (+0900) Subject: clone_partition: Modify background clone conditions X-Git-Tag: accepted/tizen/unified/20240731.160154~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ca493565df532751dd53f807dc1b081f2767cdc;p=platform%2Fcore%2Fsystem%2Fupgrade.git clone_partition: Modify background clone conditions Previously, to determine whether clone or not, checking bootmode was sufficient. Since the online upgrade feature is supported and it boots with bootmode fota. Thus, to determine if it is safe to clone or not, conditions below are going to be checked: * upgrade state is "completed" * (bootmode is normal) or (bootmode is fota and upgrade type is online) Also, due to it checks the upgrade state, clone_partition.service has to wait the update-manager.service to be started since it changes the upgrade state. Change-Id: I103a39dbe12d4cfab2f4844206b9341c3323f793 Signed-off-by: SangYoun Kwak --- diff --git a/scripts/clone_partitions/clone_partitions.service b/scripts/clone_partitions/clone_partitions.service index e296d5b..f1a8745 100644 --- a/scripts/clone_partitions/clone_partitions.service +++ b/scripts/clone_partitions/clone_partitions.service @@ -1,6 +1,6 @@ [Unit] Description=Clone partitions -After=system-delayed-target-done.service +After=system-delayed-target-done.service update-manager.service [Service] Type=simple diff --git a/scripts/clone_partitions/clone_partitions.sh b/scripts/clone_partitions/clone_partitions.sh index 3540f4e..33d6678 100644 --- a/scripts/clone_partitions/clone_partitions.sh +++ b/scripts/clone_partitions/clone_partitions.sh @@ -47,25 +47,56 @@ clone_recovery() { } check_clone_background_available() { - local bootmode=$(device_board_get_boot_mode) - local ret_boot_mode=$? + # Partitions should not be cloned if upgrade is in progress. + local upgrade_state + local upgrade_type + local bootmode + local ret + + upgrade_state=$(device_board_get_upgrade_state) + ret=$? + if [[ $? -ne 0 ]]; then + critical_log "[Error] Cannot get upgrade state: ${ret}" + exit 1 + fi + + upgrade_type=$(device_board_get_upgrade_type) + ret=$? + if [[ $? -ne 0 ]]; then + critical_log "[Error] Cannot get upgrade type: ${ret}" + exit 1 + fi - if [ ${ret_boot_mode} -ne 0 ]; then - critical_log "[Error] Cannot get boot mode: ${ret_boot_mode}" + bootmode=$(device_board_get_boot_mode) + ret=$? + if [[ $? -ne 0 ]]; then + critical_log "[Error] Cannot get boot mode: ${ret}" exit 1 fi - if [ "${bootmode}" != "normal" ]; then - log "[Info] bootmode is not \"normal\": ${bootmode}" + if [[ "${upgrade_state}" != "completed" ]]; then + log "[Info] Upgrade state is not \"completed\": ${upgrade_state}" exit 0 fi + + if [[ "${bootmode}" != "normal" ]]; then + if [[ "${bootmode}" != "fota" ]]; then + log "[Info] bootmode should be \"normal\" or \"fota\": ${bootmode}" + exit 0 + fi + + if [[ "${upgrade_type}" != "online" ]]; then + log "[Info] Upgrade type should be online if bootmode is fota: ${upgrade_type}" + exit 0 + fi + fi } clone_background() { # wait for 60 seconds to wait for bootup sleep 60 - check_clone_available + check_clone_background_available start_clone }