rockcraft needs to update apt sources before installing build-packages
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Bug Description
I am building openjdk-25 jre rock that uses openjdk-25-jdk-headless build package.
Rockcraft reports `Cannot find package listed in 'build-packages': openjdk-25-jdk-headless` when building rock.
The package can be installed with `apt-get` in `override-build`.
### To Reproduce
1. rockcraft pack
### Environment
```
$ rockcraft version
rockcraft 1.15.0
```
rockcraft uses lxd backend.
### rockcraft.yaml
```yaml
name: jre
version: 25-edge
base: bare
build-base: ubuntu@24.04
platforms:
amd64:
summary: OpenJDK 25 headless runtime environment
description: |
This rock provides OpenJDK 25 runtime environment including
parts:
dependencies:
plugin: nil
build-packages:
- openjdk-25-jdk-headless
```
### Relevant log output
```shell
:: 2025-10-14 08:18:03.935 Initialising lifecycle
:: 2025-10-14 08:18:03.936 part build packages: ['openjdk-25-jdk-headless']
:: 2025-10-14 08:18:03.936 Installing build-packages
:: 2025-10-14 08:18:03.936 get repository attribute: attr=install_packages, repository:<class 'craft_parts.packages.deb.Ubuntu'>
:: 2025-10-14 08:18:03.936 Installing packages using apt: ['openjdk-25-jdk-headless']
:: 2025-10-14 08:18:04.649 Marking openjdk-25-jdk-headless (and its dependencies) to be fetched
:: 2025-10-14 08:18:04.649 Cannot find package listed in 'build-packages': openjdk-25-jdk-headless
:: 2025-10-14 08:18:04.651 Traceback (most recent call last):
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 491, in _get_packages_marked_for_installation
:: 2025-10-14 08:18:04.651 apt_cache.mark_packages(set(package_names))
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/apt_cache.py", line 307, in mark_packages
:: 2025-10-14 08:18:04.651 raise errors.PackageNotFound(name_arch)
:: 2025-10-14 08:18:04.651 craft_parts.packages.errors.PackageNotFound: Package not found: openjdk-25-jdk-headless.
:: 2025-10-14 08:18:04.651
:: 2025-10-14 08:18:04.651 The above exception was the direct cause of the following exception:
:: 2025-10-14 08:18:04.651 Traceback (most recent call last):
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 306, in run
:: 2025-10-14 08:18:04.651 self._exec(actions)
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/lifecycle.py", line 325, in _exec
:: 2025-10-14 08:18:04.651 with self._lcm.action_executor() as aex:
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 333, in __enter__
:: 2025-10-14 08:18:04.651 self._executor.prologue()
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 101, in prologue
:: 2025-10-14 08:18:04.651 self._install_build_packages()
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/executor/executor.py", line 278, in _install_build_packages
:: 2025-10-14 08:18:04.651 packages.Repository.install_packages(sorted(build_packages))
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 548, in install_packages
:: 2025-10-14 08:18:04.651 marked_packages = cls._get_packages_marked_for_installation(package_names)
:: 2025-10-14 08:18:04.651 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 295, in wrapped
:: 2025-10-14 08:18:04.651 return method(*args, **kwargs)
:: 2025-10-14 08:18:04.651 ^^^^^^^^^^^^^^^^^^^^^^^
:: 2025-10-14 08:18:04.651 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_parts/packages/deb.py", line 493, in _get_packages_marked_for_installation
:: 2025-10-14 08:18:04.651 raise errors.BuildPackageNotFound(error.package_name) from error
:: 2025-10-14 08:18:04.651 craft_parts.packages.errors.BuildPackageNotFound: Cannot find package listed in 'build-packages': openjdk-25-jdk-headless
2025-10-14 08:18:04.993 Executing on host: lxc --project rockcraft config device show local:rockcraft-jre-amd64-33199546
2025-10-14 08:18:05.067 Executing on host: lxc --project rockcraft config device remove local:rockcraft-jre-amd64-33199546 disk-/root/project
2025-10-14 08:18:05.175 Executing on host: lxc --project rockcraft config device remove local:rockcraft-jre-amd64-33199546 disk-/tmp/craft-state
2025-10-14 08:18:05.283 Executing on host: lxc --project rockcraft stop local:rockcraft-jre-amd64-33199546
2025-10-14 08:18:09.434 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:09.760 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:10.066 Executing on host: lxc --project rockcraft list local: --format=yaml
2025-10-14 08:18:10.382 Executing on host: lxc --project rockcraft config set local:rockcraft-jre-amd64-33199546 user.craft_providers.status FINISHED
2025-10-14 08:18:10.500 Failed to run rockcraft in instance
2025-10-14 08:18:10.504 Traceback (most recent call last):
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/provider.py", line 469, in run_managed
2025-10-14 08:18:10.504 instance.execute_run( # pyright: ignore[reportUnknownMemberType,reportUnknownVariableType]
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_providers/lxd/lxd_instance.py", line 257, in execute_run
2025-10-14 08:18:10.504 return self.lxc.exec(
2025-10-14 08:18:10.504 ^^^^^^^^^^^^^^
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_providers/lxd/lxc.py", line 393, in exec
2025-10-14 08:18:10.504 return runner(final_cmd, timeout=timeout, check=check, **kwargs)
2025-10-14 08:18:10.504 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.504 File "/snap/rockcraft/current/usr/lib/python3.12/subprocess.py", line 571, in run
2025-10-14 08:18:10.504 raise CalledProcessError(retcode, process.args,
2025-10-14 08:18:10.504 subprocess.CalledProcessError: Command '['lxc', '--project', 'rockcraft', 'exec', 'local:rockcraft-jre-amd64-33199546', '--cwd', '/root/project', '--', 'env', 'CRAFT_MANAGED_MODE=1', 'ROCKCRAFT_DEBUG=False', 'ROCKCRAFT_LXD_REMOTE=local', 'ROCKCRAFT_LAUNCHPAD_INSTANCE=production', 'DEBIAN_FRONTEND=noninteractive', 'DEBCONF_NONINTERACTIVE_SEEN=true', 'DEBIAN_PRIORITY=critical', 'CRAFT_PLATFORM=amd64', 'CRAFT_VERBOSITY_LEVEL=BRIEF', 'rockcraft', 'pack']' returned non-zero exit status 1.
2025-10-14 08:18:10.504
2025-10-14 08:18:10.504 The above exception was the direct cause of the following exception:
2025-10-14 08:18:10.504 Traceback (most recent call last):
2025-10-14 08:18:10.504 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/application.py", line 663, in run
2025-10-14 08:18:10.505 return_code = self._run_inner()
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/application.py", line 640, in _run_inner
2025-10-14 08:18:10.505 return_code = dispatcher.run() or os.EX_OK
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_cli/dispatcher.py", line 564, in run
2025-10-14 08:18:10.505 return self._loaded_command.run(self._parsed_command_args)
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/base.py", line 222, in run
2025-10-14 08:18:10.505 result = self._run(parsed_args, **kwargs) or result
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 619, in _run
2025-10-14 08:18:10.505 return super()._run(parsed_args=parsed_args, step_name=step_name)
2025-10-14 08:18:10.505 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 232, in _run
2025-10-14 08:18:10.505 self._run_manager_for_build_plan(fetch_service_policy)
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/commands/lifecycle.py", line 97, in _run_manager_for_build_plan
2025-10-14 08:18:10.505 provider.run_managed(build, bool(fetch_service_policy))
2025-10-14 08:18:10.505 File "/snap/rockcraft/3790/lib/python3.12/site-packages/craft_application/services/provider.py", line 476, in run_managed
2025-10-14 08:18:10.505 raise craft_providers.ProviderError(
2025-10-14 08:18:10.505 craft_providers.errors.ProviderError: Failed to run rockcraft in instance
2025-10-14 08:18:10.505 Full execution log: '/home/vladimirp/.local/state/rockcraft/log/rockcraft-20251014-081734.765385.log'
```
Evaluation history
No evaluation history available.