Added extra lftp options config.

This commit is contained in:
Dimitris Zlatanidis 2024-04-04 20:41:12 +03:00
parent 7b7c8db3a2
commit b39aed3f81
4 changed files with 44 additions and 26 deletions

View file

@ -1,6 +1,6 @@
## slpkg - ChangeLog
### 5.0.4 - 03/04/2024
### 5.0.4 - 04/04/2024
- Updated:
* Updated to ignore blacklist installed packages
* Updated progress bar spinners
@ -12,6 +12,9 @@
* Fixed compare invalid packages version
* Fixed to work with locals repositories
- Added:
* Added extra lftp mirror options in the config file
### 5.0.3 - 01/04/2024
- Updated:
* Updated for slpkg_new-configs and (D)iff command (Thanks to Marav)

View file

@ -121,6 +121,12 @@ LFTP_GET_OPTIONS = "-c get -e"
# Ponce repositories or for the local repositories.
LFTP_MIRROR_OPTIONS = "-c mirror --parallel=100 --only-newer --delete"
# Extra lftp options by repository, using a key = value pair.
# Example, if you want to exclude some files or directories:
# {"slack" = "-x source/ -x patches/", "sbo" = "-x '*.tar.gz*'"}
# Be sure of the name, as set it in the /etc/slpkg/repositories.toml file.
LFTP_MIRROR_EXTRA_OPTIONS = {}
# Python urllib3 settings used for checking between two changelog files.
# Timeouts allow you to control how long (in seconds) requests are allowed
# to run before being aborted. In simple cases, you can specify a timeout

View file

@ -50,6 +50,7 @@ class Configs:
curl_options: str = ''
lftp_get_options: str = '-c get -e'
lftp_mirror_options: str = '-c mirror --parallel=100 --only-newer --delete'
lftp_mirror_extra_options = {}
ascii_characters: bool = True
ask_question: bool = True
parallel_downloads: bool = False
@ -95,6 +96,7 @@ class Configs:
curl_options: str = config['CURL_OPTIONS']
lftp_get_options: str = config['LFTP_GET_OPTIONS']
lftp_mirror_options: str = config['LFTP_MIRROR_OPTIONS']
lftp_mirror_extra_options = config['LFTP_MIRROR_EXTRA_OPTIONS']
ascii_characters: bool = config['ASCII_CHARACTERS']
file_list_suffix: str = config['FILE_LIST_SUFFIX']
parallel_downloads: bool = config['PARALLEL_DOWNLOADS']

View file

