Updated for repositories

This commit is contained in:
Dimitris Zlatanidis 2023-03-20 18:21:36 +02:00
parent b82ca53672
commit df722d1649
13 changed files with 162 additions and 92 deletions

View file

@ -1,7 +1,21 @@
# Repositories configuration file. # Repositories configuration file.
[REPOSITORIES] [REPOSITORIES]
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
SBO_REPO_TXT = "SLACKBUILDS.TXT"
SBO_REPO_CHGLOG_TXT = "ChangeLog.txt"
SBO_REPO_TAR_SUFFIX = ".tar.gz"
SBO_REPO_TAG = "_SBo"
PONCE_REPO = false
PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
PONCE_REPO_TXT = "SLACKBUILDS.TXT"
PONCE_REPO_CHGLOG_TXT = "ChangeLog.txt"
PONCE_REPO_TAG = "_SBo"
GNOME_REPO = true GNOME_REPO = true
GNOME_REPO_URL = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/" GNOME_REPO_URL = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
GNOME_REPO_PKG_TXT = "PACKAGES.TXT" GNOME_REPO_PKG_TXT = "PACKAGES.TXT"
GNOME_REPO_CHGLOG_TXT = "ChangeLog.txt" GNOME_REPO_CHGLOG_TXT = "ChangeLog.txt"

View file

@ -41,23 +41,23 @@
SPINNER_COLOR = "green" SPINNER_COLOR = "green"
# SLACKBUILDS.ORG REPOSITORY CONFIGS. # SLACKBUILDS.ORG REPOSITORY CONFIGS.
SBO_REPO_PATH = "/var/lib/slpkg/repositories/sbo/" # SBO_REPO_PATH = "/var/lib/slpkg/repositories/sbo/"
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/" # SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
SBO_TXT = "SLACKBUILDS.TXT" # SBO_TXT = "SLACKBUILDS.TXT"
SBO_CHGLOG_TXT = "ChangeLog.txt" # SBO_CHGLOG_TXT = "ChangeLog.txt"
SBO_TAR_SUFFIX = ".tar.gz" # SBO_TAR_SUFFIX = ".tar.gz"
SBO_REPO_TAG = "_SBo" # SBO_REPO_TAG = "_SBo"
# PONCE REPOSITORY CONFIGS. # PONCE REPOSITORY CONFIGS.
# Set the 'PONCE_REPO = true' to switch to the ponce repository and # Set the 'PONCE_REPO = true' to switch to the ponce repository and
# run 'slpkg update' to update the database if it is necessary. # run 'slpkg update' to update the database if it is necessary.
# Default is false. [true/false]. # Default is false. [true/false].
PONCE_REPO = false # PONCE_REPO = false
PONCE_REPO_PATH = "/var/lib/slpkg/repositories/ponce/" # PONCE_REPO_PATH = "/var/lib/slpkg/repositories/ponce/"
PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/" # PONCE_REPO_URL = "https://cgit.ponce.cc/slackbuilds/plain/"
PONCE_TXT = "SLACKBUILDS.TXT" # PONCE_TXT = "SLACKBUILDS.TXT"
PONCE_CHGLOG_TXT = "ChangeLog.txt" # PONCE_CHGLOG_TXT = "ChangeLog.txt"
PONCE_REPO_TAG = "_SBo" # PONCE_REPO_TAG = "_SBo"
# Slackware command for install packages, instead, you can use 'installpkg'. # Slackware command for install packages, instead, you can use 'installpkg'.
INSTALLPKG = "upgradepkg --install-new" INSTALLPKG = "upgradepkg --install-new"

View file

