Fixed for upgradable

This commit is contained in:
Dimitris Zlatanidis 2023-03-29 17:19:58 +03:00
parent 3b308d9c28
commit 23c8992032
3 changed files with 16 additions and 5 deletions

View file

@ -222,7 +222,7 @@ class Packages(Configs):
repo_ver: str = BinQueries(package, self.repo).version()
help_text: str = f'Package: {package}-{repo_ver}'
upgradable: str = self.utils.is_package_upgradeable(package)
upgradable: str = self.utils.is_package_upgradeable(package, self.flags, self.repo)
if self.mode == 'upgrade' and upgradable:
status: bool = True

View file

@ -36,7 +36,7 @@ class Upgrade(Configs):
if inst_pkg_name in repo_packages:
if self.utils.is_package_upgradeable(inst_pkg_name):
if self.utils.is_package_upgradeable(inst_pkg_name, self.flags, self.repo):
if not self.utils.is_option(self.flag_bin_repository, self.flags):
requires += Requires(inst_pkg_name).resolve()

View file

@ -13,6 +13,7 @@ from slpkg.configs import Configs
from slpkg.blacklist import Blacklist
from slpkg.sbos.queries import SBoQueries
from slpkg.repositories import Repositories
from slpkg.binaries.queries import BinQueries
class Utilities:
@ -30,6 +31,7 @@ class Utilities:
self.endc: str = self.color['endc']
self.red: str = self.color['red']
self.bred: str = f'{self.bold}{self.red}'
self.flag_bin_repository: list = ['-B=', '--bin-repo=']
self.installed_packages: list = list(self.all_installed())
self.installed_package_names: list = list(self.all_installed_names())
@ -109,14 +111,23 @@ class Utilities:
time.strftime(f'[{self.cyan}%H:%M:%S{self.endc}]',
time.gmtime(elapsed_time)))
def is_package_upgradeable(self, package: str) -> Any:
def is_package_upgradeable(self, package: str, flags=None, repo='*') -> Any:
""" Checks if the package is installed and if it is upgradeable, returns true. """
installed_version: str = '0'
installed = self.is_package_installed(package)
repository_version = str(SBoQueries(package).version())
repo_build_tag: str = self.read_sbo_build_tag(package)
inst_build_tag: str = self.split_binary_pkg(installed)[3]
if flags is None:
flags: list = []
if self.is_option(self.flag_bin_repository, flags):
repository_version = BinQueries(package, repo).version()
repo_package: str = BinQueries(package, repo).package_bin()
repo_build_tag: str = self.split_binary_pkg(repo_package)[3]
else:
repository_version = SBoQueries(package).version()
repo_build_tag: str = self.read_sbo_build_tag(package)
if not repo_build_tag:
repo_build_tag: str = ''