Added to support custom repos

This commit is contained in:
Dimitris Zlatanidis 2024-04-15 12:01:15 +03:00
parent fd69e18685
commit 6e1bc0c921
3 changed files with 35 additions and 16 deletions

View file

@ -4,6 +4,9 @@
- Update: - Update:
* Updated to read configuration values even they are lower or uppercase * Updated to read configuration values even they are lower or uppercase
- Added:
* Added to support custom repositories
### 5.0.5 - 12/04/2024 ### 5.0.5 - 12/04/2024
- Added: - Added:
* Added maximum parallel for downloading in the config file * Added maximum parallel for downloading in the config file

View file

@ -1,6 +1,6 @@
# This is the general repositories configuration file of slpkg: # This is the general repositories configuration file of slpkg:
# /etc/slpkg/repositories.toml # /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. # 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 # if it is necessary. The mirror or every part of the mirror
# should end with a slash '/'. # 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. # This is the DEFAULT REPOSITORY.
# You can change it with one that you see below. # You can change it with one that you see below.
# Make sure you have enabled it before. # Make sure you have enabled it before.

View file

@ -447,30 +447,32 @@ class Repositories:
'repo_tag': pprkut_repo_tag} 'repo_tag': pprkut_repo_tag}
} }
defaults = list(repositories.keys()) all_repos = list(repos_config.keys())
customs = 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') diff_repos.remove('default')
if diff_repos: if diff_repos:
for repo, config in repos_config.items(): for repo, data in repos_config.items():
if repo in diff_repos: if repo in diff_repos:
changelog_mirror: str = config['mirror'] mirror_packages: str = data.get('mirror', '')
mirror_changelog: str = data.get('mirror', '')
if config['branch']: if data.get('branch'):
changelog_mirror: str = config['branch'] mirror_changelog: str = data.get('mirror', '')
branch: str = data.get('branch', '')
mirror_packages: str = f'{mirror_changelog}{branch}/'
values = { values = {
'enable': config['enable'], 'enable': data.get('enable', ''),
'path': Path(repositories_path, repo), 'path': Path(repositories_path, repo),
'mirror_packages': config['mirror'], 'mirror_packages': mirror_packages,
'mirror_changelog': changelog_mirror, 'mirror_changelog': mirror_changelog,
'packages_txt': 'PACKAGES.TXT', 'packages_txt': packages_txt,
'checksums_md5': 'CHECKSUMS.md5', 'checksums_md5': checksums_md5,
'changelog_txt': 'ChangeLog.txt', 'changelog_txt': changelog_txt,
'repo_tag': config['tag'] 'repo_tag': data.get('tag', '')
} }
repositories[repo] = values repositories[repo] = values