@@ -6,22 +6,20 @@ use anyhow::{Context, Result};
6
6
use camino:: Utf8PathBuf ;
7
7
use clap:: Parser ;
8
8
use fn_error_context:: context;
9
- use ostree:: { gio, glib } ;
9
+ use ostree:: gio;
10
10
use ostree_container:: store:: LayeredImageState ;
11
11
use ostree_container:: store:: PrepareResult ;
12
12
use ostree_container:: OstreeImageReference ;
13
13
use ostree_ext:: container as ostree_container;
14
14
use ostree_ext:: container:: SignatureSource ;
15
15
use ostree_ext:: keyfileext:: KeyFileExt ;
16
16
use ostree_ext:: ostree;
17
- use ostree_ext:: sysroot:: SysrootLock ;
18
17
use std:: ffi:: OsString ;
19
18
use std:: io:: Seek ;
20
19
use std:: os:: unix:: process:: CommandExt ;
21
20
use std:: process:: Command ;
22
21
23
22
use crate :: spec:: Host ;
24
- use crate :: spec:: HostSpec ;
25
23
use crate :: spec:: ImageReference ;
26
24
27
25
/// Perform an upgrade operation
@@ -229,45 +227,6 @@ async fn pull(
229
227
Ok ( import)
230
228
}
231
229
232
- /// Stage (queue deployment of) a fetched container image.
233
- #[ context( "Staging" ) ]
234
- async fn stage (
235
- sysroot : & SysrootLock ,
236
- stateroot : & str ,
237
- image : Box < LayeredImageState > ,
238
- spec : & HostSpec ,
239
- ) -> Result < ( ) > {
240
- let cancellable = gio:: Cancellable :: NONE ;
241
- let stateroot = Some ( stateroot) ;
242
- let merge_deployment = sysroot. merge_deployment ( stateroot) ;
243
- let origin = glib:: KeyFile :: new ( ) ;
244
- let ostree_imgref = spec
245
- . image
246
- . as_ref ( )
247
- . map ( |imgref| OstreeImageReference :: from ( imgref. clone ( ) ) ) ;
248
- if let Some ( imgref) = ostree_imgref. as_ref ( ) {
249
- origin. set_string (
250
- "origin" ,
251
- ostree_container:: deploy:: ORIGIN_CONTAINER ,
252
- imgref. to_string ( ) . as_str ( ) ,
253
- ) ;
254
- }
255
- let _new_deployment = sysroot. stage_tree_with_options (
256
- stateroot,
257
- image. merge_commit . as_str ( ) ,
258
- Some ( & origin) ,
259
- merge_deployment. as_ref ( ) ,
260
- & Default :: default ( ) ,
261
- cancellable,
262
- ) ?;
263
- if let Some ( imgref) = ostree_imgref. as_ref ( ) {
264
- println ! ( "Queued for next boot: {imgref}" ) ;
265
- }
266
- ostree_container:: deploy:: remove_undeployed_images ( sysroot) . context ( "Pruning images" ) ?;
267
-
268
- Ok ( ( ) )
269
- }
270
-
271
230
#[ context( "Querying root privilege" ) ]
272
231
pub ( crate ) fn require_root ( ) -> Result < ( ) > {
273
232
let uid = rustix:: process:: getuid ( ) ;
@@ -282,7 +241,7 @@ pub(crate) fn require_root() -> Result<()> {
282
241
283
242
/// A few process changes that need to be made for writing.
284
243
#[ context( "Preparing for write" ) ]
285
- async fn prepare_for_write ( ) -> Result < ( ) > {
244
+ pub ( crate ) async fn prepare_for_write ( ) -> Result < ( ) > {
286
245
if ostree_ext:: container_utils:: is_ostree_container ( ) ? {
287
246
anyhow:: bail!(
288
247
"Detected container (ostree base); this command requires a booted host system."
@@ -351,7 +310,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
351
310
}
352
311
353
312
let osname = booted_deployment. osname ( ) ;
354
- stage ( sysroot, & osname, fetched, & host. spec ) . await ?;
313
+ crate :: deploy :: stage ( sysroot, & osname, fetched, & host. spec ) . await ?;
355
314
}
356
315
if let Some ( path) = opts. touch_if_changed {
357
316
std:: fs:: write ( & path, "" ) . with_context ( || format ! ( "Writing {path}" ) ) ?;
@@ -410,7 +369,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
410
369
}
411
370
412
371
let stateroot = booted_deployment. osname ( ) ;
413
- stage ( sysroot, & stateroot, fetched, & new_spec) . await ?;
372
+ crate :: deploy :: stage ( sysroot, & stateroot, fetched, & new_spec) . await ?;
414
373
415
374
Ok ( ( ) )
416
375
}
@@ -448,7 +407,7 @@ async fn edit(opts: EditOpts) -> Result<()> {
448
407
// TODO gc old layers here
449
408
450
409
let stateroot = booted_deployment. osname ( ) ;
451
- stage ( sysroot, & stateroot, fetched, & new_host. spec ) . await ?;
410
+ crate :: deploy :: stage ( sysroot, & stateroot, fetched, & new_host. spec ) . await ?;
452
411
453
412
Ok ( ( ) )
454
413
}
0 commit comments