← Back to issue list

repo: fix for multi-arch stage-package scenario

View original Github issue

Metadata

Project
snapcraft
Number
#3080
Type
pull request
State
merged
Author
cjp256
Labels
Created
Updated
Closed

Current evaluation

Merged fix for multi-arch stage-package dependency resolution. Uses python-apt's or_dependencies to resolve architectures correctly, passes target_arch internally, and adds fallback logic. Approved and merged after test updates.

Suggested action:

No scores available.

Issue body

When enabling multiple architectures, python-apt's BaseDependency may yield target_versions for a package which are for the unintended architecture when coming across a package with ':all' architecture. For example: python3-pip has a dependency on "python3:any". On AMD64 it may point to the i386 package, when having i386 architectures enabled: ``` >>> apt.Cache()["python3-pip"].candidate.dependencies[-1].target_versions [ <Version: package:'python3:i386' version:'3.6.7-1~18.04'>, <Version: package:'python3' version:'3.6.7-1~18.04'>, <Version: package:'python3:i386' version:'3.6.5-3'>, <Version: package:'python3' version:'3.6.5-3'>] ] ``` Instead, we'll look at python-apt's `or_dependencies` list, which is used to calculate the allowable target_versions: ``` >>> apt.Cache()["python3-pip"].candidate.dependencies[-1].or_dependencies <Dependency: [<BaseDependency: name:'python3:any' relation:'>=' version:'3.4~' rawtype:'Depends'>]> ``` apt.package.Dependency will provide us with the 'name', e.g. 'python3:any', and we can use this name to fetch the correct dependencies. To support installing the correct architecture, we now will pass target_arch to _mark_package_dependencies() and _get_resolved_package(). _get_resolved_package() will use the now-introduced _get_package_for_arch() method to find the correct package for the intended architecture: 1. First trying `<package-name>:<target-arch>`. 2. Then trying `<package-name>:all` in case it's a no-arch package. 3. Finally trying `<package-name>`, but logging a warning that it may be the incorrect architecture. This shouldn't happen, but the warning is there just so we'll know about it if there is a case we didn't consider. Update unit tests, cleaning out some old cruft left behind and passing without purpose. Signed-off-by: Chris Patterson <chris.patterson@canonical.com> - [ ] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)? - [ ] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)? - [ ] Have you successfully run `./runtests.sh static`? - [ ] Have you successfully run `./runtests.sh tests/unit`? -----

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b Merged fix for multi-arch stage-package dependency resolution. Uses python-apt's or_dependencies to resolve architectures correctly, passes target_arch internally, and adds fallback logic. Approved and merged after test updates.
qwen3.6-35b-a3b-mtp-q6 Merged fix for multi-arch stage-package dependency resolution. Corrected python-apt dependency resolution for :all packages using or_dependencies and target_arch-aware lookup. Fixed unit test failures by updating FakeAptPackage mocks.
qwen3.6-35b-a3b-mtp-q6 Merged. Fixes multi-arch stage-package resolution where python-apt mismatched :all package architectures. Resolved by using or_dependencies, passing target_arch to internal methods, and implementing _get_package_for_arch() to select correct packages.

Update history

No update history recorded yet.

Related issues

Issue Project State Summary Similarity
#3084 repo: fix for multi-arch virtual-packages snapcraft merged Merged fix for multi-arch virtual package resolution. Correctly handles architecture tags, reverts or_dependencies to target_versions, and fixes an apt.Package.architectures method call. Approved and passed CI.
85%
#1050 repo: add multiarch support for stage packages. snapcraft merged Merged into master. Adds multiarch support for stage packages via the name:arch syntax, resolving LP #1655797. The author noted a simpler solution was proposed and reassigned the task, but the PR was ultimately merged.
80%
#876 repo: allow for architecture-specific stage-packages snapcraft merged Merged. Implements architecture-specific stage-packages using a package:arch syntax in the stage-packages list. A per-part architecture approach was rejected during review. The updated code passed CI and was merged.
76%
#3416 repo: default to target arch for stage package cache snapcraft merged Merged into master following approval and passing CI. The change defaults the stage package cache to the target architecture, updates 22 files, and adds spread tests to verify the behavior.
74%
#3461 repo: account for arch & version when filtering stage packages snapcraft merged Merged into master. Refactored stage package filtering to correctly handle architecture and version qualifiers via a new helper. Updated cross-compile tests, achieved 90.74% diff coverage, and passed CI after maintainer approval.
73%
#3740 repo: enable package repository architectures snapcraft merged Merged into main. Enables package repository architectures by running dpkg --add-architecture for listed architectures, resolving Launchpad bug #1973213. Approved and passed CI with full coverage.
72%
#1346 repo: multi-arch build deps snapcraft closed Closed without merging. The multi-arch build dependency changes were abandoned due to unresolved conflicts and lack of reviewer engagement after the author was asked to resolve them.
71%
#3065 tests: fix local plugin spread test to be multi-arch aware snapcraft merged Merged a fix updating the local plugin spread test for multi-architecture compatibility, enabling autopkgtests to pass on non-amd64 platforms. Approved by one reviewer, passed CI checks, and applied with minimal changes.
70%
#258 packages: fetch stage-packages from host arch's repo craft-parts merged Merged to resolve cross-compilation failures by fetching stage-packages from the host architecture repository. Approved, passed CI, and closes LP #1983009 and CRAFT-1216.
70%