← Back to issue list

fix(deb): avoid re-downloading cached stage-packages

View original Github issue

Metadata

Project
craft-parts
Number
#1553
Type
pull request
State
open
Author
gcomneno
Labels
Created
Updated
Closed

Current evaluation

Patches apt-cache to treat cached .debs matching expected metadata as cache hits, avoiding repeated stage-packages re-downloads (workaround for python-apt _file_is_same bug). Awaiting review; CI mostly green with a few unrelated failures.

Suggested action: needs review

Reason: Issue #1495 is still open and the maintainer confirmed the analysis, explicitly naming this PR (#1553) as the pending local mitigation, and I verified the fix is not yet in craft_parts/packages/apt_cache.py (fetch_archives still calls fetch_binary with no _file_is_same patch). Last author activity was 88 days ago (rebase + lint fix), so it is within the 3-month window and not irrelevant, but it has 0 reviewers and a few failing CI jobs (OSV-scanner, lint/files, test-requires-root fast, java s390x) that a maintainer should triage.

Impact: 45 Quick Win: 22.5 Staleness: 45 Complexity: 50 Confidence: 80

Issue body

## Summary Mitigate repeated `.deb` downloads from a warm cache in the `stage-packages` / apt-cache path. This wraps `package.candidate.fetch_binary(...)` with a narrow local patch for `apt.package._file_is_same`, using: - binary file mode - order-independent hash comparison so cached `.deb` files that already match the expected metadata are treated as cache hits. ## Context Refs #1495. This is intentionally scoped to the `stage-packages` / apt-cache download path. It is related to, but separate from, #1485, which reduces some `python-apt` usage in the installed-package check path. ## Testing - `ruff check craft_parts/packages/apt_cache.py tests/unit/packages/test_apt_cache.py` - `pytest -q tests/unit/packages/test_apt_cache.py -rs` - `pytest -q tests/unit/packages/test_deb.py -rs` - `pytest -q tests/unit/packages -rs`

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.8-27b
Impact: 45
Quick Win: 22.5
Staleness: 45
Complexity: 50
Confidence: 80
needs review Patches apt-cache to treat cached .debs matching expected metadata as cache hits, avoiding repeated stage-packages re-downloads (workaround for python-apt _file_is_same bug). Awaiting review; CI mostly green with a few unrelated failures.
qwen/qwen3.6-35b-a3b
Staleness: 55
Complexity: 25
Confidence: 65
needs review Patches apt-cache to skip re-downloading cached .deb files via improved hash comparison. Currently pending maintainer review with zero approvals, minor unrelated CI failures, and last contributor activity 47 days ago.
qwen3.6-35b-a3b-mtp-q6
Staleness: 25
Complexity: 25
Confidence: 60
needs review Patches apt cache logic to prevent redundant .deb downloads by improving cache hit detection. Branch rebased, lint fixed, and tests updated. Awaiting maintainer review after unrelated CI failure.
qwen3.6-35b-a3b-mtp-q6
Staleness: 30
Complexity: 40
Confidence: 70
needs review Prevents redundant .deb downloads by patching apt cache hit detection to use binary mode and order-independent hashing. The PR is rebased and awaiting a CI rerun after an unrelated mirror failure blocked the pipeline.

Update history

No update history recorded yet.

Related work

  • Caused By: canonical/craft-parts#1495 (confidence 95%)

    PR body says 'Refs #1495'; the issue is the confirmed python-apt _file_is_same re-download bug this PR mitigates.

  • Related To: canonical/craft-parts#1485 (confidence 90%)

    PR body states it is 'related to, but separate from, #1485' (installed-package check path).

Related issues

Issue Project State Summary Similarity
#1468 fix(deb): refresh apt cache before marking packages craft-parts merged Merged a fix refreshing the apt cache before package marking to prevent BuildPackageNotFound errors from stale caches. Approved by three reviewers and merged after CI flakiness was confirmed as environment-related.
75%
#1485 fix(deb): avoid python-apt for installed package checks craft-parts merged Merged. Replaces python-apt with dpkg-query for host package checks to prevent PermissionError on deb822 systems missing /etc/apt/sources.list. Actual installation uses apt-get. Review cycle addressed formatting and CI failures prior to merge.
72%