Skip to content

Commit

Permalink
cli: add build-lint
Browse files Browse the repository at this point in the history
add simple lint to check that we only have one kernel in
image.

fixes: containers#216
Co-authored-by: Joseph Marrero <[email protected]>
Co-authored-by: Huijing Hei <[email protected]>
  • Loading branch information
3 people committed Mar 7, 2024
1 parent 4cfce9c commit a4ebc2e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use ostree_container::store::PrepareResult;
use ostree_ext::container as ostree_container;
use ostree_ext::keyfileext::KeyFileExt;
use ostree_ext::ostree;
use tracing::field::debug;
use std::ffi::OsString;
use std::io::Seek;
use std::os::unix::process::CommandExt;
Expand Down Expand Up @@ -213,7 +214,7 @@ pub(crate) enum Opt {
#[cfg(feature = "install")]
Install(InstallOpts),
/// Validate non supported files are not present.
BuildCommit,
BuildLint,
/// Execute the given command in the host mount namespace
#[cfg(feature = "install")]
#[clap(hide = true)]
Expand Down Expand Up @@ -515,12 +516,24 @@ async fn usroverlay() -> Result<()> {
}

/// Implementation of `bootc build commit`
async fn commit() -> Result<()> {
// This is just a pass-through today. At some point we may diverge from ostree-ext.
return Err(Command::new("ostree")
.args(["container", "commit"])
.exec()
.into());
/// async fn lint() -> Result<()> {
fn lint() -> Result<()> {
// TODO: Check if 1 or more folder under the /lib/modules/ directory
println!("Checking if we are in the container");
if ostree_ext::container_utils::is_ostree_container()? {
let modules_path = cap_std::fs::Dir::open_ambient_dir("lib/modules", cap_std::ambient_authority())?;
for entry in modules_path.entries()? {
let dir = entry?;
let fileName= dir.file_name();
debug(fileName);

}
return Ok(());
}
anyhow::bail!(
"Not in a ostree container, this command only verifies ostree containers."
);

}

/// Parse the provided arguments and execute.
Expand All @@ -540,7 +553,7 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
Opt::Switch(opts) => switch(opts).await,
Opt::Edit(opts) => edit(opts).await,
Opt::UsrOverlay => usroverlay().await,
Opt::BuildCommit => commit().await,
Opt::BuildLint => lint(),
#[cfg(feature = "install")]
Opt::Install(opts) => match opts {
InstallOpts::ToDisk(opts) => crate::install::install_to_disk(opts).await,
Expand Down

0 comments on commit a4ebc2e

Please sign in to comment.