Skip to content

Commit 93079bb

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 608d681 commit 93079bb

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
@@ -766,6 +766,8 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
766766
}
767767
}
768768
if changed {
769+
sysroot.update_mtime()?;
770+
769771
if opts.apply {
770772
crate::reboot::reboot()?;
771773
}
@@ -842,6 +844,8 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
842844
let stateroot = booted_deployment.osname();
843845
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;
844846

847+
sysroot.update_mtime()?;
848+
845849
if opts.apply {
846850
crate::reboot::reboot()?;
847851
}
@@ -897,6 +901,8 @@ async fn edit(opts: EditOpts) -> Result<()> {
897901
let stateroot = booted_deployment.osname();
898902
crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec, prog.clone()).await?;
899903

904+
sysroot.update_mtime()?;
905+
900906
Ok(())
901907
}
902908

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 =
96+
crate::utils::sysroot_dir(&self.sysroot).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)