From a6f8021150eff91d2bf041ff28cc3a932f8c6597 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 20 Aug 2023 13:33:49 +0200 Subject: [PATCH] `PackageManager` has both `install` and `uninstall`. --- platypush/install/docker/alpine.Dockerfile | 1 + platypush/utils/manifest.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/platypush/install/docker/alpine.Dockerfile b/platypush/install/docker/alpine.Dockerfile index 742614f191..e1e6016b72 100644 --- a/platypush/install/docker/alpine.Dockerfile +++ b/platypush/install/docker/alpine.Dockerfile @@ -6,6 +6,7 @@ WORKDIR /var/lib/platypush ARG DOCKER_CTX=1 ENV DOCKER_CTX=1 +RUN apk update RUN /install/platypush/install/scripts/alpine/install.sh RUN cd /install && pip install -U --no-input --no-cache-dir . RUN rm -rf /install diff --git a/platypush/utils/manifest.py b/platypush/utils/manifest.py index 0be8314113..0ab2ed8001 100644 --- a/platypush/utils/manifest.py +++ b/platypush/utils/manifest.py @@ -55,8 +55,10 @@ class PackageManager: executable: str """ The executable name. """ - command: Iterable[str] = field(default_factory=tuple) - """ The command to execute, as a sequence of strings. """ + install: Iterable[str] = field(default_factory=tuple) + """ The install command, as a sequence of strings. """ + uninstall: Iterable[str] = field(default_factory=tuple) + """ The uninstall command, as a sequence of strings. """ class PackageManagers(Enum): @@ -66,17 +68,20 @@ class PackageManagers(Enum): APK = PackageManager( executable='apk', - command=('apk', 'add', '--update', '--no-interactive', '--no-cache'), + install=('apk', 'add', '--update', '--no-interactive', '--no-cache'), + uninstall=('apk', 'del', '--no-interactive'), ) APT = PackageManager( executable='apt', - command=('apt', 'install', '-y'), + install=('apt', 'install', '-y'), + uninstall=('apt', 'remove', '-y'), ) PACMAN = PackageManager( executable='pacman', - command=('pacman', '-S', '--noconfirm'), + install=('pacman', '-S', '--noconfirm'), + uninstall=('pacman', '-R', '--noconfirm'), ) @classmethod @@ -90,7 +95,7 @@ class PackageManagers(Enum): if not pkg_manager: raise ValueError(f'Unknown package manager: {name}') - return pkg_manager.value.command + return pkg_manager.value.install @classmethod def scan(cls) -> Optional["PackageManagers"]: @@ -221,7 +226,7 @@ class Dependencies: yield ' '.join( [ *(['sudo'] if wants_sudo else []), - *pkg_manager.value.command, + *pkg_manager.value.install, *sorted(self.packages), # type: ignore ] )