Skip to content

feat: parse the full apt install-progress status-fd stream - #21

Merged
eatradish merged 1 commit into
masterfrom
dpkg-progress-parser
Sep 4, 2026
Merged

eatradish merged 1 commit into
masterfrom
dpkg-progress-parser

Conversation

@eatradish

@eatradish eatradish commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Description

Parse apt's install-progress status-fd stream correctly. The old parser split every line on : and assumed exactly four fields, so messages whose text contained a colon were truncated, unrecognised line types (media-change, raw dpkg lines) fell into a mislabelled fallback, and the progress percent could move backwards when dpkg re-ran.

  • src/oma.rs: rewrite the parser around apt's install-progress format — classify every line kind (pmstatus / pmerror / pmconffile / dlstatus / dpkg_raw) with a splitn(4, ':') so the message tail may itself contain :
  • Keep the progress percent monotonic (never decreases) and clamped to [0,100]; relay errors and conffile prompts without advancing the bar
  • Keep download progress on a separate download stage so it cannot push the dpkg bar to 100 prematurely
  • Relay unrecognised lines (e.g. media-change) verbatim; document the format against the apt source (v3.3.3)

The focus is one thing: an accurate, never-backwards progress bar with every install line type surfaced correctly to the UI.

About AI

This PR was written in collaboration with Deepseek V4 Flash in a VS Code agent session. I have reviewed and amended the code, tested it thoroughly, and updated the comments.

  • Model: Deepseek v4 flash
  • Platform: VSCode code agent session

Assisted-by: Deepseek noreply@deepseek.com

@eatradish
eatradish force-pushed the dpkg-progress-parser branch 3 times, most recently from d7d11ab to 338ede5 Compare August 25, 2026 05:19
@eatradish

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 338ede5215

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The fd wired to InstallProgressOpt::Fd is apt's PackageManagerProgressFd
(oma-apt do_install_fd), so the stream is apt's install-progress format
(TYPE:ARG1:ARG2:MSG), not raw dpkg output. Replace the ad-hoc parser
with one that understands every line type:

- pmstatus: real progress; apt's percent is already the overall,
  monotonic percentage, so take it verbatim with a clamp. "dpkg-exec"
  is apt's pseudo-package marking each dpkg re-run and must not count
  as a package.
- pmerror / pmconffile: relayed with the bar held so failures and
  conffile prompts surface without moving progress.
- dlstatus: download progress; relayed without moving the dpkg bar so
  a download phase cannot push it to 100 prematurely.
- media-change and anything unknown: relayed raw with the bar held
  (media-change is emitted with a literal "media-change: " prefix).

Percent never decreases (overall = overall.max(...)), fixing the
mid-run rollback caused by dpkg re-runs re-emitting 0.0 progress.

The comment block now cites the exact reference implementations with
file:line for every line type (apt-pkg/install-progress.cc,
apt-pkg/acquire.cc, apt-pkg/acquire-worker.cc, apt-pkg/deb/dpkgpm.cc,
dpkg src/main/*.c and lib/dpkg/*.c, oma-apt apt-pkg-c/pkgmanager.h).

`DpkgProgress` borrows its fields (`&str`) instead of allocating
strings, since each event is serialised before the source line drops.

@MingcongBai MingcongBai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested good against plasma-aosc-update.

@eatradish
eatradish merged commit 9f009b9 into master Sep 4, 2026
@eatradish
eatradish deleted the dpkg-progress-parser branch September 4, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants