diff --git a/oma-pm/src/progress.rs b/oma-pm/src/progress.rs index 84cdbc8bb..97fc8c035 100644 --- a/oma-pm/src/progress.rs +++ b/oma-pm/src/progress.rs @@ -96,9 +96,10 @@ impl OmaAptInstallProgress { debug!("Dpkg::Options:: is set to --force-all"); } + config.set("Dpkg::Use-Pty", "false"); + if !is_terminal() || no_progress { std::env::set_var("DEBIAN_FRONTEND", "noninteractive"); - config.set("Dpkg::Use-Pty", "false"); } if yes || force_yes || dpkg_force_all { diff --git a/src/subcommand/download.rs b/src/subcommand/download.rs index f8100d069..bedc37604 100644 --- a/src/subcommand/download.rs +++ b/src/subcommand/download.rs @@ -44,7 +44,7 @@ pub fn execute( |count, event, total| { let event = InstallPackageEvent::from(event); if !no_progress { - pb!(event, mb, pb_map, count, total, global_is_set) + pb!(event, mb, pb_map, count, total, global_is_set); } else { handle_event_without_progressbar(event); } diff --git a/src/subcommand/upgrade.rs b/src/subcommand/upgrade.rs index f81fa44a3..730df0e03 100644 --- a/src/subcommand/upgrade.rs +++ b/src/subcommand/upgrade.rs @@ -151,6 +151,9 @@ pub fn execute( op, ) { Ok(()) => { + if let Some(gpb) = pb_map.get(&0) { + gpb.finish_and_clear(); + } write_history_entry( op_after, typ, @@ -171,6 +174,9 @@ pub fn execute( OmaAptError::AptErrors(_) | OmaAptError::AptError(_) | OmaAptError::AptCxxException(_) => { + if let Some(gpb) = pb_map.get(&0) { + gpb.finish_and_clear(); + } if retry_times == 3 { write_history_entry( op_after, @@ -196,6 +202,9 @@ pub fn execute( retry_times += 1; } _ => { + if let Some(gpb) = pb_map.get(&0) { + gpb.finish_and_clear(); + } drop(fds); return Err(OutputError::from(e)); } diff --git a/src/subcommand/utils.rs b/src/subcommand/utils.rs index 321c00e8a..d0fd3c429 100644 --- a/src/subcommand/utils.rs +++ b/src/subcommand/utils.rs @@ -266,7 +266,7 @@ pub(crate) fn normal_commit(args: NormalCommitArgs, client: &Client) -> Result<( &apt_args, |count, event, total| { if !no_progress { - pb!(event, mb, pb_map, count, total, global_is_set) + pb!(event, mb, pb_map, count, total, global_is_set); } else { handle_event_without_progressbar(event); } @@ -274,6 +274,10 @@ pub(crate) fn normal_commit(args: NormalCommitArgs, client: &Client) -> Result<( op, ); + if let Some(gpb) = pb_map.get(&0) { + gpb.finish_and_clear(); + } + match res { Ok(_) => { success!("{}", fl!("history-tips-1")); diff --git a/src/utils.rs b/src/utils.rs index 8ce621e78..098258ca6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -100,14 +100,30 @@ macro_rules! pb { if let Some(gpb) = $pb_map.get(&0) { gpb.finish_and_clear(); } + $pb_map.remove(&0); } } } oma_pm::apt::InstallPackageEvent::DpkgEvent(event) => { - dbg!(event); + let gpb = $pb_map.get(&0); + if gpb.is_none() { + $global_is_set.store(true, std::sync::atomic::Ordering::SeqCst); + let sty = + oma_console::pb::oma_style_pb(oma_console::writer::Writer::default(), true); + let gpb = $mb.insert( + 0, + oma_console::indicatif::ProgressBar::new(100).with_style(sty), + ); + gpb.set_prefix("Progress"); + gpb.set_position(event.percent); + $pb_map.insert(0, gpb); + return; + } + let gpb = gpb.unwrap(); + gpb.set_position(event.percent); } oma_pm::apt::InstallPackageEvent::DpkgLine(line) => { - dbg!(line); + $mb.println(line).ok(); } }