@ -21,8 +21,7 @@ class CheckUpdates(Configs):
self.utils = Utilities() self.utils = Utilities()
self.progress = ProgressBar() self.progress = ProgressBar()
self.color = self.colour() self.color = self.colour()
self.repositories = Repositories() self.repos = Repositories()
self.repos: dict = self.repositories.configs()
self.bold: str = self.color['bold'] self.bold: str = self.color['bold']
self.green: str = self.color['green'] self.green: str = self.color['green']
@ -31,24 +30,27 @@ class CheckUpdates(Configs):
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
self.flag_binary: list = ['-B', '--binary'] self.flag_binary: list = ['-B', '--binary']
# Slackbuilds.org repository settings. self.local_chg_txt = None
self.changelog_txt: str = self.sbo_chglog_txt self.repo_chg_txt = None
self.local_chg_txt = Path(self.sbo_repo_path, self.changelog_txt)
self.repo_chg_txt: str = f'{self.sbo_repo_url}{self.changelog_txt}'
def check(self) -> bool: def check(self) -> None:
""" Checks the ChangeLogs and returns True or False. """ """ Checks the ChangeLogs and returns True or False. """
local_date: int = 0
# Ponce repository settings. # Ponce repository settings.
if self.utils.is_option(self.flag_binary, self.flags): if self.utils.is_option(self.flag_binary, self.flags):
if self.repos.gnome_repo:
pass pass
else: else:
if self.ponce_repo: if self.repos.ponce_repo:
self.changelog_txt: str = self.ponce_chglog_txt self.local_chg_txt = Path(self.ponce_repo_path, self.repos.ponce_repo_chglog_txt)
self.local_chg_txt = Path(self.ponce_repo_path, self.changelog_txt) self.repo_chg_txt: str = f'{self.repos.ponce_repo_url}{self.repos.ponce_repo_chglog_txt}'
self.repo_chg_txt: str = f'{self.ponce_repo_url}{self.changelog_txt}' self.compare_dates()
else:
self.local_chg_txt = Path(self.sbo_repo_path, self.repos.sbo_repo_chglog_txt)
self.repo_chg_txt: str = f'{self.repos.sbo_repo_url}{self.repos.sbo_repo_chglog_txt}'
self.compare_dates()
def compare_dates(self):
local_date: int = 0
try: try:
http = urllib3.PoolManager() http = urllib3.PoolManager()
repo = http.request('GET', self.repo_chg_txt) repo = http.request('GET', self.repo_chg_txt)
@ -70,7 +72,7 @@ class CheckUpdates(Configs):
def updates(self) -> None: def updates(self) -> None:
""" Starting multiprocessing download process. """ """ Starting multiprocessing download process. """
message: str = f'Checking for news in the {self.changelog_txt} file...' message: str = f'Checking for news in the {self.repo_chg_txt} file...'
# Starting multiprocessing # Starting multiprocessing
p1 = Process(target=self.view_message) p1 = Process(target=self.view_message)

View file

@ -7,6 +7,7 @@ from slpkg.configs import Configs
from slpkg.queries import SBoQueries from slpkg.queries import SBoQueries
from slpkg.blacklist import Blacklist from slpkg.blacklist import Blacklist
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.repositories import Repositories
class Check(Configs): class Check(Configs):
@ -16,9 +17,10 @@ class Check(Configs):
super(Configs, self).__init__() super(Configs, self).__init__()
self.black = Blacklist() self.black = Blacklist()
self.utils = Utilities() self.utils = Utilities()
self.repos = Repositories()
self.repo_path = self.sbo_repo_path self.repo_path = self.sbo_repo_path
if self.ponce_repo: if self.repos.ponce_repo:
self.repo_path = self.ponce_repo_path self.repo_path = self.ponce_repo_path
def exists_in_the_database(self, slackbuilds: list) -> None: def exists_in_the_database(self, slackbuilds: list) -> None:

View file

