Skip to content

Commit 30fce67

Browse files
committed
wip
1 parent be75055 commit 30fce67

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

crates/lib/src/cli.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,11 @@ pub(crate) enum ImageOpts {
416416
/// this will make the image accessible via e.g. `podman run localhost/bootc` and for builds.
417417
target: Option<String>,
418418
},
419+
/// Re-pull the currently booted image into the bootc-owned container storage.
420+
///
421+
/// This onboards the system to the unified storage path so that future
422+
/// upgrade/switch operations can read from the bootc storage directly.
423+
SetUnified,
419424
/// Copy a container image from the default `containers-storage:` to the bootc-owned container storage.
420425
PullFromDefaultStorage {
421426
/// The image to pull
@@ -1367,6 +1372,9 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
13671372
ImageOpts::CopyToStorage { source, target } => {
13681373
crate::image::push_entrypoint(source.as_deref(), target.as_deref()).await
13691374
}
1375+
ImageOpts::SetUnified => {
1376+
crate::image::set_unified_entrypoint().await
1377+
}
13701378
ImageOpts::PullFromDefaultStorage { image } => {
13711379
let sysroot = get_storage().await?;
13721380
sysroot

crates/lib/src/image.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,51 @@ pub(crate) async fn imgcmd_entrypoint(
181181
cmd.args(args);
182182
cmd.run_capture_stderr()
183183
}
184+
185+
/// Re-pull the currently booted image into the bootc-owned container storage.
186+
///
187+
/// This onboards the system to unified storage for host images so that
188+
/// upgrade/switch can use the unified path automatically when the image is present.
189+
#[context("Setting unified storage for booted image")]
190+
pub(crate) async fn set_unified_entrypoint() -> Result<()> {
191+
let sysroot = crate::cli::get_storage().await?;
192+
let ostree = sysroot.get_ostree()?;
193+
let repo = &ostree.repo();
194+
195+
// Discover the currently booted image reference
196+
let (_booted_deployment, _deployments, host) =
197+
crate::status::get_status_require_booted(ostree)?;
198+
let imgref = host
199+
.spec
200+
.image
201+
.as_ref()
202+
.ok_or_else(|| anyhow::anyhow!("No image source specified in host spec"))?;
203+
204+
// Canonicalize for pull display only, but we want to preserve original pullspec
205+
let imgref_display = imgref.clone().canonicalize()?;
206+
207+
// Pull the image from its original source into bootc storage using LBI machinery
208+
let imgstore = sysroot.get_ensure_imgstore()?;
209+
let img_string = format!("{:#}", imgref);
210+
println!(
211+
"Re-pulling booted image into bootc storage via unified path: {}",
212+
imgref_display
213+
);
214+
imgstore
215+
.pull(&img_string, crate::podstorage::PullMode::Always)
216+
.await?;
217+
218+
// Optionally verify we can import from containers-storage by preparing in a temp importer
219+
// without actually importing into the main repo; this is a lightweight validation.
220+
let containers_storage_imgref = crate::spec::ImageReference {
221+
transport: "containers-storage".to_string(),
222+
image: imgref.image.clone(),
223+
signature: imgref.signature.clone(),
224+
};
225+
let ostree_imgref = ostree_ext::container::OstreeImageReference::from(containers_storage_imgref);
226+
let _ = ostree_ext::container::store::ImageImporter::new(repo, &ostree_imgref, Default::default())
227+
.await?;
228+
229+
println!("Unified storage set for current image. Future upgrade/switch will use it automatically.");
230+
Ok(())
231+
}

crates/lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub(crate) struct InstallTargetOpts {
172172
/// When enabled, this uses bootc's container storage (/usr/lib/bootc/storage) to pull
173173
/// the image first, then imports it from there. This is the same approach used for
174174
/// logically bound images.
175-
#[clap(long)]
175+
#[clap(long = "experimental-unified-storage")]
176176
#[serde(default)]
177177
pub(crate) unified_storage_exp: bool,
178178
}

0 commit comments

Comments
 (0)