This commit is contained in:
14
src/deb.rs
14
src/deb.rs
@@ -2,7 +2,7 @@ use std::error::Error;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn build_binary_package(cwd: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
pub fn build_binary_package(arch: Option<&str>, series: Option<&str>, cwd: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
||||||
let cwd = cwd.unwrap_or_else(|| Path::new("."));
|
let cwd = cwd.unwrap_or_else(|| Path::new("."));
|
||||||
|
|
||||||
// Parse changelog to get package name and version
|
// Parse changelog to get package name and version
|
||||||
@@ -19,7 +19,17 @@ pub fn build_binary_package(cwd: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
println!("Building {} using sbuild...", dsc_path.display());
|
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() {
|
if !status.success() {
|
||||||
return Err(format!("sbuild failed with status: {}", status).into());
|
return Err(format!("sbuild failed with status: {}", status).into());
|
||||||
|
|||||||
14
src/main.rs
14
src/main.rs
@@ -49,7 +49,12 @@ fn main() {
|
|||||||
.arg(arg!(-v --version <version> "Target version").required(false)),
|
.arg(arg!(-v --version <version> "Target version").required(false)),
|
||||||
)
|
)
|
||||||
.subcommand(Command::new("build").about("Build the source package"))
|
.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 <series> "Target distribution series").required(false))
|
||||||
|
.arg(arg!(-a --arch <arch> "Target architecture").required(false))
|
||||||
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
|
|
||||||
match matches.subcommand() {
|
match matches.subcommand() {
|
||||||
@@ -109,9 +114,12 @@ fn main() {
|
|||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(("deb", _sub_matches)) => {
|
Some(("deb", sub_matches)) => {
|
||||||
let cwd = std::env::current_dir().unwrap();
|
let cwd = std::env::current_dir().unwrap();
|
||||||
if let Err(e) = pkh::deb::build_binary_package(Some(&cwd)) {
|
let series = sub_matches.get_one::<String>("series").map(|s| s.as_str());
|
||||||
|
let arch = sub_matches.get_one::<String>("arch").map(|s| s.as_str());
|
||||||
|
|
||||||
|
if let Err(e) = pkh::deb::build_binary_package(arch, series, Some(cwd.as_path())) {
|
||||||
error!("{}", e);
|
error!("{}", e);
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user