From ffa26f89481aa2d6259137b27cbe34f8e8330154 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 08:06:28 +0000 Subject: Allow explicit APT configuration for builds --- src/cli.rs | 13 +++++++++---- tests/cli.rs | 27 ++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index ffa9bba..2e204fa 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -30,6 +30,9 @@ pub enum Command { spec: PathBuf, #[arg(long)] workspace: PathBuf, + /// Project-owned APT configuration. Defaults to apt.conf beside the specification. + #[arg(long)] + apt_config: Option, #[arg(long)] output: PathBuf, }, @@ -63,13 +66,15 @@ pub fn run(cli: Cli) -> Result<()> { Command::Build { spec, workspace, + apt_config, output, } => { let plan = BuildPlan::compile(ImageSpec::load(&spec)?)?; - let apt_config = spec - .parent() - .unwrap_or_else(|| std::path::Path::new(".")) - .join("apt.conf"); + let apt_config = apt_config.unwrap_or_else(|| { + spec.parent() + .unwrap_or_else(|| std::path::Path::new(".")) + .join("apt.conf") + }); let installer = HasherInstaller::new(HasherProcessRunner); let initramfs = MakeInitrdBuilder::new(InitramfsProcessRunner); let mut executor = BuildExecutor::new(installer, initramfs); diff --git a/tests/cli.rs b/tests/cli.rs index dfaf140..fdc38b6 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -37,13 +37,38 @@ fn parses_build_with_explicit_workspace_and_output_paths() { Command::Build { spec, workspace, - output + apt_config, + output, } if spec == PathBuf::from("image.toml") && workspace == PathBuf::from("work") + && apt_config.is_none() && output == PathBuf::from("out/image.tar") )); } +#[test] +fn parses_build_with_an_explicit_apt_configuration() { + let cli = Cli::try_parse_from([ + "alt-controller-image", + "build", + "--spec", + "image.toml", + "--workspace", + "work", + "--apt-config", + "repositories/alt.conf", + "--output", + "out/image.tar", + ]) + .expect("build command with explicit APT configuration parses"); + + assert!(matches!( + cli.command, + Command::Build { apt_config, .. } + if apt_config == Some(PathBuf::from("repositories/alt.conf")) + )); +} + #[test] fn parses_inspect_with_an_explicit_artifact_path() { let cli = Cli::try_parse_from([ -- cgit v1.2.3