deb: retrieve .deb artifacts
All checks were successful
CI / build (push) Successful in 2m2s

sbuild options: unshare, build directory

context: retrieve files
This commit is contained in:
2025-12-16 20:12:08 +01:00
parent 06ab5eaf98
commit b5ac76a293
4 changed files with 102 additions and 2 deletions

View File

@@ -37,7 +37,24 @@ pub fn build_binary_package(
);
// Run sbuild
run_sbuild(&ctx, &remote_dsc_path, arch, series)?;
run_sbuild(&ctx, &remote_dsc_path, arch, series, &build_root)?;
// Retrieve artifacts
// Always retrieve to the directory containing the .dsc file
let local_output_dir = dsc_path
.parent()
.ok_or("Could not determine parent directory of dsc file")?;
println!("Retrieving artifacts to {}...", local_output_dir.display());
// Only retrieve .deb files
let remote_files = ctx.list_files(Path::new(&build_root))?;
for remote_file in remote_files {
if remote_file.extension().is_some_and(|ext| ext == "deb") {
let file_name = remote_file.file_name().ok_or("Invalid remote filename")?;
let local_dest = local_output_dir.join(file_name);
ctx.retrieve_path(&remote_file, &local_dest)?;
}
}
Ok(())
}
@@ -116,8 +133,11 @@ fn run_sbuild(
dsc_path: &Path,
arch: Option<&str>,
series: Option<&str>,
output_dir: &str,
) -> Result<(), Box<dyn Error>> {
let mut cmd = ctx.command("sbuild");
cmd.arg("--chroot-mode=unshare");
if let Some(a) = arch {
cmd.arg(format!("--arch={}", a));
}
@@ -125,6 +145,9 @@ fn run_sbuild(
cmd.arg(format!("--dist={}", s));
}
// Add output directory argument
cmd.arg(format!("--build-dir={}", output_dir));
let status = cmd.arg(dsc_path).status()?;
if !status.success() {