Updated for sbo repository

This commit is contained in:
Dimitris Zlatanidis 2023-03-14 10:58:09 +02:00
parent 7fed7d7b47
commit 28e82b7c2f
4 changed files with 18 additions and 50 deletions

View file

@ -47,7 +47,7 @@ class CreateData(Configs):
cache: list = [] # init cache 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): for i, line in enumerate(sbo_file, 1):

View file

@ -73,7 +73,7 @@ class Slackbuilds(Configs):
self.view_before_build() self.view_before_build()
start: float = time.time() start: float = time.time()
self.download_slackbuilds() self.prepare_slackbuilds_for_build()
self.build_and_install() self.build_and_install()
elapsed_time: float = time.time() - start elapsed_time: float = time.time() - start
@ -139,9 +139,8 @@ class Slackbuilds(Configs):
self.utils.is_package_upgradeable(sbo, self.file_pattern) or self.utils.is_package_upgradeable(sbo, self.file_pattern) or
self.mode == 'build' or self.utils.is_option(self.flag_reinstall, self.flags)) 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. """ """ Downloads files and sources. """
sbos_urls: list = []
sources_urls: list = [] sources_urls: list = []
for sbo in self.install_order: for sbo in self.install_order:
@ -150,46 +149,28 @@ class Slackbuilds(Configs):
self.utils.remove_folder_if_exists(self.build_path, sbo) self.utils.remove_folder_if_exists(self.build_path, sbo)
location: str = SBoQueries(sbo).location() location: str = SBoQueries(sbo).location()
slackbuild = Path(self.build_path, sbo, f'{sbo}.SlackBuild')
# Copy slackbuilds to the build folder.
if self.ponce_repo: if self.ponce_repo:
path_ponce_repo_package = Path(self.ponce_repo_path, location, sbo) 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}') shutil.copytree(path_ponce_repo_package, f'{self.build_path}{sbo}')
slackbuild = Path(path_build_package, f'{sbo}.SlackBuild')
os.chmod(slackbuild, 0o775)
else: else:
file: str = f'{sbo}{self.sbo_tar_suffix}' path_sbo_repo_package = Path(self.sbo_repo_path, location, sbo)
self.utils.remove_file_if_exists(self.build_path, file) shutil.copytree(path_sbo_repo_package, f'{self.build_path}{sbo}')
sbo_url: str = f'{self.sbo_repo_url}{location}/{file}'
sbos_urls.append(sbo_url)
os.chmod(slackbuild, 0o775)
sources_urls += SBoQueries(sbo).sources() sources_urls += SBoQueries(sbo).sources()
urls: list = sources_urls # Download the sources.
# Combine sbos and sources. down_urls = Downloader(self.build_path, sources_urls, self.flags)
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)
down_urls.download() down_urls.download()
print() # New line here. print() # New line here.
self.extract_sbos()
self.move_sources(sources_urls) self.move_sources(sources_urls)
self.checksum_downloads() 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: def move_sources(self, sources_urls: list) -> None:
""" Move the sources into the folders for build. """ """ Move the sources into the folders for build. """
for sbo, src in zip(self.install_order, sources_urls): for sbo, src in zip(self.install_order, sources_urls):

View file

@ -8,7 +8,6 @@ from multiprocessing import Process, Queue
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.downloader import Downloader
from slpkg.install_data import CreateData from slpkg.install_data import CreateData
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage
from slpkg.progress_bar import ProgressBar from slpkg.progress_bar import ProgressBar
@ -42,7 +41,6 @@ class UpdateRepository(Configs, Utilities):
def update_the_repository(self) -> None: def update_the_repository(self) -> None:
""" Updated the sbo repository. """ """ Updated the sbo repository. """
if self.update == 0: if self.update == 0:
self.view.question() self.view.question()
else: else:
@ -52,7 +50,8 @@ class UpdateRepository(Configs, Utilities):
if not self.is_option(self.flag_generate, self.flags): if not self.is_option(self.flag_generate, self.flags):
print('Updating the packages list.\n') 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} ' lftp_output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} '
f'{self.ponce_repo_path}', shell=True) f'{self.ponce_repo_path}', shell=True)
self.process_error(lftp_output) self.process_error(lftp_output)
@ -67,21 +66,18 @@ class UpdateRepository(Configs, Utilities):
os.chdir(self.ponce_repo_path) os.chdir(self.ponce_repo_path)
gen_output = subprocess.call(f'./gen_sbo_txt.sh > {self.ponce_txt}', shell=True) gen_output = subprocess.call(f'./gen_sbo_txt.sh > {self.ponce_txt}', shell=True)
self.process_error(gen_output) self.process_error(gen_output)
print() print('\n')
else: else:
print('Updating the packages list.\n') 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_txt)
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt) self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt)
slackbuilds_txt: list = [f'{self.sbo_repo_url}{self.sbo_txt}'] print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n")
changelog_txt: list = [f'{self.sbo_repo_url}{self.sbo_chglog_txt}'] lftp_output = subprocess.call(f'lftp {self.lftp_mirror_options} {self.sbo_repo_url} '
f'{self.sbo_repo_path}', shell=True)
down_slackbuilds = Downloader(self.sbo_repo_path, slackbuilds_txt, self.flags) self.process_error(lftp_output)
down_slackbuilds.download()
down_sbo_changelog = Downloader(self.sbo_repo_path, changelog_txt, self.flags)
down_sbo_changelog.download()
self.delete_sbo_data() self.delete_sbo_data()
data = CreateData() data = CreateData()

View file

@ -3,7 +3,6 @@
import time import time
import shutil import shutil
import tarfile
from pathlib import Path from pathlib import Path
from typing import Generator, Any from typing import Generator, Any
from distutils.version import LooseVersion from distutils.version import LooseVersion
@ -58,14 +57,6 @@ class Utilities:
if package_name not in self.black.packages(): if package_name not in self.black.packages():
yield self.split_installed_pkg(file.name)[0] 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 @staticmethod
def remove_file_if_exists(path: str, file: str) -> None: def remove_file_if_exists(path: str, file: str) -> None:
""" Clean the old files. """ """ Clean the old files. """