@@ -28,15 +28,16 @@ use ostree_ext::sysroot::SysrootLock;
28
28
use schemars:: schema_for;
29
29
use serde:: { Deserialize , Serialize } ;
30
30
31
- use crate :: bootc_composefs:: rollback:: composefs_rollback;
32
- use crate :: bootc_composefs:: switch:: switch_composefs;
33
- use crate :: bootc_composefs:: update:: upgrade_composefs;
31
+ #[ cfg( feature = "composefs-backend" ) ]
32
+ use crate :: bootc_composefs:: {
33
+ rollback:: composefs_rollback, status:: composefs_booted, switch:: switch_composefs,
34
+ update:: upgrade_composefs,
35
+ } ;
34
36
use crate :: deploy:: RequiredHostSpec ;
35
37
use crate :: lints;
36
38
use crate :: progress_jsonl:: { ProgressWriter , RawProgressFd } ;
37
39
use crate :: spec:: Host ;
38
40
use crate :: spec:: ImageReference ;
39
- use crate :: status:: composefs_booted;
40
41
use crate :: utils:: sigpolicy_from_opt;
41
42
42
43
/// Shared progress options
@@ -1128,29 +1129,21 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
1128
1129
1129
1130
/// Implementation of the `bootc rollback` CLI command.
1130
1131
#[ context( "Rollback" ) ]
1131
- async fn rollback ( opts : RollbackOpts ) -> Result < ( ) > {
1132
- if composefs_booted ( ) ?. is_some ( ) {
1133
- composefs_rollback ( ) . await ?
1134
- } else {
1135
- let sysroot = & get_storage ( ) . await ?;
1136
- let ostree = sysroot. get_ostree ( ) ?;
1137
- crate :: deploy:: rollback ( sysroot) . await ?;
1138
-
1139
- if opts. soft_reboot . is_some ( ) {
1140
- // Get status of rollback deployment to check soft-reboot capability
1141
- let host = crate :: status:: get_status_require_booted ( ostree) ?. 2 ;
1142
-
1143
- handle_soft_reboot (
1144
- opts. soft_reboot ,
1145
- host. status . rollback . as_ref ( ) ,
1146
- "rollback" ,
1147
- || soft_reboot_rollback ( ostree) ,
1148
- ) ?;
1149
- }
1150
- } ;
1132
+ async fn rollback ( opts : & RollbackOpts ) -> Result < ( ) > {
1133
+ let sysroot = & get_storage ( ) . await ?;
1134
+ let ostree = sysroot. get_ostree ( ) ?;
1135
+ crate :: deploy:: rollback ( sysroot) . await ?;
1151
1136
1152
- if opts. apply {
1153
- crate :: reboot:: reboot ( ) ?;
1137
+ if opts. soft_reboot . is_some ( ) {
1138
+ // Get status of rollback deployment to check soft-reboot capability
1139
+ let host = crate :: status:: get_status_require_booted ( ostree) ?. 2 ;
1140
+
1141
+ handle_soft_reboot (
1142
+ opts. soft_reboot ,
1143
+ host. status . rollback . as_ref ( ) ,
1144
+ "rollback" ,
1145
+ || soft_reboot_rollback ( ostree) ,
1146
+ ) ?;
1154
1147
}
1155
1148
1156
1149
Ok ( ( ) )
@@ -1298,20 +1291,44 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
1298
1291
let root = & Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
1299
1292
match opt {
1300
1293
Opt :: Upgrade ( opts) => {
1294
+ #[ cfg( feature = "composefs-backend" ) ]
1301
1295
if composefs_booted ( ) ?. is_some ( ) {
1302
1296
upgrade_composefs ( opts) . await
1303
1297
} else {
1304
1298
upgrade ( opts) . await
1305
1299
}
1300
+
1301
+ #[ cfg( not( feature = "composefs-backend" ) ) ]
1302
+ upgrade ( opts) . await
1306
1303
}
1307
1304
Opt :: Switch ( opts) => {
1305
+ #[ cfg( feature = "composefs-backend" ) ]
1308
1306
if composefs_booted ( ) ?. is_some ( ) {
1309
1307
switch_composefs ( opts) . await
1310
1308
} else {
1311
1309
switch ( opts) . await
1312
1310
}
1311
+
1312
+ #[ cfg( not( feature = "composefs-backend" ) ) ]
1313
+ switch ( opts) . await
1314
+ }
1315
+ Opt :: Rollback ( opts) => {
1316
+ #[ cfg( feature = "composefs-backend" ) ]
1317
+ if composefs_booted ( ) ?. is_some ( ) {
1318
+ composefs_rollback ( ) . await ?
1319
+ } else {
1320
+ rollback ( & opts) . await ?
1321
+ }
1322
+
1323
+ #[ cfg( not( feature = "composefs-backend" ) ) ]
1324
+ rollback ( & opts) . await ?;
1325
+
1326
+ if opts. apply {
1327
+ crate :: reboot:: reboot ( ) ?;
1328
+ }
1329
+
1330
+ Ok ( ( ) )
1313
1331
}
1314
- Opt :: Rollback ( opts) => rollback ( opts) . await ,
1315
1332
Opt :: Edit ( opts) => edit ( opts) . await ,
1316
1333
Opt :: UsrOverlay => usroverlay ( ) . await ,
1317
1334
Opt :: Container ( opts) => match opts {
0 commit comments