Updated for install binary

This commit is contained in:
Dimitris Zlatanidis 2023-05-08 12:20:19 +03:00
parent aed34ab817
commit 25d1918d14

View file

@ -63,21 +63,20 @@ class Packages(Configs):
self.packages: list = self.utils.apply_package_pattern(data, packages)
def execute(self) -> None:
self.dependencies()
self.creating_dependencies_list()
self.view_message.install_upgrade_packages(self.packages, self.packages_requires, self.mode)
self.view_message.question()
start: float = time.time()
self.download()
self.checksum()
self.crating_the_package_urls_list()
self.checksum_binary_packages()
self.install_packages()
elapsed_time: float = time.time() - start
self.utils.finished_time(elapsed_time)
def dependencies(self):
""" Creating the dependencies list and the order for install. """
def creating_dependencies_list(self):
if not self.option_for_resolve_off:
for pkg in self.packages:
@ -92,7 +91,7 @@ class Packages(Configs):
requires = list(OrderedDict.fromkeys(self.packages_requires))
if requires:
self.packages_requires = self.choose_dependencies(requires)
self.packages_requires = self.choose_dependencies_for_install(requires)
# Clean up the main packages if they were selected for dependencies.
for dep in self.packages_requires:
@ -101,31 +100,34 @@ class Packages(Configs):
self.install_order = [*self.packages_requires, *self.packages]
def download(self) -> None:
""" Download packages from the repositories. """
pkg_urls: list = []
def crating_the_package_urls_list(self) -> None:
package_urls: list = []
for pkg in self.install_order:
if self.continue_install(pkg):
if self.continue_to_install(pkg):
package: str = self.data[pkg][1]
mirror: str = self.data[pkg][2]
location: str = self.data[pkg][3]
pkg_urls.append(f'{mirror}{location}/{package}')
package_urls.append(f'{mirror}{location}/{package}')
self.binary_packages.append(package)
self.utils.remove_file_if_exists(self.tmp_slpkg, package)
else:
version: str = self.data[pkg][0]
self.view_message.view_skipping_packages(pkg, version)
installed_package: str = self.utils.is_package_installed(pkg)
installed_version: str = self.utils.split_binary_pkg(installed_package)[1]
self.view_message.view_skipping_packages(pkg, installed_version)
if pkg_urls:
down = Downloader(self.tmp_slpkg, pkg_urls, self.flags)
self.download_the_binary_packages(package_urls)
def download_the_binary_packages(self, package_urls: list) -> None:
if package_urls:
down = Downloader(self.tmp_slpkg, package_urls, self.flags)
down.download()
print()
def continue_install(self, name) -> bool:
def continue_to_install(self, name) -> bool:
""" Skip installed package when the option --skip-installed is applied
and continue to install if the package is upgradable or the --reinstall option
applied.
@ -141,8 +143,7 @@ class Packages(Configs):
return False
def checksum(self) -> None:
""" Packages checksums. """
def checksum_binary_packages(self) -> None:
md5 = Md5sum(self.flags)
for package in self.binary_packages:
name: str = self.utils.split_binary_pkg(Path(package).stem)[0]
@ -158,7 +159,6 @@ class Packages(Configs):
if (self.option_for_reinstall or self.utils.is_package_installed(package)
or self.mode == 'upgrade'):
message: str = f'{self.cyan}Upgrade{self.endc}'
slack_command: str = self.reinstall
@ -190,7 +190,6 @@ class Packages(Configs):
# Terminate process 2 if process 1 finished
if not p1.is_alive():
if p1.exitcode != 0:
done: str = f'{self.bred}Failed: {self.endc}{self.process_message}.'
@ -205,7 +204,7 @@ class Packages(Configs):
else:
self.utils.process(command, self.stderr, self.stdout)
def choose_dependencies(self, dependencies: list) -> list:
def choose_dependencies_for_install(self, dependencies: list) -> list:
""" Choose packages for install. """
height: int = 10
width: int = 70
@ -229,7 +228,6 @@ class Packages(Configs):
choices.extend([(package, repo_ver, status, help_text)])
text: str = f'There are {len(choices)} dependencies:'
code, tags = self.dialogbox.checklist(text, dependencies, title, height,
width, list_height, choices)