MCPcopy Create free account
hub / github.com/bootc-dev/bootc / new_ostree

Method new_ostree

crates/lib/src/store/mod.rs:469–508  ·  view source on GitHub ↗

Create a new storage accessor from an existing ostree sysroot. This is used for non-booted scenarios (e.g., `bootc install`) where we're operating on a target filesystem rather than the running system.

(sysroot: SysrootLock, run: &Dir)

Source from the content-addressed store, hash-verified

467 /// This is used for non-booted scenarios (e.g., `bootc install`) where
468 /// we're operating on a target filesystem rather than the running system.
469 pub fn new_ostree(sysroot: SysrootLock, run: &Dir) -> Result<Self> {
470 let run = run.try_clone()?;
471
472 // ostree has historically always relied on
473 // having ostree -> sysroot/ostree as a symlink in the image to
474 // make it so that code doesn't need to distinguish between booted
475 // vs offline target. The ostree code all just looks at the ostree/
476 // directory, and will follow the link in the booted case.
477 //
478 // For composefs we aren't going to do a similar thing, so here
479 // we need to explicitly distinguish the two and the storage
480 // here hence holds a reference to the physical root.
481 let ostree_sysroot_dir = crate::utils::sysroot_dir(&sysroot)?;
482 let (physical_root, physical_root_path) = if sysroot.is_booted() {
483 (
484 ostree_sysroot_dir.open_dir(SYSROOT)?,
485 Utf8PathBuf::from("/sysroot"),
486 )
487 } else {
488 // For non-booted case (install), get the path from the sysroot
489 let path = sysroot.path();
490 let path_str = path.parse_name().to_string();
491 let path = Utf8PathBuf::from(path_str);
492 (ostree_sysroot_dir, path)
493 };
494
495 let ostree_cell = OnceCell::new();
496 let _ = ostree_cell.set(sysroot);
497
498 Ok(Self {
499 physical_root,
500 physical_root_path,
501 run,
502 boot_dir: None,
503 esp: None,
504 ostree: ostree_cell,
505 composefs: Default::default(),
506 imgstore: Default::default(),
507 })
508 }
509
510 /// Returns `boot_dir` if it exists
511 pub(crate) fn require_boot_dir(&self) -> Result<&Dir> {

Callers

nothing calls this directly

Calls 2

sysroot_dirFunction · 0.85
pathMethod · 0.45

Tested by

no test coverage detected