Skip to content

Commit

Permalink
Add usr-overlay
Browse files Browse the repository at this point in the history
This also just forwards to `ostree admin unlock` the same as
`rpm-ostree usroverlay` does.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Mar 15, 2023
1 parent 53cd1e6 commit 57adb33
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use ostree_ext::keyfileext::KeyFileExt;
use ostree_ext::ostree;
use ostree_ext::sysroot::SysrootLock;
use std::ffi::OsString;
use std::os::unix::process::CommandExt;
use std::process::Command;

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

/// Implementation of `bootc usroverlay`
async fn usroverlay() -> Result<()> {
// This is just a pass-through today. At some point we may make this a libostree API
// or even oxidize it.
return Err(Command::new("ostree")
.args(["admin", "unlock"])
.exec()
.into());
}

/// Parse the provided arguments and execute.
/// Calls [`structopt::clap::Error::exit`] on failure, printing the error message and aborting the program.
pub async fn run_from_iter<I>(args: I) -> Result<()>
Expand All @@ -357,6 +372,7 @@ where
match opt {
Opt::Upgrade(opts) => upgrade(opts).await,
Opt::Switch(opts) => switch(opts).await,
Opt::UsrOverlay => usroverlay().await,
#[cfg(feature = "install")]
Opt::Install(opts) => crate::install::install(opts).await,
#[cfg(feature = "install")]
Expand Down
8 changes: 5 additions & 3 deletions tests/kolainst/basic
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ case "${AUTOPKGTEST_REBOOT_MARK:-}" in
bootc status --json > status.json
image=$(jq -r '.[0].image.image' < status.json)
echo "booted into $image"

# TODO more tests here

echo "ok status test"

test '!' -w /usr
bootc usroverlay
test -w /usr
echo "ok usroverlay"
;;
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
esac

0 comments on commit 57adb33

Please sign in to comment.