mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Use gitlab pages as mirror
This commit is contained in:
parent
b144029517
commit
846f5422fd
2 changed files with 42 additions and 8 deletions
|
|
@ -114,7 +114,7 @@ def make(apps, sortedids, apks, repodir, archive):
|
||||||
else:
|
else:
|
||||||
mirrors.append(urllib.parse.urljoin(mirror + '/', urlbasepath))
|
mirrors.append(urllib.parse.urljoin(mirror + '/', urlbasepath))
|
||||||
for mirror in common.config.get('servergitmirrors', []):
|
for mirror in common.config.get('servergitmirrors', []):
|
||||||
mirror = get_raw_mirror(mirror)
|
mirror = get_mirror_service_url(mirror)
|
||||||
if mirror is not None:
|
if mirror is not None:
|
||||||
mirrors.append(mirror + '/')
|
mirrors.append(mirror + '/')
|
||||||
if mirrorcheckfailed:
|
if mirrorcheckfailed:
|
||||||
|
|
@ -517,7 +517,7 @@ def extract_pubkey():
|
||||||
return hexlify(pubkey), repo_pubkey_fingerprint
|
return hexlify(pubkey), repo_pubkey_fingerprint
|
||||||
|
|
||||||
|
|
||||||
def get_raw_mirror(url):
|
def get_mirror_service_url(url):
|
||||||
'''Get direct URL from git service for use by fdroidclient
|
'''Get direct URL from git service for use by fdroidclient
|
||||||
|
|
||||||
Via 'servergitmirrors', fdroidserver can create and push a mirror
|
Via 'servergitmirrors', fdroidserver can create and push a mirror
|
||||||
|
|
@ -531,23 +531,27 @@ def get_raw_mirror(url):
|
||||||
url = re.sub(r'^git@(.*):(.*)', r'https://\1/\2', url)
|
url = re.sub(r'^git@(.*):(.*)', r'https://\1/\2', url)
|
||||||
|
|
||||||
segments = url.split("/")
|
segments = url.split("/")
|
||||||
|
|
||||||
|
if segments[4].endswith('.git'):
|
||||||
|
segments[4] = segments[4][:-4]
|
||||||
|
|
||||||
hostname = segments[2]
|
hostname = segments[2]
|
||||||
|
user = segments[3]
|
||||||
|
repo = segments[4]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
folder = "fdroid"
|
folder = "fdroid"
|
||||||
|
|
||||||
if hostname == "github.com":
|
if hostname == "github.com":
|
||||||
# Github like RAW segments "https://raw.githubusercontent.com/user/repo/master/fdroid"
|
# Github-like RAW segments "https://raw.githubusercontent.com/user/repo/master/fdroid"
|
||||||
segments[2] = "raw.githubusercontent.com"
|
segments[2] = "raw.githubusercontent.com"
|
||||||
segments.extend([branch, folder])
|
segments.extend([branch, folder])
|
||||||
elif hostname == "gitlab.com":
|
elif hostname == "gitlab.com":
|
||||||
# Gitlab like RAW segments "https://gitlab.com/user/repo/raw/master/fdroid"
|
# Gitlab-like Pages segments "https://user.gitlab.com/repo/fdroid"
|
||||||
segments.extend(["raw", branch, folder])
|
gitlab_url = ["https:", "", user + ".gitlab.io", repo, folder]
|
||||||
|
segments = gitlab_url
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if segments[4].endswith('.git'):
|
|
||||||
segments[4] = segments[4][:-4]
|
|
||||||
|
|
||||||
return '/'.join(segments)
|
return '/'.join(segments)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,36 @@ def update_servergitmirrors(servergitmirrors, repo_section):
|
||||||
logging.debug('Pushing to ' + remote.url)
|
logging.debug('Pushing to ' + remote.url)
|
||||||
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
|
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
|
||||||
remote.push('master', force=True, set_upstream=True, progress=progress)
|
remote.push('master', force=True, set_upstream=True, progress=progress)
|
||||||
|
|
||||||
|
# push for every remote. This will overwrite the git history
|
||||||
|
for remote in repo.remotes:
|
||||||
|
branch = 'master'
|
||||||
|
if remote.name == 'gitlab':
|
||||||
|
logging.debug('Writing .gitlab-ci.yml to deploy to GitLab Pages')
|
||||||
|
with open(os.path.join(git_mirror_path, ".gitlab-ci.yml"), "wt") as out_file:
|
||||||
|
out_file.write("""pages:
|
||||||
|
script:
|
||||||
|
- mkdir .public
|
||||||
|
- cp -r * .public/
|
||||||
|
- mv .public public
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- public
|
||||||
|
""")
|
||||||
|
|
||||||
|
repo.git.add(all=True)
|
||||||
|
repo.index.commit("fdroidserver git-mirror: Deploy to GitLab Pages")
|
||||||
|
|
||||||
|
logging.debug('Pushing to ' + remote.url)
|
||||||
|
with repo.git.custom_environment(GIT_SSH_COMMAND=ssh_cmd):
|
||||||
|
remote.push(branch, force=True, set_upstream=True, progress=progress)
|
||||||
|
|
||||||
|
# Reset the gitlab specific stuff before the next remote.
|
||||||
|
if remote.name == 'gitlab':
|
||||||
|
logging.debug('Removing .gitlab-ci.yml now that it has successfully deployed')
|
||||||
|
repo.index.reset('HEAD^')
|
||||||
|
repo.index.checkout()
|
||||||
|
|
||||||
if progress:
|
if progress:
|
||||||
bar.done()
|
bar.done()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue