lib.Distro._install(): Implement remote installation

lib.Distro._install()'s default implementation allows to install packages specified as direct links, but only to the local machine. Implement installation to arbitrary hosts specified with --target.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-27 09:38:12 +02:00
commit 1c11503dfb
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -354,13 +354,15 @@ class Distro(abc.ABC):
# Download first and then install. Override if Distro knows better.
async def _install_urls(self, urls: Iterable[str], only_update: bool) -> None:
import tempfile
from .util import copy
with tempfile.TemporaryDirectory(prefix='jw-pkg-') as tmp:
paths: list[str] = []
for url in urls:
paths.append(await copy(url, tmp))
tmp: str|None = None
try:
tmp = await self.__exec_context.mktemp('/tmp/jw-pkg-XXXXXX', directory=True)
paths = await copy(urls, self.__exec_context.uri.scheme_plus_authority + tmp)
await self._install_local_files(paths, only_update=only_update)
finally:
if tmp is not None:
await self.__exec_context.erase(tmp)
# Default implementation installs in two steps:
# - Download URLs into local directories and install