mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-17 07:48:18 +01:00
Fixed for repositories
This commit is contained in:
parent
282cfd6b7c
commit
b82ca53672
2 changed files with 60 additions and 43 deletions
|
@ -7,22 +7,29 @@ from pathlib import Path
|
|||
from multiprocessing import Process
|
||||
|
||||
from slpkg.configs import Configs
|
||||
from slpkg.utilities import Utilities
|
||||
from slpkg.progress_bar import ProgressBar
|
||||
from slpkg.repositories import Repositories
|
||||
|
||||
|
||||
class CheckUpdates(Configs):
|
||||
""" Check for changes in the ChangeLog file. """
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, flags: list):
|
||||
super(Configs, self).__init__()
|
||||
self.flags: list = flags
|
||||
self.utils = Utilities()
|
||||
self.progress = ProgressBar()
|
||||
self.color = self.colour()
|
||||
self.repositories = Repositories()
|
||||
self.repos: dict = self.repositories.configs()
|
||||
|
||||
self.bold: str = self.color['bold']
|
||||
self.green: str = self.color['green']
|
||||
self.yellow: str = self.color['yellow']
|
||||
self.bgreen: str = f'{self.bold}{self.green}'
|
||||
self.endc: str = self.color['endc']
|
||||
self.flag_binary: list = ['-B', '--binary']
|
||||
|
||||
# Slackbuilds.org repository settings.
|
||||
self.changelog_txt: str = self.sbo_chglog_txt
|
||||
|
@ -34,10 +41,13 @@ class CheckUpdates(Configs):
|
|||
local_date: int = 0
|
||||
|
||||
# Ponce repository settings.
|
||||
if self.ponce_repo:
|
||||
self.changelog_txt: str = self.ponce_chglog_txt
|
||||
self.local_chg_txt = Path(self.ponce_repo_path, self.changelog_txt)
|
||||
self.repo_chg_txt: str = f'{self.ponce_repo_url}{self.changelog_txt}'
|
||||
if self.utils.is_option(self.flag_binary, self.flags):
|
||||
pass
|
||||
else:
|
||||
if self.ponce_repo:
|
||||
self.changelog_txt: str = self.ponce_chglog_txt
|
||||
self.local_chg_txt = Path(self.ponce_repo_path, self.changelog_txt)
|
||||
self.repo_chg_txt: str = f'{self.ponce_repo_url}{self.changelog_txt}'
|
||||
|
||||
try:
|
||||
http = urllib3.PoolManager()
|
||||
|
|
|
@ -46,49 +46,21 @@ class UpdateRepository(Configs):
|
|||
self.flag_generate: list = ['-G', '--generate-only']
|
||||
self.flag_binary: list = ['-B', '--binary']
|
||||
|
||||
def update_the_repository(self) -> None:
|
||||
def update_the_repositories(self) -> None:
|
||||
""" Updated the sbo repository. """
|
||||
if self.update == 0:
|
||||
self.view.question()
|
||||
else:
|
||||
print()
|
||||
|
||||
if not self.utils.is_option(self.flag_binary, self.flags):
|
||||
if self.ponce_repo:
|
||||
if self.utils.is_option(self.flag_binary, self.flags):
|
||||
self.binary_repositories()
|
||||
else:
|
||||
self.slackbuild_repositories()
|
||||
|
||||
if not self.utils.is_option(self.flag_generate, self.flags):
|
||||
print('Ponce repository -> Updating the packages list...\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_command: str = f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} {self.ponce_repo_path}'
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
# Remove the SLACKBUILDS.TXT file before generating the new one.
|
||||
sbo_file_txt = Path(self.ponce_repo_path, self.ponce_txt)
|
||||
if sbo_file_txt.is_file():
|
||||
sbo_file_txt.unlink()
|
||||
|
||||
# Generating the ponce SLACKBUILDS.TXT file.
|
||||
print(f'Generating the {self.ponce_txt} file... ', end='', flush=True)
|
||||
os.chdir(self.ponce_repo_path)
|
||||
gen_command: str = f'./gen_sbo_txt.sh > {self.ponce_txt}'
|
||||
self.utils.process(gen_command)
|
||||
print('\n')
|
||||
|
||||
else:
|
||||
print('SBo repository -> 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)
|
||||
|
||||
print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n")
|
||||
lftp_command: str = f'lftp {self.lftp_mirror_options} {self.sbo_repo_url} {self.sbo_repo_path}'
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
self.delete_sbo_data()
|
||||
self.data.install_sbo_table()
|
||||
|
||||
elif self.repos['GNOME_REPO']:
|
||||
def binary_repositories(self):
|
||||
""" Update the binary repositories. """
|
||||
if self.repos['GNOME_REPO']:
|
||||
print('Gnome repository -> Updating the packages list...\n')
|
||||
repo: str = 'gnome'
|
||||
self.make_dirs(repo)
|
||||
|
@ -108,6 +80,41 @@ class UpdateRepository(Configs):
|
|||
|
||||
self.data.install_gnome_data(self.repos['GNOME_REPO_PKG_TXT'])
|
||||
|
||||
def slackbuild_repositories(self):
|
||||
""" Update the slackbuild repositories. """
|
||||
if self.ponce_repo:
|
||||
if not self.utils.is_option(self.flag_generate, self.flags):
|
||||
print('Ponce repository -> Updating the packages list...\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_command: str = f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} {self.ponce_repo_path}'
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
# Remove the SLACKBUILDS.TXT file before generating the new one.
|
||||
sbo_file_txt = Path(self.ponce_repo_path, self.ponce_txt)
|
||||
if sbo_file_txt.is_file():
|
||||
sbo_file_txt.unlink()
|
||||
|
||||
# Generating the ponce SLACKBUILDS.TXT file.
|
||||
print(f'Generating the {self.ponce_txt} file... ', end='', flush=True)
|
||||
os.chdir(self.ponce_repo_path)
|
||||
gen_command: str = f'./gen_sbo_txt.sh > {self.ponce_txt}'
|
||||
self.utils.process(gen_command)
|
||||
print('\n')
|
||||
|
||||
else:
|
||||
print('SBo repository -> 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)
|
||||
|
||||
print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n")
|
||||
lftp_command: str = f'lftp {self.lftp_mirror_options} {self.sbo_repo_url} {self.sbo_repo_path}'
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
self.delete_sbo_data()
|
||||
self.data.install_sbo_table()
|
||||
|
||||
def make_dirs(self, repo):
|
||||
""" Creating the repositories folders. """
|
||||
path = Path(self.lib_path, 'repositories', repo)
|
||||
|
@ -115,7 +122,7 @@ class UpdateRepository(Configs):
|
|||
os.makedirs(path)
|
||||
|
||||
def check(self, queue) -> None:
|
||||
check_updates = CheckUpdates()
|
||||
check_updates = CheckUpdates(self.flags)
|
||||
is_update: int = 0
|
||||
if not check_updates.check():
|
||||
print(f'\n\n{self.endc}{self.yellow}No changes in ChangeLog.txt between your '
|
||||
|
@ -152,7 +159,7 @@ class UpdateRepository(Configs):
|
|||
print('\x1b[?25h', self.endc, end='')
|
||||
|
||||
self.update = queue.get()
|
||||
self.update_the_repository()
|
||||
self.update_the_repositories()
|
||||
|
||||
@staticmethod
|
||||
def delete_file(folder: str, txt_file: str) -> None:
|
||||
|
|
Loading…
Reference in a new issue