44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
/// Sbuild binary package building
|
|
/// Call 'sbuild' with the dsc file to build the package with unshare
|
|
use crate::context;
|
|
use std::error::Error;
|
|
use std::path::Path;
|
|
|
|
pub fn build(
|
|
package: &str,
|
|
version: &str,
|
|
arch: &str,
|
|
series: &str,
|
|
build_root: &str,
|
|
cross: bool,
|
|
) -> Result<(), Box<dyn Error>> {
|
|
let ctx = context::current();
|
|
|
|
// Find the actual package directory
|
|
let package_dir = crate::deb::find_package_directory(Path::new(build_root), package, version)?;
|
|
let package_dir_str = package_dir
|
|
.to_str()
|
|
.ok_or("Invalid package directory path")?;
|
|
|
|
let mut cmd = ctx.command("sbuild");
|
|
cmd.current_dir(package_dir_str);
|
|
cmd.arg("--chroot-mode=unshare");
|
|
cmd.arg("--no-clean-source");
|
|
|
|
if cross {
|
|
cmd.arg(format!("--host={}", arch));
|
|
} else {
|
|
cmd.arg(format!("--arch={}", arch));
|
|
}
|
|
cmd.arg(format!("--dist={}", series));
|
|
|
|
// Add output directory argument
|
|
cmd.arg(format!("--build-dir={}", build_root));
|
|
|
|
let status = cmd.status()?;
|
|
if !status.success() {
|
|
return Err(format!("sbuild failed with status: {}", status).into());
|
|
}
|
|
Ok(())
|
|
}
|