Added view missing deps

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2024-05-10 22:09:15 +03:00
parent 1beae052e2
commit fd66fb24f8
7 changed files with 75 additions and 44 deletions

View file

@ -1,6 +1,9 @@
## slpkg - ChangeLog
### 5.0.8 - 08/05/2024
### 5.0.8 - 10/05/2024
- Added:
* Added to view packages with missing dependencies by the repository (Thanks to rizitis)
- Updated:
* Moved configs NEW_PACKAGES and REMOVE_PACKAGES to the repositories.toml file

View file

@ -74,6 +74,7 @@ class Packages(Configs): # pylint: disable=[R0902]
self.clean_the_main_slackbuilds()
self.add_main_packages_to_install_order()
self.check_for_skipped()
self.view.missing_dependencies(self.install_order)
self.view.install_upgrade_packages(self.packages, self.dependencies, self.mode)
self.view.question()

View file

@ -64,7 +64,6 @@ class InstallData(Configs):
data: dict = {}
cache: list = []
names: list = []
sbo_tags: list = [
'SLACKBUILD NAME:',
'SLACKBUILD LOCATION:',
@ -82,10 +81,6 @@ class InstallData(Configs):
self.repos.repositories[repo]['slackbuilds_txt']).read_text(
encoding='utf-8').splitlines()
for line in slackbuilds_txt:
if line.startswith(sbo_tags[0]):
names.append(line.replace(sbo_tags[0], '').strip())
for i, line in enumerate(slackbuilds_txt, 1):
for tag in sbo_tags:
if line.startswith(tag):
@ -97,7 +92,6 @@ class InstallData(Configs):
name: str = cache[0]
version: str = cache[3]
location: str = cache[1].split('/')[1]
requires: list = [item for item in cache[8].split() if item in names]
data[name] = {
'location': location,
@ -107,7 +101,7 @@ class InstallData(Configs):
'download64': cache[5].split(),
'md5sum': cache[6].split(),
'md5sum64': cache[7].split(),
'requires': requires,
'requires': cache[8].split(),
'description': cache[9]
}
@ -162,7 +156,6 @@ class InstallData(Configs):
build: str = ''
arch: str = ''
requires: list = []
names: list = []
full_requires: bool = False
pkg_tag = [
'PACKAGE NAME:',
@ -180,12 +173,6 @@ class InstallData(Configs):
checksums_md5: list = self.utils.read_text_file(path_checksums)
for line in packages_txt:
if line.startswith(pkg_tag[0]):
package: str = line.replace(pkg_tag[0], '').strip()
name: str = self.utils.split_package(package)['name']
names.append(name)
for line in checksums_md5:
line = line.strip()
if line.endswith(('.txz', '.tgz')):
@ -232,9 +219,9 @@ class InstallData(Configs):
deps.append(dep[1])
else:
deps.extend(dep)
requires: list = [item for item in list(set(deps)) if item in names]
requires: list = list(set(deps))
else:
requires: list = [item for item in required.split(',') if item in names]
requires: list = required.split(',')
if line.startswith(pkg_tag[5]):
package_description = line.replace(pkg_tag[5], '').strip()

View file

@ -5,30 +5,44 @@
from slpkg.utilities import Utilities
def resolve_requires(data: dict, name: str, flags: list) -> tuple:
""" Resolve dependencies.
class Requires:
""" Creates a tuple of dependencies with
the right order to install. """
__slots__ = (
'data', 'name', 'flags', 'utils', 'option_for_resolve_off'
)
Args:
data (dict): Repository data.
name (str): Slackbuild name.
flags (list): List of options.
def __init__(self, data: dict, name: str, flags: list):
self.data: dict = data
self.name: str = name
self.utils = Utilities()
Returns:
tuple: Description
"""
dependencies: tuple = tuple()
utils = Utilities()
self.option_for_resolve_off: bool = self.utils.is_option(
('-O', '--resolve-off'), flags)
def resolve(self) -> tuple:
""" Resolve the dependencies. """
dependencies: tuple = ()
if not self.option_for_resolve_off:
requires: list[str] = self.remove_deps(self.data[self.name]['requires'])
if not utils.is_option(('-O', '--resolve-off'), flags):
requires: list[str] = data[name]['requires']
for require in requires:
sub_requires: list[str] = data[require]['requires']
sub_requires: list[str] = self.data[require]['requires']
for sub in sub_requires:
if sub not in requires:
requires.append(sub)
requires.reverse()
dependencies: tuple = tuple(dict.fromkeys(requires))
return dependencies
def remove_deps(self, requires: list) -> list:
"""Remove requirements that not in the repository.
Args:
requires (list): List of requires.
Returns:
list: List of packages name.
"""
return [req for req in requires if req in self.data]

View file

@ -23,7 +23,7 @@ from slpkg.views.asciibox import AsciiBox
from slpkg.repositories import Repositories
from slpkg.multi_process import MultiProcess
from slpkg.views.view_process import ViewProcess
from slpkg.sbos.dependencies import resolve_requires
from slpkg.sbos.dependencies import Requires
class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
@ -98,7 +98,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
""" Creates the package dependencies list.
"""
for slackbuild in self.slackbuilds:
dependencies: tuple = resolve_requires(self.data, slackbuild, self.flags)
dependencies: tuple = Requires(self.data, slackbuild, self.flags).resolve()
for dependency in dependencies:
self.dependencies.append(dependency)
@ -262,7 +262,7 @@ class Slackbuilds(Configs): # pylint: disable=[R0902,R0904]
deps: dict = {}
deps_logs: dict = {}
installed_requires: list = []
requires: tuple = resolve_requires(self.data, name, self.flags)
requires: tuple = Requires(self.data, name, self.flags).resolve()
# Verify for installation.
for req in requires:
if self.utils.is_package_installed(req):

View file

@ -6,7 +6,7 @@ from slpkg.configs import Configs
from slpkg.utilities import Utilities
from slpkg.views.asciibox import AsciiBox
from slpkg.repositories import Repositories
from slpkg.sbos.dependencies import resolve_requires
from slpkg.sbos.dependencies import Requires
from slpkg.binaries.required import Required
@ -31,7 +31,7 @@ class Tracking(Configs): # pylint: disable=[R0902]
self.hl: str = self.ascii.horizontal_line
self.package_version: str = ''
self.package_dependency_version: str = ''
self.package_requires: tuple = ()
self.package_requires: list = []
self.package_line: str = ''
self.require_line: str = ''
self.count_requires: int = 0
@ -105,6 +105,9 @@ class Tracking(Configs): # pylint: disable=[R0902]
require (str): Require name.
"""
self.require_line: str = f'{self.cyan}{require}{self.endc}'
if require not in self.data:
self.require_line: str = f'{self.red}{require}{self.endc}'
if self.option_for_pkg_version:
self.set_package_dependency_version(require)
self.require_line: str = (f'{self.cyan}{require:<{self.require_length}}{self.endc}'
@ -136,11 +139,17 @@ class Tracking(Configs): # pylint: disable=[R0902]
Args:
package (str): Package name.
"""
if self.repository not in [self.repos.sbo_repo_name, self.repos.ponce_repo_name]:
self.package_requires: tuple = Required(self.data, package, self.flags).resolve()
self.package_requires: list = list(Required(self.data, package, self.flags).resolve())
else:
self.package_requires: tuple = resolve_requires(self.data, package, self.flags)
self.package_requires: list = list(Requires(self.data, package, self.flags).resolve())
if self.package_requires:
requires: list = self.data[package]['requires']
for req in requires:
if req not in self.data:
self.package_requires.append(req)
self.require_length: int = max(len(name) for name in self.package_requires)
def view_summary_of_tracking(self, package: str) -> None:

View file

@ -331,6 +331,23 @@ class View(Configs): # pylint: disable=[R0902]
f"{self.data[name]['package']} {failed}{' ' * 17}")
print()
def missing_dependencies(self, packages: list) -> None:
""" Checks for missing dependencies.
"""
not_found: dict = {}
for package in packages:
requires: list = self.data[package]['requires']
for req in requires:
if req not in self.data:
not_found[package] = [req for req in requires if req not in self.data]
if not_found:
# print('+' + (self.columns - 1) * '=')
print('Packages with missing dependencies:')
# print('+' + (self.columns - 1) * '=')
for pkg, deps in not_found.items():
print(f"> {self.cyan}{pkg}{self.endc}: Requires: {self.red}{', '.join(deps)}{self.endc}")
print()
def question(self, message: str = 'Do you want to continue?') -> None:
""" View a question.