@ -66,22 +66,24 @@ class Configs:
# File suffix for list packages. # File suffix for list packages.
file_list_suffix: str = '.pkgs' file_list_suffix: str = '.pkgs'
sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore
ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore
# SBo repository configs. # SBo repository configs.
sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore # sbo_repo_path: str = Path(lib_path, 'repositories', 'sbo') # type: ignore
sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/' # sbo_repo_url: str = 'https://slackbuilds.org/slackbuilds/15.0/'
sbo_txt: str = 'SLACKBUILDS.TXT' # sbo_txt: str = 'SLACKBUILDS.TXT'
sbo_chglog_txt: str = 'ChangeLog.txt' # sbo_chglog_txt: str = 'ChangeLog.txt'
sbo_tar_suffix: str = '.tar.gz' # sbo_tar_suffix: str = '.tar.gz'
sbo_repo_tag: str = '_SBo' # sbo_repo_tag: str = '_SBo'
# Ponce repo configs. # Ponce repo configs.
ponce_repo: bool = False # ponce_repo: bool = False
ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore # ponce_repo_path: str = Path(lib_path, 'repositories', 'ponce') # type: ignore
ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/' # ponce_repo_url: str = 'https://cgit.ponce.cc/slackbuilds/plain/'
ponce_txt: str = 'SLACKBUILDS.TXT' # ponce_txt: str = 'SLACKBUILDS.TXT'
ponce_chglog_txt: str = 'ChangeLog.txt' # ponce_chglog_txt: str = 'ChangeLog.txt'
ponce_repo_tag: str = '_SBo' # ponce_repo_tag: str = '_SBo'
# Slackware commands. # Slackware commands.
installpkg: str = 'upgradepkg --install-new' installpkg: str = 'upgradepkg --install-new'
@ -146,7 +148,7 @@ class Configs:
tmp_slpkg: str = config['TMP_SLPKG'] tmp_slpkg: str = config['TMP_SLPKG']
build_path: str = config['BUILD_PATH'] build_path: str = config['BUILD_PATH']
download_only_path: str = config['DOWNLOAD_ONLY_PATH'] download_only_path: str = config['DOWNLOAD_ONLY_PATH']
sbo_repo_path: str = config['SBO_REPO_PATH'] # sbo_repo_path: str = config['SBO_REPO_PATH']
# Database name. # Database name.
database_name: str = config['DATABASE_NAME'] database_name: str = config['DATABASE_NAME']
@ -155,19 +157,19 @@ class Configs:
ask_question: bool = config['ASK_QUESTION'] ask_question: bool = config['ASK_QUESTION']
# SBo repository details. # SBo repository details.
sbo_repo_url: str = config['SBO_REPO_URL'] # sbo_repo_url: str = config['SBO_REPO_URL']
sbo_txt: str = config['SBO_TXT'] # sbo_txt: str = config['SBO_TXT']
sbo_chglog_txt: str = config['SBO_CHGLOG_TXT'] # sbo_chglog_txt: str = config['SBO_CHGLOG_TXT']
sbo_tar_suffix: str = config['SBO_TAR_SUFFIX'] # sbo_tar_suffix: str = config['SBO_TAR_SUFFIX']
sbo_repo_tag: str = config['SBO_REPO_TAG'] # sbo_repo_tag: str = config['SBO_REPO_TAG']
# Ponce repo configs. # Ponce repo configs.
ponce_repo: bool = config['PONCE_REPO'] # ponce_repo: bool = config['PONCE_REPO']
ponce_repo_path: str = config['PONCE_REPO_PATH'] # ponce_repo_path: str = config['PONCE_REPO_PATH']
ponce_repo_url: str = config['PONCE_REPO_URL'] # ponce_repo_url: str = config['PONCE_REPO_URL']
ponce_txt: str = config['PONCE_TXT'] # ponce_txt: str = config['PONCE_TXT']
ponce_chglog_txt: str = config['PONCE_CHGLOG_TXT'] # ponce_chglog_txt: str = config['PONCE_CHGLOG_TXT']
ponce_repo_tag: str = config['PONCE_REPO_TAG'] # ponce_repo_tag: str = config['PONCE_REPO_TAG']
# Slackware commands. # Slackware commands.
installpkg: str = config['INSTALLPKG'] installpkg: str = config['INSTALLPKG']
@ -222,10 +224,6 @@ class Configs:
f"'mv {etc_path}/{prog_name}.toml.new {etc_path}/{prog_name}.toml'.\n" f"'mv {etc_path}/{prog_name}.toml.new {etc_path}/{prog_name}.toml'.\n"
f"or '{color['cyan']}slpkg_new-configs{color['endc']}' command.\n") f"or '{color['cyan']}slpkg_new-configs{color['endc']}' command.\n")
repo_tag: str = sbo_repo_tag
if ponce_repo:
repo_tag: str = ponce_repo_tag
# Creating the paths if not exists # Creating the paths if not exists
paths = [ paths = [
tmp_slpkg, tmp_slpkg,

View file

@ -6,6 +6,7 @@ from pathlib import Path
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.queries import SBoQueries from slpkg.queries import SBoQueries
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.repositories import Repositories
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
from slpkg.models.models import SBoTable, PonceTable, BinariesTable from slpkg.models.models import SBoTable, PonceTable, BinariesTable
@ -19,6 +20,8 @@ class CreateData(Configs):
self.session = Session self.session = Session
self.utils = Utilities() self.utils = Utilities()
self.query = SBoQueries('') self.query = SBoQueries('')
self.repositories = Repositories()
self.repos: dict = self.repositories.configs()
def install_sbo_table(self) -> None: def install_sbo_table(self) -> None:
""" Install the data for SBo repository. """ """ Install the data for SBo repository. """
@ -35,11 +38,11 @@ class CreateData(Configs):
'SLACKBUILD SHORT DESCRIPTION:' 'SLACKBUILD SHORT DESCRIPTION:'
] ]
sbo_table = SBoTable sbo_table = SBoTable
path = Path(self.sbo_repo_path, self.sbo_txt) path = Path(self.sbo_repo_path, self.repos['SBO_REPO_TXT'])
if self.ponce_repo: if self.repos['PONCE_REPO']:
sbo_table = PonceTable sbo_table = PonceTable
path = Path(self.ponce_repo_path, self.ponce_txt) path = Path(self.ponce_repo_path, self.repos['PONCE_REPO_TXT'])
sbo_file: list = self.utils.read_file(path) sbo_file: list = self.utils.read_file(path)
@ -68,7 +71,7 @@ class CreateData(Configs):
self.session.commit() self.session.commit()
def install_gnome_data(self, repo_txt: str) -> None: def install_gnome_data(self) -> None:
""" Install the data for SBo repository. """ """ Install the data for SBo repository. """
repo: str = 'gnome' repo: str = 'gnome'
pkg_tag = [ pkg_tag = [
@ -79,7 +82,7 @@ class CreateData(Configs):
'PACKAGE SIZE (uncompressed):', 'PACKAGE SIZE (uncompressed):',
'PACKAGE DESCRIPTION:', 'PACKAGE DESCRIPTION:',
] ]
path = Path(self.lib_path, 'repositories', repo, repo_txt) path = Path(self.lib_path, 'repositories', repo, self.repos['GNOME_REPO_PKG_TXT'])
pkg_txt: list = self.utils.read_file(path) pkg_txt: list = self.utils.read_file(path)

