@@ -24,6 +24,7 @@ use ostree_ext::container as ostree_container;
2424use ostree_ext:: container_utils:: ostree_booted;
2525use ostree_ext:: keyfileext:: KeyFileExt ;
2626use ostree_ext:: ostree;
27+ use ostree_ext:: sysroot:: SysrootLock ;
2728use schemars:: schema_for;
2829use serde:: { Deserialize , Serialize } ;
2930
@@ -778,13 +779,9 @@ fn has_soft_reboot_capability(deployment: Option<&crate::spec::BootEntry>) -> bo
778779
779780/// Prepare a soft reboot for the given deployment
780781#[ context( "Preparing soft reboot" ) ]
781- fn prepare_soft_reboot (
782- sysroot : & crate :: store:: Storage ,
783- deployment : & ostree:: Deployment ,
784- ) -> Result < ( ) > {
782+ fn prepare_soft_reboot ( sysroot : & SysrootLock , deployment : & ostree:: Deployment ) -> Result < ( ) > {
785783 let cancellable = ostree:: gio:: Cancellable :: NONE ;
786784 sysroot
787- . sysroot
788785 . deployment_set_soft_reboot ( deployment, false , cancellable)
789786 . context ( "Failed to prepare soft-reboot" ) ?;
790787 Ok ( ( ) )
@@ -829,7 +826,7 @@ where
829826/// Handle soft reboot for staged deployments (used by upgrade and switch)
830827#[ context( "Handling staged soft reboot" ) ]
831828fn handle_staged_soft_reboot (
832- sysroot : & crate :: store :: Storage ,
829+ sysroot : & SysrootLock ,
833830 soft_reboot_mode : Option < SoftRebootMode > ,
834831 host : & crate :: spec:: Host ,
835832) -> Result < ( ) > {
@@ -843,7 +840,7 @@ fn handle_staged_soft_reboot(
843840
844841/// Perform a soft reboot for a staged deployment
845842#[ context( "Soft reboot staged deployment" ) ]
846- fn soft_reboot_staged ( sysroot : & crate :: store :: Storage ) -> Result < ( ) > {
843+ fn soft_reboot_staged ( sysroot : & SysrootLock ) -> Result < ( ) > {
847844 println ! ( "Staged deployment is soft-reboot capable, preparing for soft-reboot..." ) ;
848845
849846 let deployments_list = sysroot. deployments ( ) ;
@@ -858,7 +855,7 @@ fn soft_reboot_staged(sysroot: &crate::store::Storage) -> Result<()> {
858855
859856/// Perform a soft reboot for a rollback deployment
860857#[ context( "Soft reboot rollback deployment" ) ]
861- fn soft_reboot_rollback ( sysroot : & crate :: store :: Storage ) -> Result < ( ) > {
858+ fn soft_reboot_rollback ( sysroot : & SysrootLock ) -> Result < ( ) > {
862859 println ! ( "Rollback deployment is soft-reboot capable, preparing for soft-reboot..." ) ;
863860
864861 let deployments_list = sysroot. deployments ( ) ;
@@ -910,9 +907,9 @@ fn prepare_for_write() -> Result<()> {
910907#[ context( "Upgrading" ) ]
911908async fn upgrade ( opts : UpgradeOpts ) -> Result < ( ) > {
912909 let sysroot = & get_storage ( ) . await ?;
913- let repo = & sysroot. repo ( ) ;
914- let ( booted_deployment , _deployments , host ) =
915- crate :: status:: get_status_require_booted ( sysroot ) ?;
910+ let ostree = sysroot. get_ostree ( ) ? ;
911+ let repo = & ostree . repo ( ) ;
912+ let ( booted_deployment , _deployments , host ) = crate :: status:: get_status_require_booted ( ostree ) ?;
916913 let imgref = host. spec . image . as_ref ( ) ;
917914 let prog: ProgressWriter = opts. progress . try_into ( ) ?;
918915
@@ -988,7 +985,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
988985 . unwrap_or_default ( ) ;
989986 if staged_unchanged {
990987 println ! ( "Staged update present, not changed." ) ;
991- handle_staged_soft_reboot ( sysroot , opts. soft_reboot , & host) ?;
988+ handle_staged_soft_reboot ( ostree , opts. soft_reboot , & host) ?;
992989 if opts. apply {
993990 crate :: reboot:: reboot ( ) ?;
994991 }
@@ -1013,8 +1010,8 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
10131010 if opts. soft_reboot . is_some ( ) {
10141011 // At this point we have new staged deployment and the host definition has changed.
10151012 // We need the updated host status before we check if we can prepare the soft-reboot.
1016- let updated_host = crate :: status:: get_status ( sysroot , Some ( & booted_deployment) ) ?. 1 ;
1017- handle_staged_soft_reboot ( sysroot , opts. soft_reboot , & updated_host) ?;
1013+ let updated_host = crate :: status:: get_status ( ostree , Some ( & booted_deployment) ) ?. 1 ;
1014+ handle_staged_soft_reboot ( ostree , opts. soft_reboot , & updated_host) ?;
10181015 }
10191016
10201017 if opts. apply {
@@ -1058,9 +1055,9 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
10581055 let cancellable = gio:: Cancellable :: NONE ;
10591056
10601057 let sysroot = & get_storage ( ) . await ?;
1061- let repo = & sysroot. repo ( ) ;
1062- let ( booted_deployment , _deployments , host ) =
1063- crate :: status:: get_status_require_booted ( sysroot ) ?;
1058+ let ostree = sysroot. get_ostree ( ) ? ;
1059+ let repo = & ostree . repo ( ) ;
1060+ let ( booted_deployment , _deployments , host ) = crate :: status:: get_status_require_booted ( ostree ) ?;
10641061
10651062 let new_spec = {
10661063 let mut new_spec = host. spec . clone ( ) ;
@@ -1095,8 +1092,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
10951092 if opts. soft_reboot . is_some ( ) {
10961093 // At this point we have staged the deployment and the host definition has changed.
10971094 // We need the updated host status before we check if we can prepare the soft-reboot.
1098- let updated_host = crate :: status:: get_status ( sysroot , Some ( & booted_deployment) ) ?. 1 ;
1099- handle_staged_soft_reboot ( sysroot , opts. soft_reboot , & updated_host) ?;
1095+ let updated_host = crate :: status:: get_status ( ostree , Some ( & booted_deployment) ) ?. 1 ;
1096+ handle_staged_soft_reboot ( ostree , opts. soft_reboot , & updated_host) ?;
11001097 }
11011098
11021099 if opts. apply {
@@ -1110,17 +1107,18 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
11101107#[ context( "Rollback" ) ]
11111108async fn rollback ( opts : RollbackOpts ) -> Result < ( ) > {
11121109 let sysroot = & get_storage ( ) . await ?;
1110+ let ostree = sysroot. get_ostree ( ) ?;
11131111 crate :: deploy:: rollback ( sysroot) . await ?;
11141112
11151113 if opts. soft_reboot . is_some ( ) {
11161114 // Get status of rollback deployment to check soft-reboot capability
1117- let host = crate :: status:: get_status_require_booted ( sysroot ) ?. 2 ;
1115+ let host = crate :: status:: get_status_require_booted ( ostree ) ?. 2 ;
11181116
11191117 handle_soft_reboot (
11201118 opts. soft_reboot ,
11211119 host. status . rollback . as_ref ( ) ,
11221120 "rollback" ,
1123- || soft_reboot_rollback ( sysroot ) ,
1121+ || soft_reboot_rollback ( ostree ) ,
11241122 ) ?;
11251123 }
11261124
@@ -1135,10 +1133,10 @@ async fn rollback(opts: RollbackOpts) -> Result<()> {
11351133#[ context( "Editing spec" ) ]
11361134async fn edit ( opts : EditOpts ) -> Result < ( ) > {
11371135 let sysroot = & get_storage ( ) . await ?;
1138- let repo = & sysroot. repo ( ) ;
1136+ let ostree = sysroot. get_ostree ( ) ?;
1137+ let repo = & ostree. repo ( ) ;
11391138
1140- let ( booted_deployment, _deployments, host) =
1141- crate :: status:: get_status_require_booted ( sysroot) ?;
1139+ let ( booted_deployment, _deployments, host) = crate :: status:: get_status_require_booted ( ostree) ?;
11421140 let new_host: Host = if let Some ( filename) = opts. filename {
11431141 let mut r = std:: io:: BufReader :: new ( std:: fs:: File :: open ( filename) ?) ;
11441142 serde_yaml:: from_reader ( & mut r) ?
0 commit comments