Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/cli/bootupctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ pub enum CtlBackend {
Generate(super::bootupd::GenerateOpts),
#[clap(name = "install", hide = true)]
Install(super::bootupd::InstallOpts),
#[clap(name = "generate-manifest", hide = true)]
GenerateManifest(super::bootupd::GenerateManifestOpts),
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -109,6 +111,9 @@ impl CtlCommand {
CtlVerb::Backend(CtlBackend::Install(opts)) => {
super::bootupd::DCommand::run_install(opts)
}
CtlVerb::Backend(CtlBackend::GenerateManifest(opts)) => {
super::bootupd::DCommand::run_generate_manifest(opts)
}
CtlVerb::MigrateStaticGrubConfig => Self::run_migrate_static_grub_config(),
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/cli/bootupd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::bootupd::{self, ConfigMode};
use crate::manifest::{self, generate_manifest};
use anyhow::{Context, Result};
use camino::Utf8Path;
use cap_std::ambient_authority;
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
use clap::Parser;
use log::LevelFilter;
use std::path::{Path, PathBuf};

/// `bootupd` sub-commands.
#[derive(Debug, Parser)]
Expand Down Expand Up @@ -39,6 +41,11 @@ pub enum DVerb {
GenerateUpdateMetadata(GenerateOpts),
#[clap(name = "install", about = "Install components")]
Install(InstallOpts),
#[clap(
name = "generate-manifest",
about = "Generate manifest for grub and shim packages (supported distros: Ubuntu/Debian, Arch Linux, Fedora/CentOS, OpenSuse and Alpine Linux"
)]
GenerateManifest(GenerateManifestOpts),
}

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -92,12 +99,24 @@ pub struct GenerateOpts {
sysroot: Option<String>,
}

#[derive(Debug, Parser)]
pub struct GenerateManifestOpts {
/// Physical root mountpoint
#[clap(value_parser)]
sysroot: Option<String>,

/// Grub or shim filepaths
#[clap(value_parser)]
files: Vec<PathBuf>,
}

impl DCommand {
/// Run CLI application.
pub fn run(self) -> Result<()> {
match self.cmd {
DVerb::Install(opts) => Self::run_install(opts),
DVerb::GenerateUpdateMetadata(opts) => Self::run_generate_meta(opts),
DVerb::GenerateManifest(opts) => Self::run_generate_manifest(opts),
}
}

Expand All @@ -111,6 +130,17 @@ impl DCommand {
Ok(())
}

/// Runner for 'generate-manifest' verb
pub(crate) fn run_generate_manifest(opts: GenerateManifestOpts) -> Result<()> {
let sysroot = opts.sysroot.as_deref().unwrap_or("/");
let path_refs: Vec<&Path> = opts.files.iter().map(|p| p.as_path()).collect();
if sysroot != "/" {
anyhow::bail!("Using a non-default sysroot is not supported: {}", sysroot);
}
manifest::generate_manifest(sysroot, &path_refs)?;
Ok(())
}

/// Runner for `install` verb.
pub(crate) fn run_install(opts: InstallOpts) -> Result<()> {
let configmode = if opts.write_uuid {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ mod freezethaw;
target_arch = "riscv64"
))]
mod grubconfigs;
mod manifest;
mod model;
mod model_legacy;
mod ostreeutil;
Expand Down
Loading