View file

@ -21,6 +21,7 @@ from slpkg.slackbuild import Slackbuilds
from slpkg.views.views import ViewMessage from slpkg.views.views import ViewMessage
from slpkg.form_configs import FormConfigs from slpkg.form_configs import FormConfigs
from slpkg.views.help_commands import Help from slpkg.views.help_commands import Help
from slpkg.repositories import Repositories
from slpkg.check_updates import CheckUpdates from slpkg.check_updates import CheckUpdates
from slpkg.find_installed import FindInstalled from slpkg.find_installed import FindInstalled
from slpkg.views.view_package import ViewPackage from slpkg.views.view_package import ViewPackage
@ -42,13 +43,15 @@ class Argparse(Configs):
self.check = Check() self.check = Check()
self.form_configs = FormConfigs() self.form_configs = FormConfigs()
self.color = self.colour() self.color = self.colour()
self.repos = Repositories()
self.bold: str = self.color['bold'] self.bold: str = self.color['bold']
self.red: str = self.color['red'] self.red: str = self.color['red']
self.endc: str = self.color['endc'] self.endc: str = self.color['endc']
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.file_pattern: str = f'*{self.repo_tag}' self.file_pattern: str = f'*{self.repos.repo_tag}'
if self.file_pattern_conf: if self.file_pattern_conf:
self.file_pattern = self.file_pattern_conf self.file_pattern = self.file_pattern_conf
@ -481,7 +484,7 @@ class Argparse(Configs):
def check_updates(self) -> None: def check_updates(self) -> None:
if len(self.args) == 1: if len(self.args) == 1:
self.check.is_empty_database() self.check.is_empty_database()
check = CheckUpdates() check = CheckUpdates(self.flags)
check.updates() check.updates()
raise SystemExit() raise SystemExit()
self.usage.help_short(1) self.usage.help_short(1)

