@@ -740,8 +740,7 @@ fn can_perform_soft_reboot(deployment: Option<&crate::spec::BootEntry>) -> bool
740740 deployment. map ( |d| d. soft_reboot_capable ) . unwrap_or ( false )
741741}
742742
743- /// If there is staged deployment, check if soft reboot is possible and perform it if possible and return true
744- /// else return false
743+ /// If there is staged deployment, check if soft reboot is possible and prepare the system for it
745744fn should_soft_reboot (
746745 sysroot : & crate :: store:: Storage ,
747746 booted_deployment : Option < & ostree:: Deployment > ,
@@ -754,12 +753,27 @@ fn should_soft_reboot(
754753 soft_reboot_staged ( sysroot) ?;
755754 return Ok ( true ) ;
756755 }
757- // TODO check if this reboot is doing a rollback...
758- // TODO then perform a soft reboot for the rollback deployment
756+
757+ //Check if we are trying to rollback
758+ //Then prepare for soft reboot for the rollback deployment
759+ let host = crate :: status:: get_status_require_booted ( sysroot) ?. 2 ;
760+ if host. spec . boot_order == crate :: spec:: BootOrder :: Rollback {
761+ if can_perform_soft_reboot ( host. status . rollback . as_ref ( ) ) {
762+ println ! ( "Rollback deployment is soft-reboot capable, preparing for soft-reboot..." ) ;
763+
764+ let deployments_list = sysroot. deployments ( ) ;
765+ let target_deployment = deployments_list
766+ . first ( )
767+ . ok_or_else ( || anyhow:: anyhow!( "No deployments found after rollback" ) ) ?;
768+
769+ prepare_soft_reboot ( sysroot, target_deployment) ?;
770+ return Ok ( true ) ;
771+ }
772+ }
759773 Ok ( false )
760774}
761775
762- /// Prepare and execute a soft reboot for the given deployment
776+ /// Prepare a soft reboot for the given deployment
763777#[ context( "Preparing soft reboot" ) ]
764778fn prepare_soft_reboot (
765779 sysroot : & crate :: store:: Storage ,
0 commit comments