-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
man: removing dependency on asciidoctor
There is some controversy around relying on a third-party application for building the projects man-pages. This introduces a heavy refactor which removes that dependency and instead relies solely on `clap` and `clap_mangen` to dynamically generate man-pages for the project. Overview: - Delete the old `build.rs` script and moves it into the `src` directory to help clean up the depenency tree inside of the build script. - Delete the legacy adoc-formatted file. - Build a pseudo-library with `cli.rs` as the main portion of the project - Refactor main.rs to simply be a driver of the pseudo-library Signed-off-by: Larry Dewey <[email protected]>
- Loading branch information
1 parent
a7ba002
commit 589bd1a
Showing
12 changed files
with
305 additions
and
432 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Documentation | ||
All of the documentation generated will end up in this directory. This is a | ||
placeholder to make sure the directory stays in the tree. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use anyhow::{Context, Result}; | ||
use clap::{arg, command, CommandFactory, Parser, Subcommand, ValueEnum}; | ||
|
||
mod cert; | ||
use cert::{export, fetch, import, verify}; | ||
use sev::firmware::host::*; | ||
mod cli; | ||
mod config; | ||
mod ok; | ||
mod processor; | ||
mod show; | ||
|
||
use cli::SnpHost; | ||
use std::path::PathBuf; | ||
|
||
fn generate_man_pages() -> std::io::Result<()> { | ||
clap_mangen::generate_to( | ||
SnpHost::command(), | ||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("docs/"), | ||
) | ||
} | ||
|
||
fn main() -> std::io::Result<()> { | ||
// Uses clap_mangen to generate all relevant man pages. | ||
generate_man_pages() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#![allow(dead_code)] | ||
|
||
use clap::{arg, Parser, Subcommand}; | ||
|
||
use super::*; | ||
|
||
pub(crate) fn firmware() -> Result<Firmware> { | ||
Firmware::open().context("unable to open /dev/sev") | ||
} | ||
|
||
pub(crate) fn snp_platform_status() -> anyhow::Result<SnpPlatformStatus> { | ||
firmware()? | ||
.snp_platform_status() | ||
.map_err(|e| anyhow::anyhow!(format!("{:?}", e))) | ||
.context("unable to retrieve SNP platform status") | ||
} | ||
|
||
pub(crate) fn sev_platform_status() -> anyhow::Result<Status> { | ||
firmware()? | ||
.platform_status() | ||
.map_err(|e| anyhow::anyhow!(format!("{:?}", e))) | ||
.context("unable to retrieve SEV platform status") | ||
} | ||
|
||
// Commit command | ||
mod commit { | ||
use crate::cli::firmware; | ||
pub fn cmd() -> anyhow::Result<()> { | ||
firmware()?.snp_commit()?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[derive(Parser)] | ||
#[command(author, version, about, long_about = None)] | ||
pub struct SnpHost { | ||
#[command(subcommand)] | ||
pub cmd: SnpHostCmd, | ||
|
||
/// Don't print anything to the console | ||
#[arg(short, long, default_value_t = false)] | ||
pub quiet: bool, | ||
} | ||
|
||
#[allow(clippy::large_enum_variant)] | ||
/// Utilities for managing the SEV-SNP environment | ||
#[derive(Subcommand)] | ||
pub enum SnpHostCmd { | ||
/// Display information about the SEV-SNP platform | ||
#[command(subcommand)] | ||
Show(show::Show), | ||
|
||
/// Export a certificate chain from a kernel format file to a given directory | ||
Export(export::Export), | ||
|
||
/// Import a certificate chain to a file | ||
Import(import::Import), | ||
|
||
/// Probe system for SEV-SNP support | ||
Ok, | ||
|
||
/// Modify the SNP configuration | ||
#[command(subcommand)] | ||
Config(config::ConfigCmd), | ||
|
||
/// Verify a certificate chain | ||
Verify(verify::Verify), | ||
|
||
/// Retrieve content from the AMD Key Distribution Server (KDS) | ||
#[command(subcommand)] | ||
Fetch(fetch::Fetch), | ||
|
||
/// Commit current firmware and TCB versions to PSP | ||
Commit, | ||
} | ||
|
||
impl SnpHostCmd { | ||
pub fn handle(self, quiet: bool) -> Result<()> { | ||
match self { | ||
Self::Show(show) => show::cmd(show), | ||
Self::Export(export) => export::cmd(export), | ||
Self::Import(import) => import::cmd(import), | ||
Self::Ok => ok::cmd(quiet), | ||
Self::Config(subcmd) => config::cmd(subcmd), | ||
Self::Verify(verify) => verify::cmd(verify, quiet), | ||
Self::Fetch(fetch) => fetch::cmd(fetch), | ||
Self::Commit => commit::cmd(), | ||
} | ||
} | ||
} |
Oops, something went wrong.