Skip to content

Commit a78b8ae

Browse files
committed
Update mtime of /ostree/bootc when status is modified
This updates the mtime after a successful invocation of upgrade/switch/edit/rollback Signed-off-by: John Eckersberg <[email protected]>
1 parent 7f3c68b commit a78b8ae

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

lib/src/cli.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
752752
}
753753
}
754754
if changed {
755+
sysroot.update_mtime()?;
756+
755757
if opts.apply {
756758
crate::reboot::reboot()?;
757759
}
@@ -832,6 +834,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
832834
let stateroot = booted_deployment.osname();
833835
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;
834836

837+
sysroot.update_mtime()?;
838+
835839
if opts.apply {
836840
crate::reboot::reboot()?;
837841
}
@@ -887,6 +891,8 @@ async fn edit(opts: EditOpts) -> Result<()> {
887891
let stateroot = booted_deployment.osname();
888892
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;
889893

894+
sysroot.update_mtime()?;
895+
890896
Ok(())
891897
}
892898

lib/src/deploy.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,9 @@ pub(crate) async fn rollback(sysroot: &Storage) -> Result<()> {
747747
} else {
748748
println!("Next boot: rollback deployment");
749749
}
750+
751+
sysroot.update_mtime()?;
752+
750753
Ok(())
751754
}
752755

lib/src/store/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ use std::cell::OnceCell;
22
use std::env;
33
use std::ops::Deref;
44

5-
use anyhow::Result;
5+
use anyhow::{Context, Result};
66
use cap_std_ext::cap_std::fs::Dir;
7+
use cap_std_ext::dirext::CapStdExtDirExt;
78
use clap::ValueEnum;
9+
use fn_error_context::context;
810

911
use ostree_ext::container::OstreeImageReference;
1012
use ostree_ext::keyfileext::KeyFileExt;
@@ -86,6 +88,18 @@ impl Storage {
8688
let imgstore = crate::imgstorage::Storage::create(&sysroot_dir, &self.run)?;
8789
Ok(self.imgstore.get_or_init(|| imgstore))
8890
}
91+
92+
/// Update the mtime on the storage root directory
93+
#[context("Updating storage root mtime")]
94+
pub(crate) fn update_mtime(&self) -> Result<()> {
95+
let sysroot_dir = Dir::reopen_dir(&crate::utils::sysroot_fd(&self.sysroot))
96+
.context("Reopen sysroot directory")?;
97+
98+
sysroot_dir
99+
.update_timestamps(std::path::Path::new(BOOTC_ROOT))
100+
.context("update_timestamps")
101+
.map_err(Into::into)
102+
}
89103
}
90104

91105
impl ContainerImageStore for ostree::Deployment {

0 commit comments

Comments
 (0)