[Investigate] support foreign architectures
Metadata
Current evaluation
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.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed in craft-archives 2.1.0 via PR #153. Resolves cross-compilation support by properly managing foreign architecture setup and apt source pinning, removing the need for manual configuration workarounds. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #149 [PROTOTYPE] feat(apt_sources_manager): support foreign architectures | craft-archives | closed | Prototype adding foreign architecture support to the apt sources manager was closed and superseded by pull request #153. The original changes were not merged. |