From 6e1bc0c921078d576fe366c77df46b2fd509f430 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Mon, 15 Apr 2024 12:01:15 +0300 Subject: [PATCH] Added to support custom repos --- ChangeLog.txt | 3 +++ configs/repositories.toml | 16 +++++++++++++++- slpkg/repositories.py | 32 +++++++++++++++++--------------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 5f16fee8..4717bf70 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,9 @@ - Update: * Updated to read configuration values even they are lower or uppercase +- Added: + * Added to support custom repositories + ### 5.0.5 - 12/04/2024 - Added: * Added maximum parallel for downloading in the config file diff --git a/configs/repositories.toml b/configs/repositories.toml index 444790b5..fa700eff 100644 --- a/configs/repositories.toml +++ b/configs/repositories.toml @@ -1,6 +1,6 @@ # This is the general repositories configuration file of slpkg: # /etc/slpkg/repositories.toml -# Updated: 12/04/2024, Version: 5.0.5 +# Updated: 15/04/2024, Version: 5.0.5 # Set 'true' or 'false' to enable or disable the repository you want. @@ -9,6 +9,20 @@ # if it is necessary. The mirror or every part of the mirror # should end with a slash '/'. +# Template to define a binary custom repository. [NAME], ENABLE, +# MIRROR and TAG options are required as a minimum. MIRROR should +# include ChangeLog.txt, PACKAGES.TXT and CHECKSUMS.md5 files. +# If the files PACKAGES.TXT and CHECKSUMS.md5 are located in +# a different branch with the ChangeLog.txt file, it should be +# set a variable BRANCH. + +# Example: +# [NAME] +# ENABLE = true +# MIRROR = "http://mirror.nl.leaseweb.net/slackware/slackware64-15.0/" +# BRANCH = "extra" +# TAG = "" + # This is the DEFAULT REPOSITORY. # You can change it with one that you see below. # Make sure you have enabled it before. diff --git a/slpkg/repositories.py b/slpkg/repositories.py index 6ab5a5ba..f909f506 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -447,30 +447,32 @@ class Repositories: 'repo_tag': pprkut_repo_tag} } - defaults = list(repositories.keys()) - customs = list(repos_config.keys()) + all_repos = list(repos_config.keys()) + defaults_repos = list(repositories.keys()) - diff_repos = list(set(customs) - set(defaults)) + diff_repos = list(set(all_repos) - set(defaults_repos)) diff_repos.remove('default') if diff_repos: - for repo, config in repos_config.items(): + for repo, data in repos_config.items(): if repo in diff_repos: - changelog_mirror: str = config['mirror'] - - if config['branch']: - changelog_mirror: str = config['branch'] + mirror_packages: str = data.get('mirror', '') + mirror_changelog: str = data.get('mirror', '') + if data.get('branch'): + mirror_changelog: str = data.get('mirror', '') + branch: str = data.get('branch', '') + mirror_packages: str = f'{mirror_changelog}{branch}/' values = { - 'enable': config['enable'], + 'enable': data.get('enable', ''), 'path': Path(repositories_path, repo), - 'mirror_packages': config['mirror'], - 'mirror_changelog': changelog_mirror, - 'packages_txt': 'PACKAGES.TXT', - 'checksums_md5': 'CHECKSUMS.md5', - 'changelog_txt': 'ChangeLog.txt', - 'repo_tag': config['tag'] + 'mirror_packages': mirror_packages, + 'mirror_changelog': mirror_changelog, + 'packages_txt': packages_txt, + 'checksums_md5': checksums_md5, + 'changelog_txt': changelog_txt, + 'repo_tag': data.get('tag', '') } repositories[repo] = values