[Investigate] support foreign architectures
Metadata
Current evaluation
Foreign-architecture package installation was implemented in PR #153 (commit 64f1092) and released in craft-archives 2.1.0.
Resolution: closed resolved
Reason: PR #153 was merged as commit 64f1092, enabling foreign-architecture APT support for deb822 Ubuntu sources, including Ubuntu 24.04. The maintainer confirmed the fix shipped in version 2.1.0.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### What needs to get done
PR #96 restricted the calls to `dpkg --add-architecture` to only "compatible" pairs of architectures. This suits a lot of use cases, particularly those that just need to download (but not install) packages from a non-host arch.
Where this breaks is effective cross-compilation; any non-trivial cross-compilation case will require dependencies in the target architecture (like dev versions of shared libraries), and the common idiom of:
```yaml
build-packages:
- libxx-dev:arch
stage-packages:
- libxx:arch
```
does *not* work because the installation of libxx-dev:arch fails, because the target arch there has not been added to the system via `dpkg --add-architecture`.
As #96 explains, the reason we can't just call `dpkg --add-architeture non-host-arch` is because the official archives list all archs (even those they don't have packages for) *and* default Apt installations do not restrict the archs in those archives. See `/etc/apt/sources.list` on my machine:
```
...
deb http://archive.ubuntu.com/ubuntu jammy-updates universe
...
```
... so `apt update` will try to fetch the packages listing for "non-host-arch" from archive.ubuntu.com and fail.
What we need to investigate/prototype is a different strategy: if a package-repo with a non-host arch is added (e.g. adding an `armhf` repo in an `amd64` host), we must call `dpkg --add-architecture armhf` (or whatever arch), but we must *also* fix
those sources listings that don't "pin" the arch. In the example above, the new line would read:
```
...
deb [arch=amd64] http://archive.ubuntu.com/ubuntu jammy-updates universe
...
```
Here's a series of steps that users are currently doing in host installations to support this scenario:
```
> dpkg --add-architecture ${ARCH}
> sed -ri "s/^deb /deb [arch=amd64] /g" /etc/apt/sources.list
> apt update
> apt --fix-broken install -y
> apt upgrade -y
```
... of course, that script only fixes a single file and doesn't do any verification of pre-existing architectures, so the actual commands need to be improved, but the general idea is this.
### Why it needs to get done
To make the build system more robust and improve support for cross-compilation.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Foreign-architecture package installation was implemented in PR #153 (commit 64f1092) and released in craft-archives 2.1.0. | |
| stealth/space-bunny-alpha | — | closed resolved | Foreign-architecture support was implemented by merged PR #153 (64f1092) for deb822 Ubuntu sources, enabling cross-compilation dependencies; shipped in craft-archives 2.1.0. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in craft-archives 2.1.0 via PR #153. Automatic architecture pinning in apt sources was implemented to enable foreign architecture support for cross-compilation, resolving target package installation failures. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in craft-archives 2.1.0 via PR #153. Resolves cross-compilation dependency installation by automatically pinning foreign architectures in apt sources, removing the need for manual configuration. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in craft-archives 2.1.0 via PR #153. Cross-compilation failures caused by unpinned apt source listings for foreign architectures were resolved by updating source configuration handling to properly support multi-arch setups. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
craft-archives#153
(confidence 100%)
Merged implementation that added foreign-architecture support and was released in version 2.1.0.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #150 Support foreign architectures | craft-archives | closed | Foreign-architecture support shipped in craft-archives 2.1.0 via merged PR #153 (64f1092), replacing prototype #149 and enabling cross-compilation dependencies. | |
| #5222 Support foreign architectures | snapcraft | closed | Foreign-architecture APT support landed in craft-archives#153 (64f1092), released in 2.1.0; Snapcraft added core24 cross-compilation coverage in b26b653c1. | |
| #153 feat: support foreign architectures | craft-archives | merged | Merged PR #153 as commit 64f1092, adding APT foreign-architecture support for deb822-based Ubuntu sources, including core24; released in craft-archives 2.1.0. | |
| #149 [PROTOTYPE] feat(apt_sources_manager): support foreign architectures | craft-archives | closed | Prototype PR #149 was closed unmerged and superseded by #153, which added foreign-architecture APT support in commit 64f1092 and shipped in craft-archives 2.1.0. | |
| #5233 [PROTOTYPE] feat: support foreign architectures | snapcraft | closed | Prototype PR for foreign-architecture support (CRAFT-4038) was closed unmerged; maintainer mr-cal noted it was superseded by merged PR #5274, shipped on latest/edge and scheduled for Snapcraft 8.8. |