Updated for install

This commit is contained in:
Dimitris Zlatanidis 2023-05-11 19:30:34 +03:00
parent 6e03e29c6a
commit 4807381029

View file

@ -40,9 +40,9 @@ class Packages(Configs):
self.stderr = None
self.stdout = None
self.process_message: str = ''
self.process_message: str = str()
self.packages_requires: list = []
self.dependencies: list = []
self.install_order: list = []
self.binary_packages: list = []
@ -61,9 +61,15 @@ class Packages(Configs):
self.packages: list = self.utils.apply_package_pattern(data, packages)
def execute(self) -> None:
# self.creating_dependencies_list()
self.creating_dependencies_list()
self.remove_duplicate_from_dependencies_list()
self.choose_package_dependencies()
self.add_dependencies_to_install_order()
self.clean_the_main_slackbuilds()
self.add_main_packages_to_install_order()
self.view_message.install_upgrade_packages(self.packages, self.packages_requires, self.mode)
self.view_message.install_upgrade_packages(self.packages, self.dependencies, self.mode)
self.view_message.question()
start: float = time.time()
@ -76,25 +82,30 @@ class Packages(Configs):
def creating_dependencies_list(self) -> None:
if not self.option_for_resolve_off:
for pkg in self.packages:
# Skip installed package when the option --skip-installed is applied.
if self.option_for_skip_installed and self.utils.is_package_installed(pkg):
continue
for package in self.packages:
dependencies: tuple = Required(self.data, package).resolve()
self.packages_requires.extend(Required(self.data, pkg).resolve())
for dependency in dependencies:
# Skip installed package when the option --skip-installed is applied.
if self.option_for_skip_installed and self.utils.is_package_installed(dependency):
continue
# Clean dependencies from the dependencies list if already added with main packages.
requires: list = list(OrderedDict.fromkeys(self.packages_requires))
self.dependencies.append(dependency)
if requires:
self.packages_requires = self.choose_dependencies_for_install(requires)
def remove_duplicate_from_dependencies_list(self) -> None:
if self.dependencies:
self.dependencies: list = list(OrderedDict.fromkeys(self.dependencies))
# Clean up the main packages if they were selected for dependencies.
for dep in self.packages_requires:
if dep in self.packages:
self.packages.remove(dep)
def add_dependencies_to_install_order(self) -> None:
self.install_order.extend(self.dependencies)
self.install_order: list = [*self.packages_requires, *self.packages]
def clean_the_main_slackbuilds(self) -> None:
for dependency in self.dependencies:
if dependency in self.packages:
self.packages.remove(dependency)
def add_main_packages_to_install_order(self) -> None:
self.install_order.extend(self.packages)
def crating_the_package_urls_list(self) -> None:
package_urls: list = []
@ -197,34 +208,30 @@ class Packages(Configs):
else:
self.utils.process(command, self.stderr, self.stdout)
def choose_dependencies_for_install(self, dependencies: list) -> list:
""" Choose packages for install. """
height: int = 10
width: int = 70
list_height: int = 0
choices: list = []
title: str = ' Choose dependencies you want to install '
def choose_package_dependencies(self) -> None:
if self.dependencies:
height: int = 10
width: int = 70
list_height: int = 0
choices: list = []
title: str = ' Choose dependencies you want to install '
for package in dependencies:
status: bool = True
repo_ver: str = self.data[package]['version']
help_text: str = f'Package: {package} {repo_ver}'
installed: str = self.utils.is_package_installed(package)
if installed:
status: bool = False
if self.option_for_reinstall:
for package in self.dependencies:
status: bool = True
repo_ver: str = self.data[package]['version']
help_text: str = f'Package: {package} {repo_ver}'
installed: str = self.utils.is_package_installed(package)
choices.extend([(package, repo_ver, status, help_text)])
if installed:
status: bool = False
text: str = f'There are {len(choices)} dependencies:'
code, tags = self.dialogbox.checklist(text, dependencies, title, height,
width, list_height, choices)
if not code:
return dependencies
if self.option_for_reinstall:
status: bool = True
os.system('clear')
choices.extend([(package, repo_ver, status, help_text)])
return tags
text: str = f'There are {len(choices)} dependencies:'
code, self.dependencies = self.dialogbox.checklist(
text, self.dependencies, title, height, width, list_height, choices)
os.system('clear')