@ -34,6 +34,7 @@ class UpdateRepositories(Configs):
self.download = Downloader(flags)
self.repos_for_update: dict = {}
self.lftp_extra_options: str = ' '
self.option_for_repository: bool = self.utils.is_option(
('-o', '--repository='), flags)
@ -74,16 +75,22 @@ class UpdateRepositories(Configs):
if self.option_for_repository:
self.view_downloading_message(self.repository)
self.set_lftp_extra_options(self.repository)
repositories[self.repository]()
else:
for repo, update in self.repos_for_update.items():
if update:
self.view_downloading_message(repo)
self.set_lftp_extra_options(repo)
repositories[repo]()
def view_downloading_message(self, repo: str) -> None:
print(f"Syncing with the repository '{self.green}{repo}{self.endc}', please wait...\n")
def set_lftp_extra_options(self, repository: str) -> None:
if self.lftp_mirror_extra_options.get(repository):
self.lftp_extra_options: str = f' {self.lftp_mirror_extra_options[repository]} '
def slack_repository(self) -> None:
urls: dict = {}
self.utils.create_directory(self.repos.slack_repo_path)
@ -94,7 +101,7 @@ class UpdateRepositories(Configs):
if self.repos.slack_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.slack_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.slack_repo_mirror[0]} '
f'{self.repos.slack_repo_path}'
)
self.multi_process.process(lftp_command)
@ -122,8 +129,8 @@ class UpdateRepositories(Configs):
if self.repos.slack_extra_repo_local[0].startswith('file'):
urls[self.repos.slack_extra_repo_name] = ((changelog,), self.repos.slack_extra_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.slack_extra_repo_mirror)} '
f'{self.repos.slack_extra_repo_path}'
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{"".join(self.repos.slack_extra_repo_mirror)} {self.repos.slack_extra_repo_path}'
)
self.multi_process.process(lftp_command)
else:
@ -152,8 +159,8 @@ class UpdateRepositories(Configs):
if self.repos.slack_patches_repo_local[0].startswith('file'):
urls[self.repos.slack_patches_repo_name] = ((changelog,), self.repos.slack_patches_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.slack_patches_repo_mirror)} '
f'{self.repos.slack_patches_repo_path}'
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{"".join(self.repos.slack_patches_repo_mirror)} {self.repos.slack_patches_repo_path}'
)
self.multi_process.process(lftp_command)
else:
@ -182,7 +189,7 @@ class UpdateRepositories(Configs):
if self.repos.alien_repo_local[0].startswith('file'):
urls[self.repos.alien_repo_name] = ((changelog,), self.repos.alien_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.alien_repo_mirror)} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{"".join(self.repos.alien_repo_mirror)} '
f'{self.repos.alien_repo_path}'
)
self.multi_process.process(lftp_command)
@ -210,7 +217,7 @@ class UpdateRepositories(Configs):
if self.repos.multilib_repo_local[0].startswith('file'):
urls[self.repos.multilib_repo_name] = ((changelog,), self.repos.multilib_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.multilib_repo_mirror)} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{"".join(self.repos.multilib_repo_mirror)} '
f'{self.repos.multilib_repo_path}'
)
self.multi_process.process(lftp_command)
@ -238,8 +245,8 @@ class UpdateRepositories(Configs):
if self.repos.restricted_repo_local[0].startswith('file'):
urls[self.repos.restricted_repo_name] = ((changelog,), self.repos.restricted_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.restricted_repo_mirror)} '
f'{self.repos.restricted_repo_path}'
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{"".join(self.repos.restricted_repo_mirror)} {self.repos.restricted_repo_path}'
)
self.multi_process.process(lftp_command)
else:
@ -263,7 +270,7 @@ class UpdateRepositories(Configs):
if self.repos.gnome_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.gnome_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.gnome_repo_mirror[0]} '
f'{self.repos.gnome_repo_path}'
)
self.multi_process.process(lftp_command)
@ -291,7 +298,7 @@ class UpdateRepositories(Configs):
if self.repos.msb_repo_local[0].startswith('file'):
urls[self.repos.msb_repo_name] = ((changelog,), self.repos.msb_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.msb_repo_mirror)} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{"".join(self.repos.msb_repo_mirror)} '
f'{self.repos.msb_repo_path}'
)
self.multi_process.process(lftp_command)
@ -315,7 +322,7 @@ class UpdateRepositories(Configs):
if self.repos.csb_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.csb_repo_mirror)} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{"".join(self.repos.csb_repo_mirror)} '
f'{self.repos.csb_repo_path}'
)
self.multi_process.process(lftp_command)
@ -340,7 +347,7 @@ class UpdateRepositories(Configs):
if self.repos.conraid_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.conraid_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.conraid_repo_mirror[0]} '
f'{self.repos.conraid_repo_path}'
)
self.multi_process.process(lftp_command)
@ -365,7 +372,7 @@ class UpdateRepositories(Configs):
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'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.slackdce_repo_mirror[0]} '
f'{self.repos.slackdce_repo_path}'
)
self.multi_process.process(lftp_command)
@ -390,7 +397,7 @@ class UpdateRepositories(Configs):
if self.repos.slackonly_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.slackonly_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.slackonly_repo_mirror[0]} '
f'{self.repos.slackonly_repo_path}'
)
self.multi_process.process(lftp_command)
@ -416,7 +423,7 @@ class UpdateRepositories(Configs):
if self.repos.salixos_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.salixos_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.salixos_repo_mirror[0]} '
f'{self.repos.salixos_repo_path}'
)
self.multi_process.process(lftp_command)
@ -447,8 +454,8 @@ class UpdateRepositories(Configs):
if self.repos.salixos_extra_repo_local[0].startswith('file'):
urls[self.repos.salixos_extra_repo_name] = ((changelog,), self.repos.salixos_extra_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.salixos_extra_repo_mirror)} '
f'{self.repos.salixos_extra_repo_path}'
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{"".join(self.repos.salixos_extra_repo_mirror)} {self.repos.salixos_extra_repo_path}'
)
self.multi_process.process(lftp_command)
else:
@ -480,8 +487,8 @@ class UpdateRepositories(Configs):
if self.repos.salixos_patches_repo_local[0].startswith('file'):
urls[self.repos.salixos_patches_repo_name] = ((changelog,), self.repos.salixos_patches_repo_path)
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {"".join(self.repos.salixos_patches_repo_mirror)} '
f'{self.repos.salixos_patches_repo_path}'
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{"".join(self.repos.salixos_patches_repo_mirror)} {self.repos.salixos_patches_repo_path}'
)
self.multi_process.process(lftp_command)
else:
@ -507,7 +514,7 @@ class UpdateRepositories(Configs):
if self.repos.slackel_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.slackel_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.slackel_repo_mirror[0]} '
f'{self.repos.slackel_repo_path}'
)
self.multi_process.process(lftp_command)
@ -532,7 +539,7 @@ class UpdateRepositories(Configs):
if self.repos.slint_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.slint_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.slint_repo_mirror[0]} '
f'{self.repos.slint_repo_path}'
)
self.multi_process.process(lftp_command)
@ -557,7 +564,7 @@ class UpdateRepositories(Configs):
if self.repos.pprkut_repo_local[0].startswith('file'):
lftp_command: str = (
f'lftp {self.lftp_mirror_options} {self.repos.pprkut_repo_mirror[0]} '
f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}{self.repos.pprkut_repo_mirror[0]} '
f'{self.repos.pprkut_repo_path}'
)
self.multi_process.process(lftp_command)
@ -578,7 +585,7 @@ class UpdateRepositories(Configs):
self.utils.remove_file_if_exists(self.repos.ponce_repo_path, self.repos.ponce_repo_slackbuilds)
self.utils.remove_file_if_exists(self.repos.ponce_repo_path, self.repos.ponce_repo_changelog)
lftp_command: str = (f'lftp {self.lftp_mirror_options} '
lftp_command: str = (f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{self.repos.ponce_repo_mirror[0]} {self.repos.ponce_repo_path}')
self.multi_process.process(lftp_command)
@ -594,7 +601,7 @@ class UpdateRepositories(Configs):
self.utils.remove_file_if_exists(self.repos.sbo_repo_path, self.repos.sbo_repo_slackbuilds)
self.utils.remove_file_if_exists(self.repos.sbo_repo_path, self.repos.sbo_repo_changelog)
lftp_command: str = (f'lftp {self.lftp_mirror_options} '
lftp_command: str = (f'lftp {self.lftp_mirror_options}{self.lftp_extra_options}'
f'{self.repos.sbo_repo_mirror[0]} {self.repos.sbo_repo_path}')
self.multi_process.process(lftp_command)