Skip to content

Commit

Permalink
Update mtime of /ostree/bootc when status is modified
Browse files Browse the repository at this point in the history
This updates the mtime after a successful invocation of
upgrade/switch/edit/rollback

Signed-off-by: John Eckersberg <[email protected]>
  • Loading branch information
jeckersb committed Dec 18, 2024
1 parent 47cbe4e commit 7726492
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
}
}
if changed {
sysroot.update_mtime()?;

if opts.apply {
crate::reboot::reboot()?;
}
Expand Down Expand Up @@ -830,6 +832,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
let stateroot = booted_deployment.osname();
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;

sysroot.update_mtime()?;

if opts.apply {
crate::reboot::reboot()?;
}
Expand Down Expand Up @@ -885,6 +889,8 @@ async fn edit(opts: EditOpts) -> Result<()> {
let stateroot = booted_deployment.osname();
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;

sysroot.update_mtime()?;

Ok(())
}

Expand Down
3 changes: 3 additions & 0 deletions lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,9 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
} else {
println!("Next boot: rollback deployment");
}

sysroot.update_mtime()?;

Ok(())
}

Expand Down
16 changes: 15 additions & 1 deletion lib/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ use std::cell::OnceCell;
use std::env;
use std::ops::Deref;

use anyhow::Result;
use anyhow::{Context, Result};
use cap_std_ext::cap_std::fs::Dir;
use cap_std_ext::dirext::CapStdExtDirExt;
use clap::ValueEnum;
use fn_error_context::context;

use ostree_ext::container::OstreeImageReference;
use ostree_ext::keyfileext::KeyFileExt;
Expand Down Expand Up @@ -86,6 +88,18 @@ impl Storage {
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run)?;
Ok(self.imgstore.get_or_init(|| imgstore))
}

/// Update the mtime on the storage root directory
#[context("Updating storage root mtime")]
pub(crate) fn update_mtime(&self) -> Result<()> {
let sysroot_dir =
crate::utils::sysroot_dir(&self.sysroot).context("Reopen sysroot directory")?;

sysroot_dir
.update_timestamps(std::path::Path::new(BOOTC_ROOT))
.context("update_timestamps")
.map_err(Into::into)
}
}

impl ContainerImageStore for ostree::Deployment {
Expand Down

0 comments on commit 7726492

Please sign in to comment.