View file

@ -5,6 +5,7 @@ from typing import Union
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.blacklist import Blacklist from slpkg.blacklist import Blacklist
from slpkg.repositories import Repositories
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
from slpkg.models.models import SBoTable, PonceTable from slpkg.models.models import SBoTable, PonceTable
@ -16,6 +17,7 @@ class SBoQueries(Configs):
super(Configs, self).__init__() super(Configs, self).__init__()
self.name: str = name self.name: str = name
self.session = Session self.session = Session
self.repos = Repositories()
self.black = Blacklist() self.black = Blacklist()
if self.name in self.black.packages(): if self.name in self.black.packages():
@ -23,7 +25,7 @@ class SBoQueries(Configs):
# Switch between sbo and ponce repository. # Switch between sbo and ponce repository.
self.sbo_table = SBoTable self.sbo_table = SBoTable
if self.ponce_repo: if self.repos.ponce_repo:
self.sbo_table = PonceTable self.sbo_table = PonceTable
def sbos(self) -> list: def sbos(self) -> list:

View file

@ -23,17 +23,55 @@ class Repositories(Configs):
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.repositories_file_toml = Path(self.etc_path, 'repositories.toml') self.repositories_file_toml = Path(self.etc_path, 'repositories.toml')
def configs(self) -> dict: self.sbo_repo_url: str = "https://slackbuilds.org/slackbuilds/15.0/"
self.sbo_repo_txt: str = "SLACKBUILDS.TXT"
self.sbo_repo_chglog_txt: str = "ChangeLog.txt"
self.sbo_repo_tar_suffix: str = ".tar.gz"
self.sbo_repo_tag: str = "_SBo"
self.ponce_repo: bool = False
self.ponce_repo_url: str = "https://cgit.ponce.cc/slackbuilds/plain/"
self.ponce_repo_txt: str = "SLACKBUILDS.TXT"
self.ponce_repo_chglog_txt: str = "ChangeLog.txt"
self.ponce_repo_tag: str = "_SBo"
self.gnome_repo: bool = True
self.gnome_repo_url: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
self.gnome_repo_pkg_txt: str = "PACKAGES.TXT"
self.gnome_repo_chglog_pkg_txt: str = "ChangeLog.txt"
self.repo_tag: str = self.sbo_repo_tag
def configs(self) -> None:
""" Reads the repositories file. """ """ Reads the repositories file. """
if self.repositories_file_toml.is_file(): if self.repositories_file_toml.is_file():
try: try:
with open(self.repositories_file_toml, 'rb') as repo: with open(self.repositories_file_toml, 'rb') as repo:
return tomli.load(repo)['REPOSITORIES'] repos = tomli.load(repo)['REPOSITORIES']
except (tomli.TOMLDecodeError, KeyError) as error: except (tomli.TOMLDecodeError, KeyError) as error:
raise SystemExit(f"\n{self.prog_name} {self.bred}Error{self.endc}: {error}: in the configuration file " raise SystemExit(f"\n{self.prog_name} {self.bred}Error{self.endc}: {error}: in the configuration file "
f"'{self.repositories_file_toml}'.\n" f"'{self.repositories_file_toml}'.\n"
f"\nIf you have upgraded the '{self.prog_name}' probably you need to run:\n" f"\nIf you have upgraded the '{self.prog_name}' probably you need to run:\n"
f"'mv {self.repositories_file_toml}.new {self.repositories_file_toml}'.\n" f"'mv {self.repositories_file_toml}.new {self.repositories_file_toml}'.\n"
f"or '{self.cyan}slpkg_new-configs{self.endc}' command.\n") f"or '{self.cyan}slpkg_new-configs{self.endc}' command.\n")
return []
self.sbo_repo_url: str = repos['SBO_REPO_URL']
self.sbo_repo_txt: str = repos['SBO_REPO_TXT']
self.sbo_repo_chglog_txt: str = repos['SBO_REPO_CHGLOG_TXT']
self.sbo_repo_tar_suffix: str = repos['SBO_REPO_TAR_SUFFIX']
self.sbo_repo_tag: str = repos['SBO_REPO_TAG']
self.ponce_repo: bool = repos['PONCE_REPO']
self.ponce_repo_url: str = repos['PONCE_REPO_URL']
self.ponce_repo_txt: str = repos['PONCE_REPO_TXT']
self.ponce_repo_chglog_txt: str = repos['PONCE_REPO_CHGLOG_TXT']
self.ponce_repo_tag: str = repos['PONCE_REPO_TAG']
self.gnome_repo: bool = repos['GNOME_REPO']
self.gnome_repo_url: str = repos['GNOME_REPO_URL']
self.gnome_repo_pkg_txt: str = repos['GNOME_REPO_PKG_TXT']
self.gnome_repo_chglog_pkg_txt: str = repos['GNOME_REPO_CHGLOG_TXT']
if self.ponce_repo:
self.repo_tag: str = self.ponce_repo_tag

