Fix pacman module not uninstalling packages
This commit is contained in:
parent
8798bb24a6
commit
1b5eb8c537
1 changed files with 14 additions and 8 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
|
from subprocess import CalledProcessError
|
||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
from rich.markup import escape
|
from rich.markup import escape
|
||||||
|
|
@ -82,17 +83,22 @@ class Pacman(Module):
|
||||||
def _install_packages(self, packages: set[str]) -> None:
|
def _install_packages(self, packages: set[str]) -> None:
|
||||||
if self.orchestrator.dry_run:
|
if self.orchestrator.dry_run:
|
||||||
return
|
return
|
||||||
if not packages:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
if packages:
|
||||||
self._pacman_execute("-S", "--needed", *sorted(packages))
|
self._pacman_execute("-S", "--needed", *sorted(packages))
|
||||||
self._pacman_execute("-D", "--asexplicit", *sorted(packages))
|
self._pacman_execute("-D", "--asexplicit", *sorted(packages))
|
||||||
|
|
||||||
def _uninstall_packages(self, packages: set[str]) -> None:
|
def _uninstall_packages(self, packages: set[str]) -> None:
|
||||||
if self.orchestrator.dry_run:
|
if self.orchestrator.dry_run:
|
||||||
return
|
return
|
||||||
if not packages:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
if packages:
|
||||||
self._pacman_execute("-D", "--asdeps", *sorted(packages))
|
self._pacman_execute("-D", "--asdeps", *sorted(packages))
|
||||||
self._pacman_execute("-Rsn", *self._pacman_capture("-Qqdt").splitlines())
|
|
||||||
|
try:
|
||||||
|
to_remove = self._pacman_capture("-Qqdt").splitlines()
|
||||||
|
except CalledProcessError:
|
||||||
|
return # pacman returns nonzero exit code if the query is empty
|
||||||
|
|
||||||
|
if to_remove:
|
||||||
|
self._pacman_execute("-Rsn", *to_remove)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue