From 659a8a2ba742c2da6877076aa4fe5c187cf78a52 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Thu, 11 Dec 2025 19:27:06 +0100 Subject: [PATCH] deb: add series, arch arguments --- src/deb.rs | 14 ++++++++++++-- src/main.rs | 14 +++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/deb.rs b/src/deb.rs index 1ac38da..69bc4d9 100644 --- a/src/deb.rs +++ b/src/deb.rs @@ -2,7 +2,7 @@ use std::error::Error; use std::path::Path; use std::process::Command; -pub fn build_binary_package(cwd: Option<&Path>) -> Result<(), Box> { +pub fn build_binary_package(arch: Option<&str>, series: Option<&str>, cwd: Option<&Path>) -> Result<(), Box> { let cwd = cwd.unwrap_or_else(|| Path::new(".")); // Parse changelog to get package name and version @@ -19,7 +19,17 @@ pub fn build_binary_package(cwd: Option<&Path>) -> Result<(), Box> { println!("Building {} using sbuild...", dsc_path.display()); - let status = Command::new("sbuild").arg(dsc_path).status()?; + let mut status = Command::new("sbuild"); + if let Some(arch) = arch { + status.arg(format!("--arch={}", arch)); + } + if let Some(series) = series { + status.arg(format!("--dist={}", series)); + } + + let status = status + .arg(dsc_path) + .status()?; if !status.success() { return Err(format!("sbuild failed with status: {}", status).into()); diff --git a/src/main.rs b/src/main.rs index 84b1bb0..82e7e79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,12 @@ fn main() { .arg(arg!(-v --version "Target version").required(false)), ) .subcommand(Command::new("build").about("Build the source package")) - .subcommand(Command::new("deb").about("Build the binary package")) + .subcommand( + Command::new("deb") + .about("Build the binary package") + .arg(arg!(-s --series "Target distribution series").required(false)) + .arg(arg!(-a --arch "Target architecture").required(false)) + ) .get_matches(); match matches.subcommand() { @@ -109,9 +114,12 @@ fn main() { std::process::exit(1); } } - Some(("deb", _sub_matches)) => { + Some(("deb", sub_matches)) => { let cwd = std::env::current_dir().unwrap(); - if let Err(e) = pkh::deb::build_binary_package(Some(&cwd)) { + let series = sub_matches.get_one::("series").map(|s| s.as_str()); + let arch = sub_matches.get_one::("arch").map(|s| s.as_str()); + + if let Err(e) = pkh::deb::build_binary_package(arch, series, Some(cwd.as_path())) { error!("{}", e); std::process::exit(1); }