View file

@ -27,8 +27,7 @@ class UpdateRepository(Configs):
self.session = Session self.session = Session
self.view = ViewMessage(self.flags) self.view = ViewMessage(self.flags)
self.repositories = Repositories() self.repos = Repositories()
self.repos: dict = self.repositories.configs()
self.progress = ProgressBar() self.progress = ProgressBar()
self.utils = Utilities() self.utils = Utilities()
self.color = self.colour() self.color = self.colour()
@ -60,17 +59,17 @@ class UpdateRepository(Configs):
def binary_repositories(self): def binary_repositories(self):
""" Update the binary repositories. """ """ Update the binary repositories. """
if self.repos['GNOME_REPO']: if self.repos.gnome_repo:
print('Gnome repository -> Updating the packages list...\n') print('Gnome repository -> Updating the packages list...\n')
repo: str = 'gnome' repo: str = 'gnome'
self.make_dirs(repo) self.make_dirs(repo)
self.urls.append(f"{self.repos['GNOME_REPO_URL']}{self.repos['GNOME_REPO_PKG_TXT']}") self.urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_pkg_txt}')
self.urls.append(f"{self.repos['GNOME_REPO_URL']}{self.repos['GNOME_REPO_CHGLOG_TXT']}") self.urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_chglog_pkg_txt}')
repo_path = Path(self.lib_path, 'repositories', repo) repo_path = Path(self.lib_path, 'repositories', repo)
self.delete_file(f"{self.lib_path}/repositories/{repo}", self.repos['GNOME_REPO_PKG_TXT']) self.delete_file(f'{self.lib_path}/repositories/{repo}', self.repos.gnome_repo_pkg_txt)
self.delete_file(f"{self.lib_path}/repositories/{repo}", self.repos['GNOME_REPO_CHGLOG_TXT']) self.delete_file(f'{self.lib_path}/repositories/{repo}', self.repos.gnome_repo_chglog_pkg_txt)
down = Downloader(repo_path, self.urls, self.flags) down = Downloader(repo_path, self.urls, self.flags)
down.download() down.download()
@ -78,38 +77,39 @@ class UpdateRepository(Configs):
self.delete_binaries_data(repo) self.delete_binaries_data(repo)
self.data.install_gnome_data(self.repos['GNOME_REPO_PKG_TXT']) self.data.install_gnome_data()
def slackbuild_repositories(self): def slackbuild_repositories(self):
""" Update the slackbuild repositories. """ """ Update the slackbuild repositories. """
if self.ponce_repo: if self.repos.ponce_repo:
if not self.utils.is_option(self.flag_generate, self.flags): if not self.utils.is_option(self.flag_generate, self.flags):
print('Ponce repository -> Updating the packages list...\n') print('Ponce repository -> Updating the packages list...\n')
print(f"Downloading the '{self.green}ponce{self.endc}' 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) self.delete_file(self.ponce_repo_path, self.repos .ponce_repo_txt)
lftp_command: str = f'lftp {self.lftp_mirror_options} {self.ponce_repo_url} {self.ponce_repo_path}' lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.ponce_repo_url} '
f'{self.ponce_repo_path}')
self.utils.process(lftp_command) self.utils.process(lftp_command)
# Remove the SLACKBUILDS.TXT file before generating the new one. # Remove the SLACKBUILDS.TXT file before generating the new one.
sbo_file_txt = Path(self.ponce_repo_path, self.ponce_txt) sbo_file_txt = Path(self.ponce_repo_path, self.repos.ponce_repo_txt)
if sbo_file_txt.is_file(): if sbo_file_txt.is_file():
sbo_file_txt.unlink() sbo_file_txt.unlink()
# Generating the ponce SLACKBUILDS.TXT file. # Generating the ponce SLACKBUILDS.TXT file.
print(f'Generating the {self.ponce_txt} file... ', end='', flush=True) print(f'Generating the {self.repos.ponce_repo_txt} file... ', end='', flush=True)
os.chdir(self.ponce_repo_path) os.chdir(self.ponce_repo_path)
gen_command: str = f'./gen_sbo_txt.sh > {self.ponce_txt}' gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_txt}'
self.utils.process(gen_command) self.utils.process(gen_command)
print('\n') print('\n')
else: else:
print('SBo repository -> Updating the packages list...\n') 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.repos.sbo_repo_txt)
self.delete_file(self.sbo_repo_path, self.sbo_chglog_txt) self.delete_file(self.sbo_repo_path, self.repos.sbo_repo_chglog_txt)
print(f"Downloading the '{self.green}sbo{self.endc}' repository, please wait...\n") 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}' lftp_command: str = f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_url} {self.sbo_repo_path}'
self.utils.process(lftp_command) self.utils.process(lftp_command)
self.delete_sbo_data() self.delete_sbo_data()
@ -170,7 +170,7 @@ class UpdateRepository(Configs):
def delete_sbo_data(self) -> None: def delete_sbo_data(self) -> None:
""" Delete all the data from a table of the database. """ """ Delete all the data from a table of the database. """
if self.ponce_repo: if self.repos.ponce_repo:
self.session.query(PonceTable).delete() self.session.query(PonceTable).delete()
else: else:
self.session.query(SBoTable).delete() self.session.query(SBoTable).delete()

