Added default_os field to PackageManagers enum elements.

This is useful to determine which is the default set of scripts that
should be used by the installer depending on the detected installed
package manager.
This commit is contained in:
Fabio Manganiello 2023-08-20 21:21:37 +02:00
parent 2c46b6fe14
commit 10c0e5fcad
Signed by: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 10 additions and 2 deletions

View file

@ -1 +1 @@
pacman -S --noconfirm pacman -S --noconfirm --needed

View file

@ -55,6 +55,11 @@ class PackageManager:
executable: str executable: str
""" The executable name. """ """ The executable name. """
default_os: str
"""
The default distro whose configuration we should use if this package
manager is detected.
"""
install: Iterable[str] = field(default_factory=tuple) install: Iterable[str] = field(default_factory=tuple)
""" The install command, as a sequence of strings. """ """ The install command, as a sequence of strings. """
uninstall: Iterable[str] = field(default_factory=tuple) uninstall: Iterable[str] = field(default_factory=tuple)
@ -70,18 +75,21 @@ class PackageManagers(Enum):
executable='apk', executable='apk',
install=('apk', 'add', '--update', '--no-interactive', '--no-cache'), install=('apk', 'add', '--update', '--no-interactive', '--no-cache'),
uninstall=('apk', 'del', '--no-interactive'), uninstall=('apk', 'del', '--no-interactive'),
default_os='alpine',
) )
APT = PackageManager( APT = PackageManager(
executable='apt', executable='apt',
install=('apt', 'install', '-y'), install=('apt', 'install', '-y'),
uninstall=('apt', 'remove', '-y'), uninstall=('apt', 'remove', '-y'),
default_os='debian',
) )
PACMAN = PackageManager( PACMAN = PackageManager(
executable='pacman', executable='pacman',
install=('pacman', '-S', '--noconfirm'), install=('pacman', '-S', '--noconfirm', '--needed'),
uninstall=('pacman', '-R', '--noconfirm'), uninstall=('pacman', '-R', '--noconfirm'),
default_os='arch',
) )
@classmethod @classmethod