mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-11-16 07:47:35 +01:00
Updated for git update
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
e39ea72600
commit
35a08f64f1
2 changed files with 43 additions and 5 deletions
|
@ -5,6 +5,7 @@
|
|||
from pathlib import Path
|
||||
from typing import ClassVar
|
||||
from dataclasses import dataclass
|
||||
from urllib.parse import urlparse
|
||||
import tomlkit
|
||||
|
||||
from slpkg.configs import Configs
|
||||
|
@ -163,9 +164,40 @@ class Repositories: # pylint: disable=[R0902]
|
|||
|
||||
sbo_repo: bool = repos_config['SBO']['ENABLE']
|
||||
sbo_repo_mirror: str = repos_config['SBO']['MIRROR']
|
||||
sbo_git_mirror: str = sbo_repo_mirror
|
||||
if sbo_repo_mirror.endswith('.git'):
|
||||
# https://raw.githubusercontent.com/{owner}/{repository}/{branch}/{path_to_file}
|
||||
# https://gitlab.com/{owner}/{repository}/-/raw/{branch}/{path_to_file}
|
||||
parsed_url = urlparse(sbo_git_mirror)
|
||||
path_parts = parsed_url.path.strip("/").split("/")
|
||||
owner = path_parts[0]
|
||||
repository_name: str = path_parts[1].replace('.git', '')
|
||||
if 'github.com' in sbo_git_mirror and sbo_repo_path.is_dir():
|
||||
branch: str = utils.get_git_branch(sbo_repo_path)
|
||||
sbo_repo_mirror: str = f'https://raw.githubusercontent.com/{owner}/{repository_name}/{branch}/'
|
||||
|
||||
if 'gitlab.com' in sbo_git_mirror and sbo_repo_path.is_dir():
|
||||
branch: str = utils.get_git_branch(sbo_repo_path)
|
||||
sbo_repo_mirror: str = f'https://gitlab.com/{owner}/{repository_name}/-/raw/{branch}/'
|
||||
|
||||
ponce_repo: bool = repos_config['PONCE']['ENABLE']
|
||||
ponce_repo_mirror: str = repos_config['PONCE']['MIRROR']
|
||||
ponce_git_mirror: str = ponce_repo_mirror
|
||||
if ponce_repo_mirror.endswith('.git'):
|
||||
# https://raw.githubusercontent.com/{owner}/{repository}/{branch}/{path_to_file}
|
||||
# https://gitlab.com/{owner}/{repository}/-/raw/{branch}/{path_to_file}
|
||||
parsed_url = urlparse(ponce_git_mirror)
|
||||
path_parts = parsed_url.path.strip("/").split("/")
|
||||
owner = path_parts[0]
|
||||
repository_name: str = path_parts[1].replace('.git', '')
|
||||
|
||||
if 'github.com' in ponce_git_mirror and ponce_repo_path.is_dir():
|
||||
branch: str = utils.get_git_branch(ponce_repo_path)
|
||||
ponce_repo_mirror: str = f'https://raw.githubusercontent.com/{owner}/{repository_name}/{branch}/'
|
||||
|
||||
if 'gitlab.com' in ponce_git_mirror and ponce_repo_path.is_dir():
|
||||
branch: str = utils.get_git_branch(ponce_repo_path)
|
||||
ponce_repo_mirror: str = f'https://gitlab.com/{owner}/{repository_name}/-/raw/{branch}/'
|
||||
|
||||
slack_repo: bool = repos_config['SLACK']['ENABLE']
|
||||
slack_repo_mirror: str = repos_config['SLACK']['MIRROR']
|
||||
|
|
|
@ -145,14 +145,20 @@ class UpdateRepositories(Configs): # pylint: disable=[R0902]
|
|||
self.import_gpg_key(repo)
|
||||
|
||||
mirror: str = self.repos.repositories[repo]['mirror_packages']
|
||||
repo_path: str = self.repos.repositories[repo]['path']
|
||||
|
||||
git_mirror: dict = {
|
||||
self.repos.sbo_repo_name: self.repos.sbo_git_mirror,
|
||||
self.repos.ponce_repo_name: self.repos.ponce_git_mirror
|
||||
}
|
||||
|
||||
repo_path: Path = self.repos.repositories[repo]['path']
|
||||
|
||||
self.utils.remove_file_if_exists(repo_path, self.repos.repositories[repo]['slackbuilds_txt'])
|
||||
self.utils.remove_file_if_exists(repo_path, self.repos.repositories[repo]['changelog_txt'])
|
||||
|
||||
if mirror.endswith('.git'):
|
||||
if '.git' in git_mirror[repo]:
|
||||
self.utils.remove_folder_if_exists(repo_path)
|
||||
syncing_command: str = f"{self.git_clone} {mirror} {repo_path}"
|
||||
syncing_command: str = f"{self.git_clone} {git_mirror[repo]} {repo_path}"
|
||||
else:
|
||||
self.utils.create_directory(repo_path)
|
||||
syncing_command: str = f"lftp {self.lftp_mirror_options} {mirror} {repo_path}"
|
||||
|
@ -162,8 +168,8 @@ class UpdateRepositories(Configs): # pylint: disable=[R0902]
|
|||
# It checks if there is a SLACKBUILDS.TXT file, otherwise it's going to create one.
|
||||
if not Path(self.repos.repositories[repo]['path'],
|
||||
self.repos.repositories[repo]['slackbuilds_txt']).is_file():
|
||||
if mirror.endswith('.git'):
|
||||
print() # New line for .git mirror
|
||||
if '.git' in git_mirror[repo]:
|
||||
print()
|
||||
self.generate.slackbuild_file(self.repos.repositories[repo]['path'],
|
||||
self.repos.repositories[repo]['slackbuilds_txt'])
|
||||
|
||||
|
|
Loading…
Reference in a new issue