View file

@ -13,6 +13,7 @@ from distutils.version import LooseVersion
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.queries import SBoQueries from slpkg.queries import SBoQueries
from slpkg.blacklist import Blacklist from slpkg.blacklist import Blacklist
from slpkg.repositories import Repositories
class Utilities: class Utilities:
@ -22,6 +23,7 @@ class Utilities:
self.colors = self.configs.colour self.colors = self.configs.colour
self.color = self.colors() self.color = self.colors()
self.black = Blacklist() self.black = Blacklist()
self.repos = Repositories()
self.bold: str = self.color['bold'] self.bold: str = self.color['bold']
self.yellow: str = self.color['yellow'] self.yellow: str = self.color['yellow']
@ -94,7 +96,7 @@ class Utilities:
name: str = '-'.join(package.split('-')[:-3]) name: str = '-'.join(package.split('-')[:-3])
version: str = ''.join(package[len(name):].split('-')[:-2]) version: str = ''.join(package[len(name):].split('-')[:-2])
arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1]) arch: str = ''.join(package[len(name + version) + 2:].split('-')[:-1])
build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.configs.repo_tag, '') build: str = ''.join(package[len(name + version + arch) + 3:].split('-')).replace(self.repos.repo_tag, '')
tag: str = ''.join(package[len(name + version + arch + build) + 4:].split('-')) tag: str = ''.join(package[len(name + version + arch + build) + 4:].split('-'))
return [name, version, arch, build, tag] return [name, version, arch, build, tag]

