From 28e82b7c2fe6d85e3a8ab78eea3b364998440abc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Tue, 14 Mar 2023 10:58:09 +0200 Subject: [PATCH] Updated for sbo repository --- slpkg/install_data.py | 2 +- slpkg/slackbuild.py | 37 +++++++++---------------------------- slpkg/update_repository.py | 20 ++++++++------------ slpkg/utilities.py | 9 --------- 4 files changed, 18 insertions(+), 50 deletions(-) diff --git a/slpkg/install_data.py b/slpkg/install_data.py index fd15c83b..0237826b 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -47,7 +47,7 @@ class CreateData(Configs): cache: list = [] # init cache - print('\nCreating the database... ', end='', flush=True) + print('Creating the database... ', end='', flush=True) for i, line in enumerate(sbo_file, 1): diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index 9c8c62f6..f71ec143 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -73,7 +73,7 @@ class Slackbuilds(Configs): self.view_before_build() start: float = time.time() - self.download_slackbuilds() + self.prepare_slackbuilds_for_build() self.build_and_install() elapsed_time: float = time.time() - start @@ -139,9 +139,8 @@ class Slackbuilds(Configs): self.utils.is_package_upgradeable(sbo, self.file_pattern) or self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags)) - def download_slackbuilds(self) -> None: + def prepare_slackbuilds_for_build(self) -> None: """ Downloads files and sources. """ - sbos_urls: list = [] sources_urls: list = [] for sbo in self.install_order: @@ -150,46 +149,28 @@ class Slackbuilds(Configs): self.utils.remove_folder_if_exists(self.build_path, sbo) location: str = SBoQueries(sbo).location() + slackbuild = Path(self.build_path, sbo, f'{sbo}.SlackBuild') + # Copy slackbuilds to the build folder. if self.ponce_repo: path_ponce_repo_package = Path(self.ponce_repo_path, location, sbo) - path_build_package = Path(self.build_path, sbo) - shutil.copytree(path_ponce_repo_package, f'{self.build_path}{sbo}') - slackbuild = Path(path_build_package, f'{sbo}.SlackBuild') - os.chmod(slackbuild, 0o775) - else: - file: str = f'{sbo}{self.sbo_tar_suffix}' - self.utils.remove_file_if_exists(self.build_path, file) - sbo_url: str = f'{self.sbo_repo_url}{location}/{file}' - sbos_urls.append(sbo_url) + path_sbo_repo_package = Path(self.sbo_repo_path, location, sbo) + shutil.copytree(path_sbo_repo_package, f'{self.build_path}{sbo}') + os.chmod(slackbuild, 0o775) sources_urls += SBoQueries(sbo).sources() - urls: list = sources_urls - # Combine sbos and sources. - if not self.ponce_repo: - urls.extend(sbos_urls) - - # Download all the urls to the build folder. - down_urls = Downloader(self.build_path, urls, self.flags) + # Download the sources. + down_urls = Downloader(self.build_path, sources_urls, self.flags) down_urls.download() print() # New line here. - self.extract_sbos() self.move_sources(sources_urls) self.checksum_downloads() - def extract_sbos(self) -> None: - """ Untar all the sbo.tar.gz files. """ - if not self.ponce_repo: - for sbo in self.install_order: - file: str = f'{sbo}{self.sbo_tar_suffix}' - self.utils.untar_archive(self.build_path, file) - self.patch_sbo_tag(sbo) - def move_sources(self, sources_urls: list) -> None: """ Move the sources into the folders for build. """ for sbo, src in zip(self.install_order, sources_urls): diff --git a/slpkg/update_repository.py b/slpkg/update_repository.py index db80e5e4..239b06af 100644 --- a/slpkg/update_repository.py +++ b/slpkg/update_repository.py @@ -8,7 +8,6 @@ from multiprocessing import Process, Queue from slpkg.configs import Configs from slpkg.utilities import Utilities -from slpkg.downloader import Downloader from slpkg.install_data import CreateData from slpkg.views.views import ViewMessage from slpkg.progress_bar import ProgressBar @@ -42,7 +41,6 @@ class UpdateRepository(Configs, Utilities): def update_the_repository(self) -> None: """ Updated the sbo repository. """ - if self.update == 0: self.view.question() else: @@ -52,7 +50,8 @@ class UpdateRepository(Configs, Utilities): if not self.is_option(self.flag_generate, self.flags): print('Updating the packages list.\n') - print("Downloading the 'ponce' repository, please wait...\n") + print(f"Downloading the '{self.green}ponce{self.endc}' repository, please wait...\n") + self.delete_file(self.ponce_repo_path, self.ponce_chglog_txt) lftp_output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} ' f'{self.ponce_repo_path}', shell=True) self.process_error(lftp_output) @@ -67,21 +66,18 @@ class UpdateRepository(Configs, Utilities): os.chdir(self.ponce_repo_path) gen_output = subprocess.call(f'./gen_sbo_txt.sh > {self.ponce_txt}', shell=True) self.process_error(gen_output) - print() + print('\n') else: print('Updating the packages list.\n') + self.delete_file(self.sbo_repo_path, self.sbo_txt) self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt) - slackbuilds_txt: list = [f'{self.sbo_repo_url}{self.sbo_txt}'] - changelog_txt: list = [f'{self.sbo_repo_url}{self.sbo_chglog_txt}'] - - down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags) - down_slackbuilds.download() - - down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags) - down_sbo_changelog.download() + print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n") + lftp_output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.sbo_repo_url} ' + f'{self.sbo_repo_path}', shell=True) + self.process_error(lftp_output) self.delete_sbo_data() data = CreateData() diff --git a/slpkg/utilities.py b/slpkg/utilities.py index e2bec6cf..137eb710 100644 --- a/slpkg/utilities.py +++ b/slpkg/utilities.py @@ -3,7 +3,6 @@ import time import shutil -import tarfile from pathlib import Path from typing import Generator, Any from distutils.version import LooseVersion @@ -58,14 +57,6 @@ class Utilities: if package_name not in self.black.packages(): yield self.split_installed_pkg(file.name)[0] - @staticmethod - def untar_archive(path: str, archive: str) -> None: - """ Untar the file to the build folder. """ - tar_file = Path(path, archive) - untar = tarfile.open(tar_file) - untar.extractall(path) - untar.close() - @staticmethod def remove_file_if_exists(path: str, file: str) -> None: """ Clean the old files. """