fix(deb): avoid python-apt for installed package checks
Metadata
Current evaluation
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.
Suggested action: —
No scores available.
Issue body
Fixes #976
## Background
On Ubuntu Plucky, `/etc/apt/sources.list` may be absent because the system uses deb822-based configuration exclusively.
When `python-apt` initializes its cache (`apt.cache.Cache(rootdir="/")`), it attempts to ensure certain files exist, including `/etc/apt/sources.list`.
If the file is missing, it attempts to create it. When running as an unprivileged user (e.g. during integration tests), this results in:
PermissionError: [Errno 13] Permission denied: '//etc/apt/sources.list'
This failure happens in the installed-package check path, before any actual installation occurs.
## What this change does
For the host `install_packages()` path only:
- Replace the use of `python-apt` for:
- checking whether packages are already installed
- constructing the returned `package=version` list
- Use `dpkg-query` instead for installed-state detection.
Actual installation still uses:
apt-get install ...
Stage package handling and other apt-cache–based functionality remain unchanged.
## Rationale
For determining whether a package is installed, `dpkg-query` is:
- sufficient
- does not require root
- independent of apt source configuration
- unaffected by deb822 migration
Using `python-apt` for this specific optimization is unnecessary and causes failures on systems without `/etc/apt/sources.list`.
## Trade-offs
- `dpkg-query` does not resolve virtual packages in the same way as `python-apt`.
- However:
- `apt-get install` still performs dependency and virtual package resolution.
- The returned `package=version` list is already documented as “best effort”.
- Typical build-packages (cmake, gcc, pkg-config, etc.) are concrete packages.
## Scope
This change only affects the installed-check optimization and version reporting for host installs.
All apt-cache usage for stage packages remains intact.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| qwen3.6-35b-a3b-mtp-q6 | — | — | 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. | |
| qwen/qwen3.8-27b |
Impact:
50
Quick Win:
22.5
Staleness:
5
Complexity:
55
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query/apt-get --simulate for host installed-package checks to avoid PermissionError when /etc/apt/sources.list is absent (fixes #976). Approved by 2 reviewers; active review cycle with unresolved ruff formatting request and merge conflicts. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
5
Complexity:
30
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for host installed package checks to avoid permission errors on deb822-only systems. Approved, CI passing, merge conflicts resolved, awaiting final maintainer review. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
10
Complexity:
30
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix permission errors on deb822-only systems. CI passing, awaiting maintainer review after merge conflict resolution. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
10
Complexity:
35
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. Currently under review with unresolved comments and pending merge conflict resolution. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
15
Complexity:
50
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. Currently under review, awaiting merge conflict resolution. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
15
Complexity:
50
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. Currently awaiting maintainer review after addressing merge conflicts and requested changes. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
10
Complexity:
45
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. CI passes, author addressed reviewer feedback, awaiting maintainer approval. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
20
Complexity:
40
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to avoid permission errors on deb822-only systems. CI passes, review requested with 8 unresolved comments, awaiting maintainer feedback. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
10
Complexity:
45
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix permission errors on deb822-only systems. CI passes. Awaiting maintainer re-review after recent updates addressing requested changes. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
20
Complexity:
30
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to avoid permission errors on deb822-only systems. CI passes, but review status remains changes_requested with unresolved comments despite recent contributor updates. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
45
Complexity:
40
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for host installed-package checks to prevent permission errors on deb822-only systems. Currently awaiting maintainer review after addressing requested changes; CI is mostly passing. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
15
Complexity:
50
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. Currently under review with changes requested, author has addressed feedback and CI is green. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
20
Complexity:
40
Confidence:
90
|
needs review | Replaces python-apt with dpkg-query for installed package checks to avoid permission errors on deb822-only systems. Awaiting maintainer review of latest changes addressing requested feedback. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
45
Complexity:
45
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to prevent permission errors on deb822-only systems. Currently awaiting maintainer review after addressing requested changes; CI is green. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
20
Complexity:
40
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for installed package checks to fix PermissionError on deb822-only systems. PR is green, review comments addressed, awaiting maintainer review. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
45
Complexity:
30
Confidence:
85
|
needs review | Replaces python-apt with dpkg-query for host package checks to prevent permission errors on deb822-only systems. Tests pass and requested changes addressed. Awaiting maintainer review and approval. |
Update history
| Date | Change |
|---|---|
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated | |
| updated |
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1127 build(deps): update python-apt groups | rockcraft | merged | Merged after two approvals and passing CI checks. Updates python-apt groups to align with current Ubuntu distributions, removing oracular and plucky while adding resolute. | |
| #1553 fix(deb): avoid re-downloading cached stage-packages | craft-parts | open | 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. | |
| #450 deps: change python-apt dependencies to launchpad | craft-parts | merged | Merged an update replacing python-apt dependencies with launchpad. Approved by one reviewer, passed CI, and modified one file with three additions and three deletions. | |
| #259 deps: update python-apt dependencies | rockcraft | merged | Merged update to python-apt dependencies. Approved by two reviewers and passed CI. Maintainers confirmed merging regardless of pending craft-parts decisions, as stable Launchpad URLs prevent 404 errors. | |
| #1205 deps: update python-apt | charmcraft | merged | Successfully merged following single reviewer approval. The python-apt dependency update altered three files with three additions and three deletions, applying a routine package version bump. | |
| #1068 build(deps): update python-apt for plucky | craft-parts | merged | Merged after approval from two reviewers and passing all CI checks. Updates the python-apt dependency for the Plucky release, modifying two files with 17 additions and 6 deletions. |