deb: drive build_binary_package through the BuildView port

The binary build joins the source build on the reporting ports:
build_binary_package takes a DebBuildOptions struct (replacing eleven
positional arguments), reports target, phases, progress and the
outcome through the environment-agnostic BuildView, and the Phase enum
with its default classifiers moves from the terminal widget into the
deb module (announced through the enter_phase helper). DebUi loses its
inherent event methods and only implements the port; tee logging and
the SIGINT behavior are unchanged.

No behavior change for the CLI; headless consumers pass report::Quiet.
This commit is contained in:
2026-09-18 20:22:45 +02:00
parent 27b1083b15
commit 052c02cdc3
8 changed files with 390 additions and 428 deletions
+24 -36
View File
@@ -573,28 +573,21 @@ fn main() {
}
Some(("deb", sub_matches)) => {
let cwd = current_dir_or_exit();
let series = sub_matches.get_one::<String>("series").map(|s| s.as_str());
let pocket = sub_matches.get_one::<String>("pocket").map(|s| s.as_str());
let arch = sub_matches.get_one::<String>("arch").map(|s| s.as_str());
let cross = sub_matches.get_one::<bool>("cross").unwrap_or(&false);
let ppa: Vec<&str> = sub_matches
let series = sub_matches.get_one::<String>("series").cloned();
let pocket = sub_matches.get_one::<String>("pocket").cloned();
let arch = sub_matches.get_one::<String>("arch").cloned();
let cross = sub_matches
.get_one::<bool>("cross")
.copied()
.unwrap_or(false);
let ppa: Vec<String> = sub_matches
.get_many::<String>("ppa")
.map(|v| v.map(|s| s.as_str()).collect())
.map(|v| v.cloned().collect())
.unwrap_or_default();
let ppa = if ppa.is_empty() {
None
} else {
Some(ppa.as_slice())
};
let inject_packages: Vec<&str> = sub_matches
let inject: Vec<String> = sub_matches
.get_many::<String>("inject")
.map(|v| v.map(|s| s.as_str()).collect())
.map(|v| v.cloned().collect())
.unwrap_or_default();
let inject_packages = if inject_packages.is_empty() {
None
} else {
Some(inject_packages.as_slice())
};
let mode: Option<&str> = sub_matches.get_one::<String>("mode").map(|s| s.as_str());
let mode: Option<pkh::deb::BuildMode> = match mode {
Some("local") => Some(pkh::deb::BuildMode::Local),
@@ -613,36 +606,31 @@ fn main() {
})
});
// Live build view: disabled by --verbose or when stdout is not a
// terminal (DebUi handles the non-TTY case itself)
let ui = if verbose {
None
} else {
Some(std::sync::Arc::new(pkh::ui::deb::DebUi::new(&multi)))
};
// Live build view, unless --verbose (DebUi additionally disables
// itself when stdout is not a terminal)
let quiet = pkh::report::Quiet;
let live = pkh::ui::deb::DebUi::new(&multi);
let view: &dyn pkh::report::BuildView = if verbose { &quiet } else { &live };
let result = rt.block_on(async {
pkh::deb::build_binary_package(
pkh::deb::build_binary_package(pkh::deb::DebBuildOptions {
arch,
series,
pocket,
Some(cwd.as_path()),
*cross,
cwd: Some(cwd.clone()),
cross,
mode,
ppa,
inject_packages,
None,
ui.clone(),
inject,
jobs,
)
view,
..Default::default()
})
.await
});
match result {
Ok(artifacts) => {
let _ = artifacts;
info!("Done.");
}
Ok(_) => info!("Done."),
Err(e) => {
error!("{}", e);
std::process::exit(1);