Clean up dependencies

This commit is contained in:
Dimitris Zlatanidis 2022-12-24 21:59:06 +02:00
parent 8e65e88602
commit f0efbf3c02

View file

@ -7,10 +7,11 @@ from dialog import Dialog
from distutils.version import LooseVersion
from slpkg.configs import Configs
from slpkg.views.version import Version
from slpkg.dependencies import Requires
from slpkg.queries import SBoQueries
from slpkg.utilities import Utilities
from slpkg.blacklist import Blacklist
from slpkg.views.version import Version
locale.setlocale(locale.LC_ALL, '')
@ -29,6 +30,7 @@ class Upgrade:
""" Compares version of packages and returns the maximum. """
repo_packages = SBoQueries('').sbos()
black = Blacklist().get()
upgrade, requires = [], []
for pkg in os.listdir(self.configs.log_packages):
inst_pkg_name = self.utils.split_installed_pkg(pkg)[0]
@ -41,7 +43,16 @@ class Upgrade:
repo_ver = SBoQueries(inst_pkg_name).version()
if LooseVersion(repo_ver) > LooseVersion(installed_ver):
yield inst_pkg_name
upgrade.append(inst_pkg_name)
# Creating a list with requires
for pkg in upgrade:
requires += Requires(pkg).resolve()
# Clean the packages if they are dependencies
for pkg in upgrade:
if pkg not in requires:
yield pkg
def packages(self):
""" Choose packages for upgrade. """
@ -52,7 +63,7 @@ class Upgrade:
pkg = self.utils.is_installed(package)
inst_ver = self.utils.split_installed_pkg(pkg)[1]
repo_ver = SBoQueries(package).version()
choices += [(package, f'{inst_ver} -> {repo_ver}', False)]
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
code, tags = self.d.checklist(f'There are {len(choices)} packages for upgrade:',
title='Choose packages you want to upgrade',