Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rpm-ostree experimental #5213

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ci/test-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ if ! grep -qe "error.*This system was not booted via libostree" err.txt; then
fatal "did not find expected error"
fi

# This does nothing, just verifies the experimental CLI works.
rpm-ostree experimental stub >out.txt
grep 'Did nothing successfully' out.txt && rm out.txt

rpm-ostree install testdaemon
grep -qF 'u testdaemon-user' /usr/lib/sysusers.d/35-rpmostree-pkg-user-testdaemon-user.conf
grep -qF 'g testdaemon-group' /usr/lib/sysusers.d/30-rpmostree-pkg-group-testdaemon-group.conf
Expand Down
51 changes: 51 additions & 0 deletions rust/src/cli_experimental.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

use anyhow::Result;
use clap::Parser;

#[derive(Debug, Parser)]
#[clap(rename_all = "kebab-case")]
/// Main options struct
struct Experimental {
#[clap(subcommand)]
cmd: Cmd,
}

#[derive(Debug, clap::Subcommand)]
#[clap(rename_all = "kebab-case")]
/// Subcommands
enum Cmd {
/// This command does nothing, it's a placeholder for future expansion.
#[clap(hide = true)]
Stub,
}

impl Cmd {
fn run(self) -> Result<()> {
match self {
Cmd::Stub => println!("Did nothing successfully."),
}
Ok(())
}
}

/// Primary entrypoint to running our wrapped `yum`/`dnf` handling.
pub fn main(argv: &[&str]) -> Result<i32> {
let opt = Experimental::parse_from(argv.into_iter().skip(1));
opt.cmd.run()?;
Ok(0)
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_parse() -> Result<()> {
let opt = Experimental::try_parse_from(["experimental", "stub"]).unwrap();
match opt.cmd {
Cmd::Stub => {}
}
Ok(())
}
}
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ pub(crate) use composepost::*;
mod core;
use crate::core::*;
mod capstdext;
pub mod cli_experimental;
mod daemon;
pub(crate) use daemon::*;
mod deployment_utils;
Expand Down
3 changes: 3 additions & 0 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ async fn inner_async_main(args: Vec<String>) -> Result<i32> {
rpmostree_rust::container::container_encapsulate(args_orig).map(|_| 0)
.map_err(anyhow::Error::msg)
},
"experimental" => {
rpmostree_rust::cli_experimental::main(args)
}
// C++ main
_ => Ok(rpmostree_rust::ffi::rpmostree_main(args)?),
}
Expand Down
Loading