mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Refactored for repo configs
This commit is contained in:
parent
16f7daf2bd
commit
b71e4b41dd
8 changed files with 75 additions and 68 deletions
|
@ -2,27 +2,29 @@
|
|||
[REPOSITORIES]
|
||||
|
||||
SBO_REPO_NAME = "sbo"
|
||||
SBO_REPO_URL = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
SBO_REPO_TXT = "SLACKBUILDS.TXT"
|
||||
SBO_REPO_CHGLOG_TXT = "ChangeLog.txt"
|
||||
SBO_REPO_MIRROR = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
SBO_REPO_SLACKBUILDS = "SLACKBUILDS.TXT"
|
||||
SBO_REPO_CHANGELOG = "ChangeLog.txt"
|
||||
SBO_REPO_TAR_SUFFIX = ".tar.gz"
|
||||
SBO_REPO_TAG = "_SBo"
|
||||
|
||||
PONCE_REPO_NAME = "ponce"
|
||||
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_MIRROR = "https://cgit.ponce.cc/slackbuilds/plain/"
|
||||
PONCE_REPO_SLACKBUILDS = "SLACKBUILDS.TXT"
|
||||
PONCE_REPO_CHANGELOG = "ChangeLog.txt"
|
||||
PONCE_REPO_TAG = "_SBo"
|
||||
|
||||
GNOME_REPO_NAME = "gnome"
|
||||
GNOME_REPO = true
|
||||
GNOME_REPO_URL = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
|
||||
GNOME_REPO_PKG_TXT = "PACKAGES.TXT"
|
||||
GNOME_REPO_CHGLOG_TXT = "ChangeLog.txt"
|
||||
GNOME_REPO_MIRROR = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
|
||||
GNOME_REPO_PACKAGES = "PACKAGES.TXT"
|
||||
GNOME_REPO_CHECKSUMS = "CHECKSUMS.md5"
|
||||
GNOME_REPO_CHANGELOG = "ChangeLog.txt"
|
||||
|
||||
CONRAID_REPO_NAME = "conraid"
|
||||
CONRAID_REPO = true
|
||||
CONRAID_REPO_URL = "https://slack.conraid.net/repository/slackware64-current/"
|
||||
CONRAID_REPO_PKG_TXT = "PACKAGES.TXT"
|
||||
CONRAID_REPO_CHGLOG_TXT = "ChangeLog.txt"
|
||||
CONRAID_REPO_MIRROR = "https://slack.conraid.net/repository/slackware64-current/"
|
||||
CONRAID_REPO_PACKAGES = "PACKAGES.TXT"
|
||||
CONRAID_REPO_CHECKSUMS = "CHECKSUMS.md5"
|
||||
CONRAID_REPO_CHANGELOG = "ChangeLog.txt"
|
||||
|
|
|
@ -40,24 +40,24 @@ class CheckUpdates(Configs):
|
|||
|
||||
if self.utils.is_option(self.flag_binary, self.flags):
|
||||
if self.repos.gnome_repo:
|
||||
self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_chglog_pkg_txt)
|
||||
self.repo_chg_txt: str = f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_chglog_pkg_txt}'
|
||||
self.local_chg_txt: Path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
|
||||
self.repo_chg_txt: str = f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}'
|
||||
compare[self.repos.gnome_repo_name] = self.compare_dates()
|
||||
|
||||
if self.repos.conraid_repo:
|
||||
self.local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_chglog_pkg_txt)
|
||||
self.repo_chg_txt: str = f'{self.repos.conraid_repo_url}{self.repos.conraid_repo_chglog_pkg_txt}'
|
||||
self.local_chg_txt: Path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
|
||||
self.repo_chg_txt: str = f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}'
|
||||
compare[self.repos.conraid_repo_name] = self.compare_dates()
|
||||
|
||||
else:
|
||||
if self.repos.ponce_repo:
|
||||
self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_chglog_txt)
|
||||
self.repo_chg_txt: str = f'{self.repos.ponce_repo_url}{self.repos.ponce_repo_chglog_txt}'
|
||||
self.local_chg_txt: Path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)
|
||||
self.repo_chg_txt: str = f'{self.repos.ponce_repo_mirror}{self.repos.ponce_repo_changelog}'
|
||||
compare[self.repos.ponce_repo_name] = self.compare_dates()
|
||||
|
||||
else:
|
||||
self.local_chg_txt: Path = Path(self.repos.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.local_chg_txt: Path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
|
||||
self.repo_chg_txt: str = f'{self.repos.sbo_repo_mirror}{self.repos.sbo_repo_changelog}'
|
||||
compare[self.repos.sbo_repo_name] = self.compare_dates()
|
||||
|
||||
return compare
|
||||
|
|
|
@ -47,7 +47,7 @@ class Download(Configs, Utilities):
|
|||
shutil.copytree(ponce_repo_path_package, Path(download_path, sbo))
|
||||
else:
|
||||
file: str = f'{sbo}{self.repos.sbo_repo_tar_suffix}'
|
||||
url: list = [f'{self.repos.sbo_repo_url}{location}/{file}']
|
||||
url: list = [f'{self.repos.sbo_repo_mirror}{location}/{file}']
|
||||
down_sbo = Downloader(download_path, url, self.flags)
|
||||
down_sbo.download()
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ class CreateData(Configs):
|
|||
'SLACKBUILD SHORT DESCRIPTION:'
|
||||
]
|
||||
sbo_table = SBoTable
|
||||
path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_txt)
|
||||
path = Path(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
|
||||
|
||||
if self.repos.ponce_repo:
|
||||
sbo_table = PonceTable
|
||||
path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_txt)
|
||||
path = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
|
||||
|
||||
slackbuilds_txt: list = self.utils.read_file(path)
|
||||
|
||||
|
@ -77,7 +77,7 @@ class CreateData(Configs):
|
|||
'PACKAGE SIZE (uncompressed):',
|
||||
'PACKAGE DESCRIPTION:'
|
||||
]
|
||||
path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_pkg_txt)
|
||||
path = Path(self.repos.gnome_repo_path, self.repos.gnome_repo_packages)
|
||||
|
||||
packages_txt: list = self.utils.read_file(path)
|
||||
|
||||
|
@ -148,7 +148,7 @@ class CreateData(Configs):
|
|||
'PACKAGE SIZE (uncompressed):',
|
||||
'PACKAGE DESCRIPTION:'
|
||||
]
|
||||
path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_pkg_txt)
|
||||
path = Path(self.repos.conraid_repo_path, self.repos.conraid_repo_packages)
|
||||
|
||||
packages_txt: list = self.utils.read_file(path)
|
||||
|
||||
|
|
|
@ -26,33 +26,35 @@ class Repositories:
|
|||
|
||||
sbo_repo_name: str = 'sbo'
|
||||
sbo_repo_path: Path = Path(config.lib_path, 'repositories', sbo_repo_name)
|
||||
sbo_repo_url: str = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
sbo_repo_txt: str = "SLACKBUILDS.TXT"
|
||||
sbo_repo_chglog_txt: str = "ChangeLog.txt"
|
||||
sbo_repo_mirror: str = "https://slackbuilds.org/slackbuilds/15.0/"
|
||||
sbo_repo_slackbuilds: str = "SLACKBUILDS.TXT"
|
||||
sbo_repo_changelog: str = "ChangeLog.txt"
|
||||
sbo_repo_tar_suffix: str = ".tar.gz"
|
||||
sbo_repo_tag: str = "_SBo"
|
||||
|
||||
ponce_repo_name: str = 'ponce'
|
||||
ponce_repo: bool = False
|
||||
ponce_repo_path: Path = Path(config.lib_path, 'repositories', ponce_repo_name)
|
||||
ponce_repo_url: str = "https://cgit.ponce.cc/slackbuilds/plain/"
|
||||
ponce_repo_txt: str = "SLACKBUILDS.TXT"
|
||||
ponce_repo_chglog_txt: str = "ChangeLog.txt"
|
||||
ponce_repo_mirror: str = "https://cgit.ponce.cc/slackbuilds/plain/"
|
||||
ponce_repo_slackbuilds: str = "SLACKBUILDS.TXT"
|
||||
ponce_repo_changelog: str = "ChangeLog.txt"
|
||||
ponce_repo_tag: str = "_SBo"
|
||||
|
||||
gnome_repo_name: str = 'gnome'
|
||||
gnome_repo: bool = True
|
||||
gnome_repo_path: Path = Path(config.lib_path, 'repositories', gnome_repo_name)
|
||||
gnome_repo_url: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
|
||||
gnome_repo_pkg_txt: str = "PACKAGES.TXT"
|
||||
gnome_repo_chglog_pkg_txt: str = "ChangeLog.txt"
|
||||
gnome_repo_mirror: str = "https://reddoglinux.ddns.net/linux/gnome/43.x/x86_64/"
|
||||
gnome_repo_packages: str = "PACKAGES.TXT"
|
||||
gnome_repo_checksums: str = "CHECKSUMS.md5"
|
||||
gnome_repo_changelog: str = "ChangeLog.txt"
|
||||
|
||||
conraid_repo_name: str = 'conraid'
|
||||
conraid_repo: bool = True
|
||||
conraid_repo_path: Path = Path(config.lib_path, 'repositories', conraid_repo_name)
|
||||
conraid_repo_url: str = "https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/"
|
||||
conraid_repo_pkg_txt: str = "PACKAGES.TXT"
|
||||
conraid_repo_chglog_pkg_txt: str = "ChangeLog.txt"
|
||||
conraid_repo_mirror: str = "https://reddoglinux.ddns.net/linux/conraid_43.x/x86_64/"
|
||||
conraid_repo_packages: str = "PACKAGES.TXT"
|
||||
conraid_repo_checksums: str = "CHECKSUMS.md5"
|
||||
conraid_repo_changelog: str = "ChangeLog.txt"
|
||||
|
||||
repo_tag: str = sbo_repo_tag
|
||||
|
||||
|
@ -62,30 +64,32 @@ class Repositories:
|
|||
repos = tomli.load(repo)['REPOSITORIES']
|
||||
|
||||
sbo_repo_name: str = repos['SBO_REPO_NAME']
|
||||
sbo_repo_url: str = repos['SBO_REPO_URL']
|
||||
sbo_repo_txt: str = repos['SBO_REPO_TXT']
|
||||
sbo_repo_chglog_txt: str = repos['SBO_REPO_CHGLOG_TXT']
|
||||
sbo_repo_mirror: str = repos['SBO_REPO_MIRROR']
|
||||
sbo_repo_slackbuilds: str = repos['SBO_REPO_SLACKBUILDS']
|
||||
sbo_repo_changelog: str = repos['SBO_REPO_CHANGELOG']
|
||||
sbo_repo_tar_suffix: str = repos['SBO_REPO_TAR_SUFFIX']
|
||||
sbo_repo_tag: str = repos['SBO_REPO_TAG']
|
||||
|
||||
ponce_repo_name: str = repos['PONCE_REPO_NAME']
|
||||
ponce_repo: bool = repos['PONCE_REPO']
|
||||
ponce_repo_url: str = repos['PONCE_REPO_URL']
|
||||
ponce_repo_txt: str = repos['PONCE_REPO_TXT']
|
||||
ponce_repo_chglog_txt: str = repos['PONCE_REPO_CHGLOG_TXT']
|
||||
ponce_repo_mirror: str = repos['PONCE_REPO_MIRROR']
|
||||
ponce_repo_slackbuilds: str = repos['PONCE_REPO_SLACKBUILDS']
|
||||
ponce_repo_changelog: str = repos['PONCE_REPO_CHANGELOG']
|
||||
ponce_repo_tag: str = repos['PONCE_REPO_TAG']
|
||||
|
||||
gnome_repo_name: str = repos['GNOME_REPO_NAME']
|
||||
gnome_repo: bool = repos['GNOME_REPO']
|
||||
gnome_repo_url: str = repos['GNOME_REPO_URL']
|
||||
gnome_repo_pkg_txt: str = repos['GNOME_REPO_PKG_TXT']
|
||||
gnome_repo_chglog_pkg_txt: str = repos['GNOME_REPO_CHGLOG_TXT']
|
||||
gnome_repo_mirror: str = repos['GNOME_REPO_MIRROR']
|
||||
gnome_repo_packages: str = repos['GNOME_REPO_PACKAGES']
|
||||
gnome_repo_checksums: str = repos['GNOME_REPO_CHECKSUMS']
|
||||
gnome_repo_changelog: str = repos['GNOME_REPO_CHANGELOG']
|
||||
|
||||
conraid_repo_name: str = repos['CONRAID_REPO_NAME']
|
||||
conraid_repo: bool = repos['CONRAID_REPO']
|
||||
conraid_repo_url: str = repos['CONRAID_REPO_URL']
|
||||
conraid_repo_pkg_txt: str = repos['CONRAID_REPO_PKG_TXT']
|
||||
conraid_repo_chglog_pkg_txt: str = repos['CONRAID_REPO_CHGLOG_TXT']
|
||||
conraid_repo_mirror: str = repos['CONRAID_REPO_MIRROR']
|
||||
conraid_repo_packages: str = repos['CONRAID_REPO_PACKAGES']
|
||||
conraid_repo_checksums: str = repos['CONRAID_REPO_CHECKSUMS']
|
||||
conraid_repo_changelog: str = repos['CONRAID_REPO_CHANGELOG']
|
||||
|
||||
except (tomli.TOMLDecodeError, KeyError) as error:
|
||||
raise SystemExit(f"\n{config.prog_name} {bred}Error{endc}: {error}: in the configuration file "
|
||||
|
|
|
@ -66,11 +66,12 @@ class UpdateRepository(Configs):
|
|||
print(f"Downloading the '{self.green}{self.repos.gnome_repo_name}{self.endc}' repository, please wait...\n")
|
||||
self.make_dirs(self.repos.gnome_repo_name)
|
||||
|
||||
urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_pkg_txt}')
|
||||
urls.append(f'{self.repos.gnome_repo_url}{self.repos.gnome_repo_chglog_pkg_txt}')
|
||||
urls.append(f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_packages}')
|
||||
urls.append(f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_changelog}')
|
||||
urls.append(f'{self.repos.gnome_repo_mirror}{self.repos.gnome_repo_checksums}')
|
||||
|
||||
self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_pkg_txt)
|
||||
self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_chglog_pkg_txt)
|
||||
self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_packages)
|
||||
self.delete_file(self.repos.gnome_repo_path, self.repos.gnome_repo_changelog)
|
||||
|
||||
down = Downloader(self.repos.gnome_repo_path, urls, self.flags)
|
||||
down.download()
|
||||
|
@ -88,11 +89,11 @@ class UpdateRepository(Configs):
|
|||
f"repository, please wait...\n")
|
||||
self.make_dirs(self.repos.conraid_repo_name)
|
||||
|
||||
urls.append(f'{self.repos.conraid_repo_url}{self.repos.conraid_repo_pkg_txt}')
|
||||
urls.append(f'{self.repos.conraid_repo_url}{self.repos.conraid_repo_chglog_pkg_txt}')
|
||||
urls.append(f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_packages}')
|
||||
urls.append(f'{self.repos.conraid_repo_mirror}{self.repos.conraid_repo_changelog}')
|
||||
|
||||
self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_pkg_txt)
|
||||
self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_chglog_pkg_txt)
|
||||
self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_packages)
|
||||
self.delete_file(self.repos.conraid_repo_path, self.repos.conraid_repo_changelog)
|
||||
|
||||
down = Downloader(self.repos.conraid_repo_path, urls, self.flags)
|
||||
down.download()
|
||||
|
@ -110,20 +111,20 @@ class UpdateRepository(Configs):
|
|||
print('Updating the packages list...\n')
|
||||
print(f"Downloading the '{self.green}{self.repos.ponce_repo_name}"
|
||||
f"{self.endc}' repository, please wait...\n")
|
||||
self.delete_file(self.repos.ponce_repo_path, self.repos .ponce_repo_txt)
|
||||
lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.ponce_repo_url} '
|
||||
self.delete_file(self.repos.ponce_repo_path, self.repos .ponce_repo_slackbuilds)
|
||||
lftp_command: str = (f'lftp {self.lftp_mirror_options} {self.repos.ponce_repo_mirror} '
|
||||
f'{self.repos.ponce_repo_path}')
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
# Remove the SLACKBUILDS.TXT file before generating the new one.
|
||||
sbo_file_txt = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_txt)
|
||||
sbo_file_txt = Path(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
|
||||
if sbo_file_txt.is_file():
|
||||
sbo_file_txt.unlink()
|
||||
|
||||
# Generating the ponce SLACKBUILDS.TXT file.
|
||||
print(f'Generating the {self.repos.ponce_repo_txt} file... ', end='', flush=True)
|
||||
print(f'Generating the {self.repos.ponce_repo_slackbuilds} file... ', end='', flush=True)
|
||||
os.chdir(self.repos.ponce_repo_path)
|
||||
gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_txt}'
|
||||
gen_command: str = f'./gen_sbo_txt.sh > {self.repos.ponce_repo_slackbuilds}'
|
||||
self.utils.process(gen_command)
|
||||
print('\n')
|
||||
|
||||
|
@ -131,11 +132,11 @@ class UpdateRepository(Configs):
|
|||
self.make_dirs(self.repos.sbo_repo_name)
|
||||
print('Updating the packages list...\n')
|
||||
|
||||
self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_txt)
|
||||
self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_chglog_txt)
|
||||
self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
|
||||
self.delete_file(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
|
||||
|
||||
print(f"Downloading the '{self.green}{self.repos.sbo_repo_name}{self.endc}' repository, please wait...\n")
|
||||
lftp_command: str = f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_url} {self.repos.sbo_repo_path}'
|
||||
lftp_command: str = f'lftp {self.lftp_mirror_options} {self.repos.sbo_repo_mirror} {self.repos.sbo_repo_path}'
|
||||
self.utils.process(lftp_command)
|
||||
|
||||
self.delete_sbo_data()
|
||||
|
|
|
@ -25,12 +25,12 @@ class ViewPackage(Configs):
|
|||
|
||||
# Switch between sbo and ponce repository.
|
||||
self.sbo_table = SBoTable
|
||||
self.repo_url: str = self.repos.sbo_repo_url
|
||||
self.repo_url: str = self.repos.sbo_repo_mirror
|
||||
self.repo_path: Path = self.repos.sbo_repo_path
|
||||
self.repo_tar_suffix: str = self.repos.sbo_repo_tar_suffix
|
||||
if self.repos.ponce_repo:
|
||||
self.sbo_table = PonceTable
|
||||
self.repo_url: str = self.repos.ponce_repo_url
|
||||
self.repo_url: str = self.repos.ponce_repo_mirror
|
||||
self.repo_path: Path = self.repos.ponce_repo_path
|
||||
self.repo_tar_suffix: str = ''
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class TestConfigs(unittest.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.repos = Repositories()
|
||||
self.sbo_txt = self.repos.sbo_repo_txt
|
||||
self.sbo_txt = self.repos.sbo_repo_slackbuilds
|
||||
self.sbo_tar_suffix = self.repos.sbo_repo_tar_suffix
|
||||
self.sbo_repo_tag = self.repos.sbo_repo_tag
|
||||
self.os_arch = Configs.os_arch
|
||||
|
|
Loading…
Reference in a new issue