deb: first implementation
This commit is contained in:
29
src/deb.rs
Normal file
29
src/deb.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use std::error::Error;
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn build_binary_package(cwd: Option<&Path>) -> Result<(), Box<dyn Error>> {
|
||||
let cwd = cwd.unwrap_or_else(|| Path::new("."));
|
||||
|
||||
// Parse changelog to get package name and version
|
||||
let changelog_path = cwd.join("debian/changelog");
|
||||
let (package, version, _series) = crate::changelog::parse_changelog_header(&changelog_path)?;
|
||||
|
||||
// Construct dsc file name
|
||||
let parent = cwd.parent().ok_or("Cannot find parent directory")?;
|
||||
let dsc_name = format!("{}_{}.dsc", package, version);
|
||||
let dsc_path = parent.join(&dsc_name);
|
||||
if !dsc_path.exists() {
|
||||
return Err(format!("Could not find .dsc file at {}", dsc_path.display()).into());
|
||||
}
|
||||
|
||||
println!("Building {} using sbuild...", dsc_path.display());
|
||||
|
||||
let status = Command::new("sbuild").arg(dsc_path).status()?;
|
||||
|
||||
if !status.success() {
|
||||
return Err(format!("sbuild failed with status: {}", status).into());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user