Skip to content

Commit 6531d53

Browse files
authored
Merge pull request #77 from cgwalters/add-usroverlay
Add `usr-overlay`
2 parents 53cd1e6 + 57adb33 commit 6531d53

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/src/cli.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use ostree_ext::keyfileext::KeyFileExt;
1717
use ostree_ext::ostree;
1818
use ostree_ext::sysroot::SysrootLock;
1919
use std::ffi::OsString;
20+
use std::os::unix::process::CommandExt;
21+
use std::process::Command;
2022

2123
/// Perform an upgrade operation
2224
#[derive(Debug, Parser)]
@@ -104,6 +106,9 @@ pub(crate) enum Opt {
104106
Switch(SwitchOpts),
105107
/// Display status
106108
Status(StatusOpts),
109+
/// Add a transient writable overlayfs on `/usr` that will be discarded on reboot.
110+
#[clap(alias = "usroverlay")]
111+
UsrOverlay,
107112
/// Install to the target block device
108113
#[cfg(feature = "install")]
109114
Install(crate::install::InstallOpts),
@@ -346,6 +351,16 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
346351
Ok(())
347352
}
348353

354+
/// Implementation of `bootc usroverlay`
355+
async fn usroverlay() -> Result<()> {
356+
// This is just a pass-through today. At some point we may make this a libostree API
357+
// or even oxidize it.
358+
return Err(Command::new("ostree")
359+
.args(["admin", "unlock"])
360+
.exec()
361+
.into());
362+
}
363+
349364
/// Parse the provided arguments and execute.
350365
/// Calls [`structopt::clap::Error::exit`] on failure, printing the error message and aborting the program.
351366
pub async fn run_from_iter<I>(args: I) -> Result<()>
@@ -357,6 +372,7 @@ where
357372
match opt {
358373
Opt::Upgrade(opts) => upgrade(opts).await,
359374
Opt::Switch(opts) => switch(opts).await,
375+
Opt::UsrOverlay => usroverlay().await,
360376
#[cfg(feature = "install")]
361377
Opt::Install(opts) => crate::install::install(opts).await,
362378
#[cfg(feature = "install")]

tests/kolainst/basic

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
1717
bootc status --json > status.json
1818
image=$(jq -r '.[0].image.image' < status.json)
1919
echo "booted into $image"
20-
21-
# TODO more tests here
22-
2320
echo "ok status test"
21+
22+
test '!' -w /usr
23+
bootc usroverlay
24+
test -w /usr
25+
echo "ok usroverlay"
2426
;;
2527
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
2628
esac

0 commit comments

Comments
 (0)