deb: make tests parallel
CI / build (push) Failing after 12m10s
CI / snap (push) Has been skipped

This commit is contained in:
2026-03-19 00:24:48 +01:00
parent daaf33cd6b
commit 2b6207981a
7 changed files with 180 additions and 59 deletions
+13 -13
View File
@@ -1,11 +1,12 @@
/// Local binary package building
/// Directly calling 'debian/rules' in current context
use crate::context;
use crate::context::Context;
use crate::deb::find_dsc_file;
use log::warn;
use std::collections::HashMap;
use std::error::Error;
use std::path::Path;
use std::sync::Arc;
use crate::apt;
use crate::deb::cross;
@@ -20,14 +21,13 @@ pub async fn build(
cross: bool,
ppa: Option<&[&str]>,
inject_packages: Option<&[&str]>,
ctx: Arc<Context>,
) -> Result<(), Box<dyn Error>> {
// Environment
let mut env = HashMap::<String, String>::new();
env.insert("LANG".to_string(), "C".to_string());
env.insert("DEBIAN_FRONTEND".to_string(), "noninteractive".to_string());
let ctx = context::current();
// Parallel building: find local number of cores, and use that
let num_cores = ctx
.command("nproc")
@@ -52,11 +52,11 @@ pub async fn build(
if cross {
log::debug!("Setting up environment for local cross build...");
cross::setup_environment(&mut env, arch)?;
cross::ensure_repositories(arch, series)?;
cross::setup_environment(&mut env, arch, ctx.clone())?;
cross::ensure_repositories(arch, series, ctx.clone())?;
}
let mut sources = apt::sources::load(None)?;
let mut sources = apt::sources::load(Some(ctx.clone()))?;
let mut modified = false;
let mut added_ppas: Vec<(&str, &str)> = Vec::new();
@@ -117,11 +117,12 @@ pub async fn build(
}
if modified {
apt::sources::save_legacy(None, sources, "/etc/apt/sources.list")?;
apt::sources::save_legacy(Some(ctx.clone()), sources, "/etc/apt/sources.list")?;
// Download and import PPA keys for all added PPAs
for (user, ppa_name) in added_ppas {
if let Err(e) = crate::apt::keyring::download_trust_ppa_key(None, user, ppa_name).await
if let Err(e) =
crate::apt::keyring::download_trust_ppa_key(Some(ctx.clone()), user, ppa_name).await
{
warn!(
"Failed to download PPA key for {}/{}: {}",
@@ -205,7 +206,7 @@ pub async fn build(
// If build-dep fails, we try to explain the failure using dose-debcheck
if !status.success() {
dose3_explain_dependencies(package, version, arch, build_root, cross)?;
dose3_explain_dependencies(package, version, arch, build_root, cross, ctx.clone())?;
return Err("Could not install build-dependencies for the build".into());
}
@@ -222,7 +223,7 @@ pub async fn build(
// If build-dep fails, we try to explain the failure using dose-debcheck
if !status.success() {
dose3_explain_dependencies(package, version, arch, build_root, cross)?;
dose3_explain_dependencies(package, version, arch, build_root, cross, ctx.clone())?;
return Err("Could not install build-dependencies for the build".into());
}
@@ -261,9 +262,8 @@ fn dose3_explain_dependencies(
arch: &str,
build_root: &str,
cross: bool,
ctx: Arc<Context>,
) -> Result<(), Box<dyn Error>> {
let ctx = context::current();
// Construct the list of Packages files
let mut bg_args = Vec::new();
let mut cmd = ctx.command("apt-get");
@@ -285,7 +285,7 @@ fn dose3_explain_dependencies(
// Transform the dsc file into a 'Source' stanza (replacing 'Source' with 'Package')
// TODO: Remove potential GPG headers/signature
let dsc_path = find_dsc_file(build_root, package, version)?;
let dsc_path = find_dsc_file(build_root, package, version, &ctx)?;
let mut dsc_content = ctx.read_file(&dsc_path)?;
dsc_content = dsc_content.replace("Source", "Package");
ctx.write_file(