From d45adc6465aabc244d65030c6a3571c4369a588b Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 1 Apr 2024 19:40:46 +0300 Subject: [PATCH] Updated to ignore blacklist installed packages --- ChangeLog.txt | 4 ++++ slpkg/checks.py | 3 +-- slpkg/utilities.py | 9 ++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0f7ae6da..816a69d4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,9 @@ ## slpkg - ChangeLog +### 5.0.4 - 01/04/2024 +- Updated: + * Updated to ignore blacklist installed packages + ### 5.0.3 - 01/04/2024 - Updated: * Updated for slpkg_new-configs and (D)iff command (Thanks to Marav) diff --git a/slpkg/checks.py b/slpkg/checks.py index d4359418..f272687d 100644 --- a/slpkg/checks.py +++ b/slpkg/checks.py @@ -30,10 +30,9 @@ class Check(Configs): def is_package_installed(self, packages: list) -> None: """ Checking for installed packages. """ not_found: list = [] - blacklist_packages: list = self.utils.ignore_packages(packages) for pkg in packages: - if not self.utils.is_package_installed(pkg) or pkg in blacklist_packages: + if not self.utils.is_package_installed(pkg): not_found.append(pkg) if not_found: diff --git a/slpkg/utilities.py b/slpkg/utilities.py index ce14fa7f..61b417ac 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -25,21 +25,28 @@ class Utilities(Configs): def is_package_installed(self, name: str) -> str: """ Returns the installed package binary. """ installed_package: Generator = self.log_packages.glob(f'{name}*') + for installed in installed_package: inst_name: str = self.split_package(installed.name)['name'] - if inst_name == name: + if inst_name == name and inst_name not in self.ignore_packages([inst_name]): return installed.name return '' def all_installed(self) -> dict: """ Return all installed packages from /val/log/packages folder. """ installed_packages: dict = {} + for file in self.log_packages.glob('*'): name: str = self.split_package(file.name)['name'] if not name.startswith('.'): installed_packages[name] = file.name + blacklist_packages: list = self.ignore_packages(list(installed_packages.keys())) + if blacklist_packages: + for black in blacklist_packages: + del installed_packages[black] + return installed_packages @staticmethod