Can't mix ports.ubuntu.com and archive.ubuntu.com (building multi-arch snaps)
Metadata
Current evaluation
Resolved in Snapcraft 7.5.2 by globally adding only compatible foreign architectures (amd64+i386, arm64+armhf); the reporter confirmed package-repository refresh now works.
Resolution: closed resolved
Reason: The reporter confirmed on 18 August 2023 that Snapcraft 7.5.2 fixed Case A. A maintainer then closed the issue as fix released, noting advanced package-repository grammar might be addressed separately.
Evaluated by: mr-cal-bot
No scores available.
Issue body
The use case is building snaps containing both 32- and 64-bit packages (i.e. to support older software in the graphics-core22 stack [1]).
I've not found a way to build a amd64 + i386 (or arm64 + armhf) snap, because either repository refresh fails (case A), or snapcraft holds on to an archive cache from before `dpkg --add-architecture` (case B).
## Case A
Given this YAML:
(using the ARM example as this stops working when building a snap for an architecture that doesn't exist in the added repository - this way you can reproduce on amd64)
```yaml
name: arch-test
base: core22
version: '0.1'
summary: Architecture test
description: |
Multi-architecture test.
grade: devel
confinement: devmode
package-repositories:
- type: apt
url: http://ports.ubuntu.com/ubuntu-ports/
suites: [jammy]
components: [main, universe]
architectures: [armhf]
key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C
key-server: keyserver.ubuntu.com
parts:
part:
plugin: nil
stage-packages:
- libc6:armhf
```
```plain
$ snapcraft
Launching instance...
Add repository architecture: armhf
Failed to refresh package list: failed to run apt update.
Failed to execute pack in instance.
Full execution log: '/home/michal/.cache/snapcraft/log/snapcraft-20230304-212001.588931.log'
```
Because:
```plain
2023-03-04 21:20:35.447 :: 2023-03-04 20:20:35.054 :: E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/main/binary-armhf/Packages 404 Not Found [IP: 185.125.190.36 80]
2023-03-04 21:20:35.447 :: 2023-03-04 20:20:35.054 :: E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/jammy-security/main/binary-armhf/Packages 404 Not Found [IP: 185.125.190.39 80]
2023-03-04 21:20:35.447 :: 2023-03-04 20:20:35.054 :: E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-updates/main/binary-armhf/Packages 404 Not Found [IP: 185.125.190.39 80]
2023-03-04 21:20:35.447 :: 2023-03-04 20:20:35.054 :: E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy-backports/main/binary-armhf/Packages 404 Not Found [IP: 185.125.190.39 80]
2023-03-04 21:20:35.447 :: 2023-03-04 20:20:35.054 :: E: Some index files failed to download. They have been ignored, or old ones used instead.
```
The apt repository definitions in the build base are not architecture-specific, so adding an architecture outside of that repository results in above errors.
## Case B
Another approach:
```yaml
# ... (no package-repositories)
parts:
aaa:
plugin: nil
stage-packages:
- libc6
arch-add:
plugin: nil
override-pull: |
if [ "${CRAFT_TARGET_ARCH}" == "amd64" ]; then
dpkg --add-architecture i386
apt-get update
fi
pack-i386:
after: [arch-add]
plugin: nil
stage-packages:
- libc6:i386
```
This will fail to find `libc6:i386`, because Snapcraft seems to hold to an apt cache from before processing parts:
```plain
Launching instance...
Executed: pull arch-add
Stage package not found in part 'pack': libc6:i386.
Failed to execute pack in instance.
Full execution log: '/home/michal/.cache/snapcraft/log/snapcraft-20230304-213302.303889.log'
```
Re-running the build will complete, because Snapcraft will have reloaded the now-multiarch cache.
[1] https://github.com/MirServer/glvnd-core22/
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Resolved in Snapcraft 7.5.2 by globally adding only compatible foreign architectures (amd64+i386, arm64+armhf); the reporter confirmed package-repository refresh now works. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in Snapcraft 7.5.2 by restricting core22 dpkg architecture additions to compatible host/target pairs; the reporter confirmed the fix. | |
| stealth/space-bunny-alpha | — | closed stale | Closed without a recorded fix, closure comment, or linked resolution; no verified commit or PR addresses multi-architecture APT refresh and cache handling. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Multi-arch snap builds fail due to apt cache persistence across parts and architecture-specific repository fetch errors. No fix or merge was implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. Multi-arch snap builds remain unsupported due to apt repository mixing failures and stale package caches before architecture additions. No fix was implemented. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without resolution. The reported multi-arch snap build failure caused by apt repository mixing and stale package caches remains unfixed. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Closed without comments or resolution. Likely abandoned. Multi-arch repository mixing remains unaddressed. |
Update history
| Date | Change |
|---|---|
| created |
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2018609 Can't update repositories when building for different arch from host | snapcraft (launchpad) | closed | Cross-arch apt sources picked archive.ubuntu.com instead of ports.ubuntu.com; fixed on the snapcraft side by canonical/craft-archives#96 and snapcore/snapcraft#4303 (commit 1db0f39), released in 7.5.1/7.5.2; reporter confirmed resolved. | |
| #1973213 package-repositories with i386 doesn't enable the arch | snapcraft (launchpad) | closed | Fixed by merged PR canonical/snapcraft#3740: package-repository architectures now run dpkg --add-architecture. Merge commit: 7b848f76d. |