Fix for invalid compare versions

This commit is contained in:
Dimitris Zlatanidis 2024-04-03 17:55:11 +03:00
parent e0b835de12
commit b15137098b
2 changed files with 12 additions and 13 deletions

View file

@ -1,6 +1,6 @@
## slpkg - ChangeLog ## slpkg - ChangeLog
### 5.0.4 - 02/04/2024 ### 5.0.4 - 03/04/2024
- Updated: - Updated:
* Updated to ignore blacklist installed packages * Updated to ignore blacklist installed packages
* Updated progress bar spinners * Updated progress bar spinners
@ -8,6 +8,9 @@
- Removed: - Removed:
* python3-progress dependency * python3-progress dependency
- Bugfixes:
* Fixed compare invalid packages version
### 5.0.3 - 01/04/2024 ### 5.0.3 - 01/04/2024
- Updated: - Updated:
* Updated for slpkg_new-configs and (D)iff command (Thanks to Marav) * Updated for slpkg_new-configs and (D)iff command (Thanks to Marav)

View file

@ -63,15 +63,6 @@ class Upgrade(Configs):
if name not in self.installed_names: if name not in self.installed_names:
yield name 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: def is_package_upgradeable(self, installed: str) -> bool:
""" Returns True for upgradeable packages. """ """ Returns True for upgradeable packages. """
inst_name: str = self.utils.split_package(installed)['name'] 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): if parse(repo_version) == parse(inst_version) and int(repo_build) > int(inst_build):
return True return True
except InvalidVersion as err: except InvalidVersion as err:
# Different options to compare packages.
repo_package: str = self.data[inst_name]['package'] 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 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 return False
self._write_log_file(installed, inst_name, err) self._write_log_file(installed, inst_name, err)
return False
return False return False
def _write_log_file(self, installed: str, name: str, err: InvalidVersion) -> None: def _write_log_file(self, installed: str, name: str, err: InvalidVersion) -> None: