mirror of
https://git.launchpad.net/livecd-rootfs
synced 2026-02-17 15:33:32 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
e4b17221a0
commit
6a6b00d68b
@ -82,7 +82,7 @@ class AptStateManager:
|
|||||||
if params:
|
if params:
|
||||||
yield PackageInfo(**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`.
|
"""Download the package specified by `pkg_info` under `rootdir`.
|
||||||
|
|
||||||
The package is saved to the same path under `rootdir` as it is
|
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 = rootdir.joinpath(pkg_info.filename).parent
|
||||||
target_dir.mkdir(parents=True, exist_ok=True)
|
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(
|
self.logger.run(
|
||||||
["apt-get", "download", pkg_info.spec],
|
["apt-get", "download", spec],
|
||||||
cwd=target_dir,
|
cwd=target,
|
||||||
check=True,
|
check=True,
|
||||||
env=self._apt_env(),
|
env=self._apt_env(),
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user