From b15137098b7b294daecda3bd560c0026fecedec1 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 3 Apr 2024 17:55:11 +0300 Subject: [PATCH] Fix for invalid compare versions --- ChangeLog.txt | 5 ++++- slpkg/upgrade.py | 20 ++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 9c80acbb..c8ce6a18 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,6 @@ ## slpkg - ChangeLog -### 5.0.4 - 02/04/2024 +### 5.0.4 - 03/04/2024 - Updated: * Updated to ignore blacklist installed packages * Updated progress bar spinners @@ -8,6 +8,9 @@ - Removed: * python3-progress dependency +- Bugfixes: + * Fixed compare invalid packages version + ### 5.0.3 - 01/04/2024 - Updated: * Updated for slpkg_new-configs and (D)iff command (Thanks to Marav) diff --git a/slpkg/upgrade.py b/slpkg/upgrade.py index a9d36d59..05a082fb 100644 --- a/slpkg/upgrade.py +++ b/slpkg/upgrade.py @@ -63,15 +63,6 @@ class Upgrade(Configs): if name not in self.installed_names: yield name - # def is_package_upgradeable(self, installed: str) -> bool: - # """ Returns True for upgradeable packages. """ - # name: str = self.utils.split_package(installed)['name'] - # if self.data.get(name): - # repo_package: str = self.data[name]['package'] - # - # if installed != repo_package[:-4]: - # return True - def is_package_upgradeable(self, installed: str) -> bool: """ Returns True for upgradeable packages. """ inst_name: str = self.utils.split_package(installed)['name'] @@ -87,13 +78,18 @@ class Upgrade(Configs): if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build): return True except InvalidVersion as err: + # Different options to compare packages. repo_package: str = self.data[inst_name]['package'] - if installed != repo_package[:-4]: + if repo_version > inst_version: # Try to compare the strings. return True - elif installed == repo_package[:-4]: + elif repo_version == inst_version and int(repo_build) > int(inst_build): + return True + elif installed != repo_package[:-4]: # Add the package if a new one on the repository. + return True + elif installed == repo_package[:-4]: # Not new packages in the repository. return False self._write_log_file(installed, inst_name, err) - return False + return False def _write_log_file(self, installed: str, name: str, err: InvalidVersion) -> None: