From 6a6b00d68b0afde48e2d61ce3ea2afb4123b11cc Mon Sep 17 00:00:00 2001 From: "michael.hudson@canonical.com" Date: Wed, 11 Feb 2026 10:54:33 +1300 Subject: [PATCH] Add download_direct method to AptStateManager Extract a download_direct() method from download() to enable downloading packages to an arbitrary directory with an arbitrary specification string. This will be used by the boot configuration code to download bootloader packages. Co-Authored-By: Claude Opus 4.6 --- live-build/isobuilder/apt_state.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/live-build/isobuilder/apt_state.py b/live-build/isobuilder/apt_state.py index 27d93271..1cf0440f 100644 --- a/live-build/isobuilder/apt_state.py +++ b/live-build/isobuilder/apt_state.py @@ -82,7 +82,7 @@ class AptStateManager: if params: yield PackageInfo(**params) - def download(self, rootdir: pathlib.Path, pkg_info: PackageInfo): + def download(self, rootdir: pathlib.Path, pkg_info: PackageInfo) -> None: """Download the package specified by `pkg_info` under `rootdir`. The package is saved to the same path under `rootdir` as it is @@ -90,9 +90,17 @@ class AptStateManager: """ target_dir = rootdir.joinpath(pkg_info.filename).parent target_dir.mkdir(parents=True, exist_ok=True) + self.download_direct(pkg_info.spec, target_dir) + + def download_direct(self, spec: str, target: pathlib.Path) -> None: + """Download the package specified by spec to target directory. + + The package is downloaded using apt-get download and saved directly + in the target directory. + """ self.logger.run( - ["apt-get", "download", pkg_info.spec], - cwd=target_dir, + ["apt-get", "download", spec], + cwd=target, check=True, env=self._apt_env(), )