mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Updated for resolve off
This commit is contained in:
parent
35b8e11a63
commit
1dd6cd1ddb
5 changed files with 65 additions and 58 deletions
|
@ -50,9 +50,6 @@ class Packages(Configs):
|
|||
self.option_for_skip_installed: bool = self.utils.is_option(
|
||||
('-k', '--skip-installed'), flags)
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
self.packages: list = self.utils.apply_package_pattern(data, packages)
|
||||
|
||||
def execute(self) -> None:
|
||||
|
@ -78,14 +75,13 @@ class Packages(Configs):
|
|||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def creating_dependencies_list(self) -> None:
|
||||
if not self.option_for_resolve_off:
|
||||
print('\rResolving dependencies... ', end='')
|
||||
for package in self.packages:
|
||||
dependencies: tuple = Required(self.data, package).resolve()
|
||||
print('\rResolving dependencies... ', end='')
|
||||
for package in self.packages:
|
||||
dependencies: tuple = Required(self.data, package, self.flags).resolve()
|
||||
|
||||
for dependency in dependencies:
|
||||
self.dependencies.append(dependency)
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
for dependency in dependencies:
|
||||
self.dependencies.append(dependency)
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
|
||||
def remove_duplicate_from_dependencies_list(self) -> None:
|
||||
if self.dependencies:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
from typing import Generator
|
||||
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.repositories import Repositories
|
||||
|
||||
|
||||
|
@ -10,14 +11,16 @@ class Required:
|
|||
""" Creates a tuple of dependencies with
|
||||
the right order to install. """
|
||||
__slots__ = (
|
||||
'data', 'name', 'repos',
|
||||
'special_repos', 'repo', 'repository_packages'
|
||||
'data', 'name', 'flags', 'repos', 'utils',
|
||||
'special_repos', 'repo', 'repository_packages',
|
||||
'option_for_resolve_off'
|
||||
)
|
||||
|
||||
def __init__(self, data: dict, name: str):
|
||||
def __init__(self, data: dict, name: str, flags: list):
|
||||
self.data: dict = data
|
||||
self.name: str = name
|
||||
self.repos = Repositories()
|
||||
self.utils = Utilities()
|
||||
|
||||
self.special_repos: list = [
|
||||
self.repos.salixos_repo_name,
|
||||
|
@ -30,28 +33,35 @@ class Required:
|
|||
self.repo: str = data[name]['repo']
|
||||
self.repository_packages: tuple = tuple(self.data.keys())
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
def resolve(self) -> tuple:
|
||||
""" Resolve the dependencies. """
|
||||
requires: list[str] = list(
|
||||
self.remove_deps(self.data[self.name]['requires'])
|
||||
)
|
||||
dependencies: tuple = ()
|
||||
if not self.option_for_resolve_off:
|
||||
requires: list[str] = list(
|
||||
self.remove_deps(self.data[self.name]['requires'])
|
||||
)
|
||||
|
||||
# Resolve dependencies for some special repos.
|
||||
if self.repo in self.special_repos:
|
||||
for require in requires:
|
||||
if require not in self.repository_packages:
|
||||
requires.remove(require)
|
||||
# Resolve dependencies for some special repos.
|
||||
if self.repo in self.special_repos:
|
||||
for require in requires:
|
||||
if require not in self.repository_packages:
|
||||
requires.remove(require)
|
||||
|
||||
else:
|
||||
for require in requires:
|
||||
sub_requires: list[str] = list(
|
||||
self.remove_deps(self.data[require]['requires'])
|
||||
)
|
||||
for sub in sub_requires:
|
||||
requires.append(sub)
|
||||
else:
|
||||
for require in requires:
|
||||
sub_requires: list[str] = list(
|
||||
self.remove_deps(self.data[require]['requires'])
|
||||
)
|
||||
for sub in sub_requires:
|
||||
requires.append(sub)
|
||||
|
||||
requires.reverse()
|
||||
return tuple(dict.fromkeys(requires))
|
||||
requires.reverse()
|
||||
dependencies: tuple = tuple(dict.fromkeys(requires))
|
||||
|
||||
return dependencies
|
||||
|
||||
def remove_deps(self, requires: list) -> Generator:
|
||||
""" Remove requires that not in the repository or blacklisted. """
|
||||
|
|
|
@ -36,12 +36,6 @@ class RemovePackages(Configs):
|
|||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
self.option_for_yes: bool = self.utils.is_option(
|
||||
('-y', '--yes'), flags)
|
||||
|
||||
def remove(self) -> None:
|
||||
self.deps_log: dict = self.utils.read_json_file(self.deps_log_file)
|
||||
self.add_packages_for_remove()
|
||||
|
|
|
@ -1,24 +1,35 @@
|
|||
#!/usr/bin/python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from slpkg.utilities import Utilities
|
||||
|
||||
|
||||
class Requires:
|
||||
""" Creates a tuple of dependencies with
|
||||
the right order to install. """
|
||||
__slots__ = ('data', 'name', 'repository_packages')
|
||||
__slots__ = (
|
||||
'data', 'name', 'flags', 'utils', 'option_for_resolve_off'
|
||||
)
|
||||
|
||||
def __init__(self, data: dict, name: str):
|
||||
def __init__(self, data: dict, name: str, flags: list):
|
||||
self.data: dict = data
|
||||
self.name: str = name
|
||||
self.repository_packages: tuple = tuple(data.keys())
|
||||
self.utils = Utilities()
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
def resolve(self) -> tuple:
|
||||
""" Resolve the dependencies. """
|
||||
requires: list[str] = self.data[self.name]['requires']
|
||||
for require in requires:
|
||||
sub_requires: list[str] = self.data[require]['requires']
|
||||
for sub in sub_requires:
|
||||
requires.append(sub)
|
||||
dependencies: tuple = ()
|
||||
if not self.option_for_resolve_off:
|
||||
requires: list[str] = self.data[self.name]['requires']
|
||||
for require in requires:
|
||||
sub_requires: list[str] = self.data[require]['requires']
|
||||
for sub in sub_requires:
|
||||
requires.append(sub)
|
||||
|
||||
requires.reverse()
|
||||
requires.reverse()
|
||||
dependencies: tuple = tuple(dict.fromkeys(requires))
|
||||
|
||||
return tuple(dict.fromkeys(requires))
|
||||
return dependencies
|
||||
|
|
|
@ -34,6 +34,7 @@ class Slackbuilds(Configs):
|
|||
self.flags: list = flags
|
||||
self.mode: str = mode
|
||||
|
||||
self.ascii = AsciiBox()
|
||||
self.errors = Errors()
|
||||
self.repos = Repositories()
|
||||
self.utils = Utilities()
|
||||
|
@ -42,7 +43,6 @@ class Slackbuilds(Configs):
|
|||
self.view = View(flags, repository, data)
|
||||
self.check_md5 = Md5sum(flags)
|
||||
self.download = Downloader(flags)
|
||||
self.ascii = AsciiBox()
|
||||
|
||||
self.sources: dict = {}
|
||||
self.install_order: list = []
|
||||
|
@ -57,9 +57,6 @@ class Slackbuilds(Configs):
|
|||
self.option_for_skip_installed: bool = self.utils.is_option(
|
||||
('-k', '--skip-installed'), flags)
|
||||
|
||||
self.option_for_resolve_off: bool = self.utils.is_option(
|
||||
('-O', '--resolve-off'), flags)
|
||||
|
||||
self.option_for_jobs: bool = self.utils.is_option(
|
||||
('-j', '--jobs'), flags)
|
||||
|
||||
|
@ -90,14 +87,13 @@ class Slackbuilds(Configs):
|
|||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def creating_dependencies_list(self) -> None:
|
||||
if not self.option_for_resolve_off:
|
||||
print('\rResolving dependencies... ', end='')
|
||||
for slackbuild in self.slackbuilds:
|
||||
dependencies: tuple = Requires(self.data, slackbuild).resolve()
|
||||
print('\rResolving dependencies... ', end='')
|
||||
for slackbuild in self.slackbuilds:
|
||||
dependencies: tuple = Requires(self.data, slackbuild, self.flags).resolve()
|
||||
|
||||
for dependency in dependencies:
|
||||
self.dependencies.append(dependency)
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
for dependency in dependencies:
|
||||
self.dependencies.append(dependency)
|
||||
print(f'{self.yellow}{self.ascii.done}{self.endc}')
|
||||
|
||||
def remove_duplicate_from_dependencies_list(self) -> None:
|
||||
self.dependencies: list = list(OrderedDict.fromkeys(self.dependencies))
|
||||
|
@ -216,7 +212,7 @@ class Slackbuilds(Configs):
|
|||
deps: dict = {}
|
||||
deps_logs: dict = {}
|
||||
installed_requires: list = []
|
||||
requires: tuple = Requires(self.data, name).resolve()
|
||||
requires: tuple = Requires(self.data, name, self.flags).resolve()
|
||||
# Verify for installation.
|
||||
for req in requires:
|
||||
if self.utils.is_package_installed(req):
|
||||
|
|
Loading…
Reference in a new issue