lib.Distro, ExecContext: Add classes, refactor lib.distro
The code below lib.distro, as left behind by the previous commit, is
geared towards being directly used as a command-line API. This commit
introduces the abstract base class Distro, a proxy for
distribution-specific interactions. The proxy abstracts distro
specifics into an API with proper method prototypes, not
argparse.Namespace contents, and can thus be more easily driven by
arbitrary code.
The Distro class is initialized with a member variable of type
ExecContext, another new class introduced by this commit. It is
designed to abstract the communication channel to the distribution
instance. Currently only one specialization exists, Local, which
interacts with the distribution and root file system it is running
in, but is planned to be subclassed to support interaction via SSH,
serial, chroot, or chains thereof.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-05 17:33:52 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
|
|
|
|
from ...Distro import Distro as Base
|
|
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from typing import Iterable
|
|
|
|
|
from ...ExecContext import Result
|
|
|
|
|
from ...Package import Package
|
|
|
|
|
|
|
|
|
|
class Distro(Base):
|
|
|
|
|
|
|
|
|
|
async def pacman(self, args: list[str]) -> Result:
|
|
|
|
|
cmd = ['/usr/bin/pacman']
|
|
|
|
|
if not self.interactive:
|
|
|
|
|
cmd.extend(['--noconfirm'])
|
|
|
|
|
cmd.extend(args)
|
|
|
|
|
return await self.sudo(cmd)
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
async def _ref(self) -> None:
|
|
|
|
|
raise NotImplementedError('distro refresh is not yet implemented for Arch-like distributions')
|
|
|
|
|
|
|
|
|
|
async def _dup(self, download_only: bool) -> None:
|
|
|
|
|
args = ['-Su']
|
|
|
|
|
if args.download_only:
|
|
|
|
|
args.append('-w')
|
2026-03-06 17:25:19 +01:00
|
|
|
return await self.pacman(args)
|
lib.Distro, ExecContext: Add classes, refactor lib.distro
The code below lib.distro, as left behind by the previous commit, is
geared towards being directly used as a command-line API. This commit
introduces the abstract base class Distro, a proxy for
distribution-specific interactions. The proxy abstracts distro
specifics into an API with proper method prototypes, not
argparse.Namespace contents, and can thus be more easily driven by
arbitrary code.
The Distro class is initialized with a member variable of type
ExecContext, another new class introduced by this commit. It is
designed to abstract the communication channel to the distribution
instance. Currently only one specialization exists, Local, which
interacts with the distribution and root file system it is running
in, but is planned to be subclassed to support interaction via SSH,
serial, chroot, or chains thereof.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-05 17:33:52 +01:00
|
|
|
|
|
|
|
|
async def _reboot_required(self, verbose: bool) -> bool:
|
|
|
|
|
raise NotImplementedError('distro reboot-required is not yet implemented for Arch-like distributions')
|
|
|
|
|
|
|
|
|
|
async def _select(self, names: Iterable[str]) -> Iterable[Package]:
|
2026-03-06 17:25:19 +01:00
|
|
|
raise NotImplementedError('distro select is not yet implemented for Arch-like distributions')
|
lib.Distro, ExecContext: Add classes, refactor lib.distro
The code below lib.distro, as left behind by the previous commit, is
geared towards being directly used as a command-line API. This commit
introduces the abstract base class Distro, a proxy for
distribution-specific interactions. The proxy abstracts distro
specifics into an API with proper method prototypes, not
argparse.Namespace contents, and can thus be more easily driven by
arbitrary code.
The Distro class is initialized with a member variable of type
ExecContext, another new class introduced by this commit. It is
designed to abstract the communication channel to the distribution
instance. Currently only one specialization exists, Local, which
interacts with the distribution and root file system it is running
in, but is planned to be subclassed to support interaction via SSH,
serial, chroot, or chains thereof.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-05 17:33:52 +01:00
|
|
|
|
|
|
|
|
async def _install(self, names: Iterable[str], only_update: bool) -> None:
|
|
|
|
|
if only_update:
|
|
|
|
|
raise NotImplementedError('--only-update is not yet implemented for pacman')
|
|
|
|
|
args = ['-S', '--needed']
|
|
|
|
|
args.extend(args.packages)
|
2026-03-06 17:25:19 +01:00
|
|
|
await self.pacman(args)
|
lib.Distro, ExecContext: Add classes, refactor lib.distro
The code below lib.distro, as left behind by the previous commit, is
geared towards being directly used as a command-line API. This commit
introduces the abstract base class Distro, a proxy for
distribution-specific interactions. The proxy abstracts distro
specifics into an API with proper method prototypes, not
argparse.Namespace contents, and can thus be more easily driven by
arbitrary code.
The Distro class is initialized with a member variable of type
ExecContext, another new class introduced by this commit. It is
designed to abstract the communication channel to the distribution
instance. Currently only one specialization exists, Local, which
interacts with the distribution and root file system it is running
in, but is planned to be subclassed to support interaction via SSH,
serial, chroot, or chains thereof.
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-03-05 17:33:52 +01:00
|
|
|
|
|
|
|
|
async def _delete(self, names: Iterable[str]) -> None:
|
|
|
|
|
raise NotImplementedError('distro delete not yet implemented for Arch-like distributions')
|
|
|
|
|
|
|
|
|
|
async def _pkg_files(self, name: str) -> Iterable[str]:
|
|
|
|
|
raise NotImplementedError('distro pkg ls yet implemented for Arch-like distributions')
|