View file

@ -4,6 +4,7 @@
import shutil import shutil
from slpkg.configs import Configs from slpkg.configs import Configs
from slpkg.repositories import Repositories
class Ascii(Configs): class Ascii(Configs):
@ -11,6 +12,7 @@ class Ascii(Configs):
def __init__(self): def __init__(self):
super(Configs, self).__init__() super(Configs, self).__init__()
self.color = self.colour() self.color = self.colour()
self.repos = Repositories()
self.columns, self.rows = shutil.get_terminal_size() self.columns, self.rows = shutil.get_terminal_size()
self.vertical_line: str = '|' self.vertical_line: str = '|'
@ -50,7 +52,7 @@ class Ascii(Configs):
self.bred: str = f'{self.bold}{self.red}' self.bred: str = f'{self.bold}{self.red}'
self.repo: str = 'sbo' self.repo: str = 'sbo'
if self.ponce_repo: if self.repos.ponce_repo:
self.repo: str = 'ponce' self.repo: str = 'ponce'
def draw_package_title_box(self, message: str, title: str) -> None: def draw_package_title_box(self, message: str, title: str) -> None:

View file

@ -9,6 +9,7 @@ from slpkg.views.ascii import Ascii
from slpkg.queries import SBoQueries from slpkg.queries import SBoQueries
from slpkg.utilities import Utilities from slpkg.utilities import Utilities
from slpkg.dialog_box import DialogBox from slpkg.dialog_box import DialogBox
from slpkg.repositories import Repositories
from slpkg.models.models import LogsDependencies from slpkg.models.models import LogsDependencies
from slpkg.models.models import session as Session from slpkg.models.models import session as Session
@ -25,6 +26,7 @@ class ViewMessage(Configs):
self.dialogbox = DialogBox() self.dialogbox = DialogBox()
self.ascii = Ascii() self.ascii = Ascii()
self.color = self.colour() self.color = self.colour()
self.repos = Repositories()
self.yellow: str = self.color['yellow'] self.yellow: str = self.color['yellow']
self.cyan: str = self.color['cyan'] self.cyan: str = self.color['cyan']
@ -37,7 +39,9 @@ class ViewMessage(Configs):
self.flag_resolve_off: list = ['-o', '--resolve-off'] self.flag_resolve_off: list = ['-o', '--resolve-off']
self.flag_reinstall: list = ['-r', '--reinstall'] self.flag_reinstall: list = ['-r', '--reinstall']
self.flag_yes: list = ['-y', '--yes'] self.flag_yes: list = ['-y', '--yes']
self.file_pattern: str = f'*{self.repo_tag}'
self.file_pattern: str = f'*{self.repos.repo_tag}'
self.all_installed: list = list(self.utils.all_installed_names(self.file_pattern)) self.all_installed: list = list(self.utils.all_installed_names(self.file_pattern))
def view_packages(self, package: str, version: str, mode: str) -> None: def view_packages(self, package: str, version: str, mode: str) -> None: