2026-01-27 17:36:33 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from argparse import Namespace, ArgumentParser
|
|
|
|
|
|
|
|
|
|
from .Cmd import Cmd
|
|
|
|
|
from ..CmdDistro import CmdDistro
|
|
|
|
|
|
|
|
|
|
class CmdInstall(Cmd): # export
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent: CmdDistro) -> None:
|
|
|
|
|
super().__init__(parent, 'install', help="Install the distribution's notion of available packages")
|
|
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
|
|
|
super().add_arguments(parser)
|
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
|
|
|
parser.add_argument("names", nargs="*", help="Packages to be installed")
|
2026-03-03 10:52:36 +01:00
|
|
|
parser.add_argument('--only-update', default=False, action='store_true', help='Only update the listed packages, don\'t install them')
|
2026-04-16 14:19:18 +02:00
|
|
|
parser.add_argument('-F', '--fixed-strings', action='store_true',
|
2026-04-18 12:08:00 +02:00
|
|
|
help='Don\'t expand platform.expand_macros macros in <names>')
|
2026-01-27 17:36:33 +01:00
|
|
|
|
|
|
|
|
async def _run(self, args: Namespace) -> None:
|
2026-04-18 12:08:00 +02:00
|
|
|
names = names if args.fixed_strings else self.app.distro.expand_macros(args.names)
|
2026-04-16 14:19:18 +02:00
|
|
|
return await self.distro.install(names, only_update=args.only_update)
|