Fail to fetch packages for non-host architecture
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Bug Description
Snapcraft fails to fetch packages from remote repositories with architectures different than the hosts, giving error:
```
Stage package not found in part 'foo': ros-jazzy-ros-base:arm64.
```
This is despite `ros-jazzy-ros-base:arm64` being present in a known repo. When running natively on either ARM64 or AMD64 (without `platform` key in yaml), all dependencies are pulled as expected and the build succeeds.
### To Reproduce
Simply run snapcraft on the `snapcraft.yaml` file.
### Environment
Ubuntu 24.04.2 LTS
snapcraft 8.7.4.post91 (tracking latest/edge)
LXD rev 33110 (5.21/stable)
### snapcraft.yaml
```yaml
name: foo
version: '0.0.0'
summary: foo
description: foo
grade: devel
confinement: devmode
base: core24
lint:
ignore:
- library
- classic
platforms:
arm64:
build-on: [amd64]
build-for: [arm64]
package-repositories:
- type: apt
architectures: [$CRAFT_ARCH_BUILD_FOR]
formats: [deb, deb-src]
components: [main, universe]
suites: [noble, noble-updates, noble-backports]
key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C
url: http://ports.ubuntu.com/ubuntu-ports
- type: apt
architectures: [$CRAFT_ARCH_BUILD_FOR]
formats: [deb, deb-src]
components: [main]
suites: [noble]
key-id: C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
url: http://repo.ros2.org/ubuntu/main
parts:
foo:
plugin: nil
source: .
stage-packages:
- libc6:$CRAFT_ARCH_BUILD_FOR
- ros-jazzy-ros-base:$CRAFT_ARCH_BUILD_FOR
```
### Relevant log output
```shell
:: 2025-04-16 08:43:37.275 Pulling foo
:: 2025-04-16 08:43:37.276 execute action foo:Action(part_name='foo', step=Step.PULL, action_type=ActionType.RUN, reason=None, project_vars=None, properties=ActionProperties(changed_files=None, changed_dirs=None))
:: 2025-04-16 08:43:37.276 Fetching stage-packages
:: 2025-04-16 08:43:37.276 Requested stage-packages: ['libc6:arm64', 'ros-jazzy-ros-base:arm64']
:: 2025-04-16 08:43:39.079 Marking libc6:arm64 (and its dependencies) to be fetched
:: 2025-04-16 08:43:39.079 package: libc6:arm64
:: 2025-04-16 08:43:39.201 Marking ros-jazzy-ros-base:arm64 (and its dependencies) to be fetched
:: 2025-04-16 08:43:39.201 package: ros-jazzy-ros-base:arm64
:: 2025-04-16 08:43:39.347 Stage package not found in part 'foo': ros-jazzy-ros-base:arm64.
:: 2025-04-16 08:43:39.350 Traceback (most recent call last):
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 949, in _fetch_stage_packages
:: 2025-04-16 08:43:39.350 fetched_packages = packages.Repository.fetch_stage_packages(
:: 2025-04-16 08:43:39.350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 638, in fetch_stage_packages
:: 2025-04-16 08:43:39.350 return cls._fetch_stage_debs( # type: ignore[no-any-return]
:: 2025-04-16 08:43:39.350 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 293, in wrapped
:: 2025-04-16 08:43:39.350 return method(*args, **kwargs)
:: 2025-04-16 08:43:39.350 ^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 685, in _fetch_stage_debs
:: 2025-04-16 08:43:39.350 apt_cache.mark_packages(set(package_names))
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/packages/apt_cache.py", line 328, in mark_packages
:: 2025-04-16 08:43:39.350 _verify_marked_install(package)
:: 2025-04-16 08:43:39.350 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/packages/apt_cache.py", line 375, in _verify_marked_install
:: 2025-04-16 08:43:39.350 raise errors.PackageNotFound(package.name)
:: 2025-04-16 08:43:39.350 craft_parts.packages.errors.PackageNotFound: Package not found: ros-jazzy-ros-base:arm64.
:: 2025-04-16 08:43:39.351
:: 2025-04-16 08:43:39.351 The above exception was the direct cause of the following exception:
:: 2025-04-16 08:43:39.351 Traceback (most recent call last):
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 302, in run
:: 2025-04-16 08:43:39.351 aex.execute(action, stdout=stream, stderr=stream)
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 324, in execute
:: 2025-04-16 08:43:39.351 self._executor.execute(actions, stdout=stdout, stderr=stderr)
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 136, in execute
:: 2025-04-16 08:43:39.351 self._run_action(act, stdout=stdout, stderr=stderr)
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 211, in _run_action
:: 2025-04-16 08:43:39.351 handler.run_action(action, stdout=stdout, stderr=stderr)
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 202, in run_action
:: 2025-04-16 08:43:39.351 state = handler(step_info, stdout=stdout, stderr=stderr)
:: 2025-04-16 08:43:39.351 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 224, in _run_pull
:: 2025-04-16 08:43:39.351 fetched_packages = self._fetch_stage_packages(step_info=step_info)
:: 2025-04-16 08:43:39.351 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-04-16 08:43:39.351 File "/snap/snapcraft/14286/lib/python3.12/site-packages/craft_parts/executor/part_handler.py", line 957, in _fetch_stage_packages
:: 2025-04-16 08:43:39.351 raise errors.StagePackageNotFound(
:: 2025-04-16 08:43:39.351 craft_parts.errors.StagePackageNotFound: Stage package not found in part 'foo': ros-jazzy-ros-base:arm64.
```
### Additional context
_No response_
Evaluation history
No evaluation history available.