From 00b621d86b24e93a7e18eb08e7dfaaab5ca88026 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 16 Dec 2023 22:31:47 +0200 Subject: [PATCH] Added slackdce repository --- ChangeLog.txt | 6 ++- configs/repositories.toml | 10 ++++ repositories.txt | 1 + slpkg/install_data.py | 96 ++++++++++++++++++++++++++++++++++++ slpkg/repositories.py | 35 +++++++++++++ slpkg/update_repositories.py | 30 +++++++++++ 6 files changed, 177 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3ecd931e..5d335c54 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,9 @@ ## slpkg - ChangeLog +### 4.9.6 - 16/12/2023 +- Added: + * slackdce repository (Thanks to rizitis) + ### 4.9.5 - 10/12/2023 - Fixed: * Remove packages with option "--yes" @@ -17,7 +21,7 @@ * Process stderr exit code - Added: - * pprkut repository + * pprkut repository (Thanks to rizitis) ### 4.9.2 - 05/08/2023 - Updated: diff --git a/configs/repositories.toml b/configs/repositories.toml index f5e7e329..746aff1d 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -174,6 +174,16 @@ CONRAID_REPO_CHECKSUMS = "CHECKSUMS.md5" CONRAID_REPO_CHANGELOG = "ChangeLog.txt" CONRAID_REPO_TAG = "cf" +# Slackdce repository for Slackware x86_64 15.0 stable. +SLACKDCE_REPO = false +SLACKDCE_REPO_NAME = "slackdce" +SLACKDCE_REPO_LOCAL = [""] +SLACKDCE_REPO_MIRROR = ["https://slackware.uk/slackdce/15.0/x86_64/"] +SLACKDCE_REPO_PACKAGES = "PACKAGES.TXT" +SLACKDCE_REPO_CHECKSUMS = "CHECKSUMS.md5" +SLACKDCE_REPO_CHANGELOG = "ChangeLog.txt" +SLACKDCE_REPO_TAG = "dce" + # Slackonly repository for Slackware x86_64 15.0 stable. # For Slackware x86_64 -current: # ["https://packages.slackonly.com/pub/packages/current-x86_64/"] diff --git a/repositories.txt b/repositories.txt index 71debdae..115dc701 100644 --- a/repositories.txt +++ b/repositories.txt @@ -12,6 +12,7 @@ Supported repositories: > msb: https://slackware.uk/msb/15.0/1.26/x86_64/ > csb: https://slackware.uk/csb/15.0/x86_64/ > conraid: https://slack.conraid.net/repository/slackware64-current/ +> slackdce: https://slackware.uk/slackdce/15.0/x86_64/ > slackonly: https://packages.slackonly.com/pub/packages/15.0-x86_64/ > salixos: https://download.salixos.org/x86_64/slackware-15.0/ > salixos_xtra: https://download.salixos.org/x86_64/slackware-15.0/extra/ diff --git a/slpkg/install_data.py b/slpkg/install_data.py index 40feaee6..035bccb8 100644 --- a/slpkg/install_data.py +++ b/slpkg/install_data.py @@ -1035,6 +1035,102 @@ class InstallData(Configs): self.view_done_message() + def install_slackdce_data(self) -> None: + """ Install the data for slackdce repository. """ + print(f"Updating the database for '{self.cyan}{self.repos.slackdce_repo_name}{self.endc}'... ", + end='', flush=True) + + checksums_dict: dict = {} + pkg_tag = [ + 'PACKAGE NAME:', + 'PACKAGE LOCATION:', + 'PACKAGE SIZE (compressed):', + 'PACKAGE SIZE (uncompressed):', + 'PACKAGE REQUIRED:', + 'PACKAGE DESCRIPTION:' + ] + path_packages: Path = Path(self.repos.slackdce_repo_path, self.repos.slackdce_repo_packages) + path_checksums: Path = Path(self.repos.slackdce_repo_path, self.repos.slackdce_repo_checksums) + path_changelog: Path = Path(self.repos.slackdce_repo_path, self.repos.slackdce_repo_changelog) + packages_txt: list = self.utils.read_text_file(path_packages) + checksums_md5: list = self.utils.read_text_file(path_checksums) + + mirror: str = self.repos.slackdce_repo_mirror[0] + if self.repos.slackdce_repo_local[0].startswith('file'): + mirror: str = self.repos.slackdce_repo_local[0] + + for line in checksums_md5: + line = line.strip() + + if line.endswith(('.txz', '.tgz')): + file: str = line.split('./')[1].split('/')[-1].strip() + checksum: str = line.split('./')[0].strip() + checksums_dict[file] = checksum + + cache: list = [] # init cache + + for line in packages_txt: + + if line.startswith(pkg_tag[0]): + package = line.replace(pkg_tag[0], '').strip() + name: str = self.utils.split_package(package)['name'] + version: str = self.utils.split_package(package)['version'] + cache.append(name) + cache.append(version) + cache.append(package) + cache.append(mirror) + try: + cache.append(checksums_dict[package]) + except KeyError: + cache.append('error checksum') + + if line.startswith(pkg_tag[1]): + package_location = line.replace(pkg_tag[1], '').strip() + cache.append(package_location[2:]) # Do not install (./) dot + + if line.startswith(pkg_tag[2]): + cache.append(''.join(re.findall(r'\d+', line))) + + if line.startswith(pkg_tag[3]): + cache.append(''.join(re.findall(r'\d+', line))) + + if line.startswith(pkg_tag[4]): + required = line.replace(pkg_tag[4], '').strip() + package_required = required.replace(',', ' ').strip() + cache.append(package_required) + + if line.startswith(pkg_tag[5]): + package_description = line.replace(pkg_tag[5], '').strip() + cache.append(package_description) + + if len(cache) == 10: + data: str = BinariesTable( + repo=self.repos.slackdce_repo_name, + name=cache[0], + version=cache[1], + package=cache[2], + mirror=cache[3], + checksum=cache[4], + location=cache[5], + size_comp=cache[6], + size_uncomp=cache[7], + required=cache[8], + description=cache[9], + conflicts='', + suggests='' + ) + + self.session.add(data) + + cache: list = [] # reset cache + + last_updated: str = self.last_updated(path_changelog) + date: str = LastRepoUpdated(repo=self.repos.slackdce_repo_name, date=last_updated) + self.session.add(date) + self.session.commit() + + self.view_done_message() + def install_slackonly_data(self) -> None: """ Install the data for slackonly repository. """ print(f"Updating the database for '{self.cyan}{self.repos.slackonly_repo_name}{self.endc}'... ", diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 42041818..b7388a51 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -143,6 +143,16 @@ class Repositories: conraid_repo_changelog: str = 'ChangeLog.txt' conraid_repo_tag: str = 'cf' + slackdce_repo: bool = False + slackdce_repo_name: str = 'slackdce' + slackdce_repo_path: Path = Path(repositories_path, slackdce_repo_name) + slackdce_repo_local = [''] + slackdce_repo_mirror = ['https://slackware.uk/slackdce/15.0/x86_64/'] + slackdce_repo_packages: str = 'PACKAGES.TXT' + slackdce_repo_checksums: str = 'CHECKSUMS.md5' + slackdce_repo_changelog: str = 'ChangeLog.txt' + slackdce_repo_tag: str = 'dce' + slackonly_repo: bool = False slackonly_repo_name: str = 'slackonly' slackonly_repo_path: Path = Path(repositories_path, slackonly_repo_name) @@ -413,6 +423,22 @@ class Repositories: except IndexError: conraid_repo_local = [''] + slackdce_repo: bool = repos_config['SLACKDCE_REPO'] + slackdce_repo_name: str = repos_config['SLACKDCE_REPO_NAME'] + slackdce_repo_local = repos_config['SLACKDCE_REPO_LOCAL'] + slackdce_repo_mirror = repos_config['SLACKDCE_REPO_MIRROR'] + slackdce_repo_packages: str = repos_config['SLACKDCE_REPO_PACKAGES'] + slackdce_repo_checksums: str = repos_config['SLACKDCE_REPO_CHECKSUMS'] + slackdce_repo_changelog: str = repos_config['SLACKDCE_REPO_CHANGELOG'] + slackdce_repo_tag: str = repos_config['SLACKDCE_REPO_TAG'] + try: + if slackdce_repo_local[0].startswith('file'): + slackdce_repo_path: Path = Path( + ''.join(slackdce_repo_local).replace('file:', '') + ) + except IndexError: + slackdce_repo_local = [''] + slackonly_repo: bool = repos_config['SLACKONLY_REPO'] slackonly_repo_name: str = repos_config['SLACKONLY_REPO_NAME'] slackonly_repo_local = repos_config['SLACKONLY_REPO_LOCAL'] @@ -638,6 +664,15 @@ class Repositories: 'changelog_txt': conraid_repo_changelog, 'repo_tag': conraid_repo_tag}, + slackdce_repo_name: { + 'enable': slackdce_repo, + 'path': slackdce_repo_path, + 'mirror': slackdce_repo_mirror, + 'packages_txt': slackdce_repo_packages, + 'checksums_txt': slackdce_repo_checksums, + 'changelog_txt': slackdce_repo_changelog, + 'repo_tag': slackdce_repo_tag}, + slackonly_repo_name: { 'enable': slackonly_repo, 'path': slackonly_repo_path, diff --git a/slpkg/update_repositories.py b/slpkg/update_repositories.py index fb621a09..b9377607 100644 --- a/slpkg/update_repositories.py +++ b/slpkg/update_repositories.py @@ -69,6 +69,7 @@ class UpdateRepositories(Configs): self.repos.msb_repo_name: self.msb_repository, self.repos.csb_repo_name: self.csb_repository, self.repos.conraid_repo_name: self.conraid_repository, + self.repos.slackdce_repo_name: self.slackdce_repository, self.repos.slackonly_repo_name: self.slackonly_repository, self.repos.salixos_repo_name: self.salixos_repository, self.repos.salixos_extra_repo_name: self.salixos_extra_repository, @@ -405,6 +406,35 @@ class UpdateRepositories(Configs): self.delete_last_updated(self.repos.conraid_repo_name) self.data.install_conraid_data() + def slackdce_repository(self) -> None: + if not self.option_for_install_data: + urls: dict = {} + self.utils.create_directory(self.repos.slackdce_repo_path) + + self.utils.remove_file_if_exists(self.repos.slackdce_repo_path, self.repos.slackdce_repo_changelog) + self.utils.remove_file_if_exists(self.repos.slackdce_repo_path, self.repos.slackdce_repo_packages) + self.utils.remove_file_if_exists(self.repos.slackdce_repo_path, self.repos.slackdce_repo_checksums) + + if self.repos.slackdce_repo_local[0].startswith('file'): + lftp_command: str = ( + f'lftp {self.lftp_mirror_options} {self.repos.slackdce_repo_mirror[0]} ' + f'{self.repos.slackdce_repo_path}' + ) + self.utils.process(lftp_command) + else: + changelog: str = f'{self.repos.slackdce_repo_mirror[0]}{self.repos.slackdce_repo_changelog}' + packages: str = f'{self.repos.slackdce_repo_mirror[0]}{self.repos.slackdce_repo_packages}' + checksums: str = f'{self.repos.slackdce_repo_mirror[0]}{self.repos.slackdce_repo_checksums}' + + urls[self.repos.slackdce_repo_name] = ((changelog, packages, checksums), self.repos.slackdce_repo_path) + + self.download.download(urls) + print() + + self.delete_bin_database_data(self.repos.slackdce_repo_name) + self.delete_last_updated(self.repos.slackdce_repo_name) + self.data.install_slackdce_data() + def slackonly_repository(self) -> None: if not self.option_for_install_data: urls: dict = {}