Updated for naming

This commit is contained in:
Dimitris Zlatanidis 2023-05-09 21:24:49 +03:00
parent 8dd3b365b2
commit e6e08b87f0

View file

@ -35,39 +35,39 @@ class Upgrade(Configs):
# Returns the matched packages between two lists.
packages: tuple = tuple(set(self.utils.installed_packages.keys()) & set(self.data.keys()))
for pkg in packages:
if self.is_package_upgradeable(pkg):
yield pkg
for package in packages:
if self.is_package_upgradeable(package):
yield package
def is_package_upgradeable(self, name: str) -> bool:
""" Compares version of packages and returns the maximum. """
repo_version = repo_build = '0'
inst_version = inst_build = '0'
repo_package_version = repo_package_build = '0'
inst_package_version = inst_package_build = '0'
inst_package: str = self.utils.is_package_installed(name)
if inst_package and inst_package.endswith(self.repos.repositories[self.repository][6]):
inst_version: str = self.utils.split_binary_pkg(inst_package)[1]
inst_build: str = self.utils.split_binary_pkg(inst_package)[3]
inst_package_version: str = self.utils.split_binary_pkg(inst_package)[1]
inst_package_build: str = self.utils.split_binary_pkg(inst_package)[3]
if self.is_binary and self.data.get(name):
repo_version: str = self.data[name][0]
repo_package_version: str = self.data[name][0]
repo_package: str = self.data[name][1]
repo_build: str = self.utils.split_binary_pkg(repo_package)[3]
repo_package_build: str = self.utils.split_binary_pkg(repo_package)[3]
else:
repo_version: str = self.data[name][2]
repo_package_version: str = self.data[name][2]
repo_location: str = self.data[name][0]
repo_build: str = self.utils.read_slackbuild_build_tag(
repo_package_build: str = self.utils.read_slackbuild_build_tag(
name, repo_location, self.repository)
repo_pkg: str = f'{name}-{repo_version}'
inst_pkg: str = f'{name}-{inst_version}'
repository_package: str = f'{name}-{repo_package_version}'
installed_package: str = f'{name}-{inst_package_version}'
try:
if parse(repo_pkg) > parse(inst_pkg):
if parse(repository_package) > parse(installed_package):
return True
if (parse(repo_pkg) == parse(inst_pkg)
and parse(repo_build) > parse(inst_build)):
if (parse(repository_package) == parse(installed_package)
and parse(repo_package_build) > parse(inst_package_build)):
return True
except InvalidVersion:
@ -75,13 +75,13 @@ class Upgrade(Configs):
logger.exception(f'{self.__class__.__name__}: '
f'{self.__class__.is_package_upgradeable.__name__}: '
f'{self.repos.repositories[self.repository][6]}, '
f'{repo_pkg=}, {inst_pkg=}, {repo_pkg > inst_pkg}, '
f'{repo_pkg == inst_pkg and repo_build > inst_build}')
f'{repository_package=}, {installed_package=}, {repository_package > installed_package}, '
f'{repository_package == installed_package and repo_package_build > inst_package_build}')
if repo_pkg > inst_pkg:
if repository_package > installed_package:
return True
if repo_pkg == inst_pkg and repo_build > inst_build:
if repository_package == installed_package and repo_package_build > inst_package_build:
return True
return False