deb: add -j/--jobs to control parallel build jobs

By default the number of parallel jobs is detected with nproc inside
the build context. Add a -j/--jobs option so an explicit count can be
honored instead, threading it through build_binary_package and
local::build into DEB_BUILD_OPTIONS=parallel=N.
This commit is contained in:
2026-09-10 15:27:50 +02:00
parent 348abf61b9
commit 182a06ffbe
3 changed files with 35 additions and 15 deletions
+20 -15
View File
@@ -37,6 +37,7 @@ pub async fn build(
inject_packages: Option<&[&str]>,
ctx: Arc<Context>,
ui: Option<Arc<DebUi>>,
jobs: Option<usize>,
) -> Result<(), Box<dyn Error>> {
let sink: Option<Arc<dyn LineSink>> = ui.as_ref().map(|u| u.sink());
@@ -45,21 +46,25 @@ pub async fn build(
env.insert("LANG".to_string(), "C".to_string());
env.insert("DEBIAN_FRONTEND".to_string(), "noninteractive".to_string());
// Parallel building: find local number of cores, and use that
let num_cores = ctx
.command("nproc")
.output()
.map(|output| {
if output.status.success() {
String::from_utf8_lossy(&output.stdout)
.trim()
.parse::<usize>()
.unwrap_or(1)
} else {
1 // Default to 1 if nproc fails
}
})
.unwrap_or(1); // Default to 1 if we can't execute the command
// Parallel building: honor an explicit -j/--jobs count, otherwise detect
// the number of cores available inside the build context (nproc).
let num_cores = match jobs {
Some(j) => j,
None => ctx
.command("nproc")
.output()
.map(|output| {
if output.status.success() {
String::from_utf8_lossy(&output.stdout)
.trim()
.parse::<usize>()
.unwrap_or(1)
} else {
1 // Default to 1 if nproc fails
}
})
.unwrap_or(1), // Default to 1 if we can't execute the command
};
// Build options: parallel, disable tests by default
env.insert(