exp: cross #3

This commit is contained in:
2025-12-21 21:37:56 +01:00
parent 31bcd28c72
commit 0d4ae565dd
5 changed files with 197 additions and 59 deletions

View File

@@ -1,24 +1,10 @@
/// Sbuild binary package building
/// Call 'sbuild' with the dsc file to build the package with unshare
use crate::context;
use crate::deb::find_dsc_file;
use std::error::Error;
use std::path::{Path, PathBuf};
fn find_dsc_file(cwd: &Path, package: &str, version: &str) -> Result<PathBuf, Box<dyn Error>> {
let parent = cwd.parent().ok_or("Cannot find parent directory")?;
// Strip epoch from version (e.g., "1:2.3.4-5" -> "2.3.4-5")
let version_without_epoch = version.split_once(':').map(|(_, v)| v).unwrap_or(version);
let dsc_name = format!("{}_{}.dsc", package, version_without_epoch);
let dsc_path = parent.join(&dsc_name);
if !dsc_path.exists() {
return Err(format!("Could not find .dsc file at {}", dsc_path.display()).into());
}
Ok(dsc_path)
}
pub fn build(
cwd: &Path,
package: &str,
version: &str,
arch: &str,
@@ -26,7 +12,7 @@ pub fn build(
build_root: &str,
cross: bool,
) -> Result<(), Box<dyn Error>> {
let dsc_path = find_dsc_file(cwd, package, version)?;
let dsc_path = find_dsc_file(build_root, package, version)?;
let ctx = context::current();
let mut cmd = ctx.command("sbuild");