@@ -740,8 +740,7 @@ fn can_perform_soft_reboot(deployment: Option<&crate::spec::BootEntry>) -> bool
740
740
deployment. map ( |d| d. soft_reboot_capable ) . unwrap_or ( false )
741
741
}
742
742
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
745
744
fn should_soft_reboot (
746
745
sysroot : & crate :: store:: Storage ,
747
746
booted_deployment : Option < & ostree:: Deployment > ,
@@ -754,12 +753,27 @@ fn should_soft_reboot(
754
753
soft_reboot_staged ( sysroot) ?;
755
754
return Ok ( true ) ;
756
755
}
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
+ }
759
773
Ok ( false )
760
774
}
761
775
762
- /// Prepare and execute a soft reboot for the given deployment
776
+ /// Prepare a soft reboot for the given deployment
763
777
#[ context( "Preparing soft reboot" ) ]
764
778
fn prepare_soft_reboot (
765
779
sysroot : & crate :: store:: Storage ,
0 commit comments