add git repo mirroring

This commit is contained in:
thez3ro 2017-02-10 18:38:25 +01:00
parent fc433c803b
commit 5a9bcfbbf4
No known key found for this signature in database
GPG key ID: F628F9E41DD7C073
4 changed files with 92 additions and 2 deletions

View file

@ -961,6 +961,32 @@ def extract_pubkey():
return hexlify(pubkey)
# Get raw URL from git service for mirroring
def get_raw_mirror(url):
# Divide urls in parts
url = url.split("/")
# Get the hostname
hostname = url[2]
# fdroidserver will use always 'master' branch for git-mirroring
branch = "master"
folder = "fdroid"
if hostname == "github.com":
# Github like RAW url "https://raw.githubusercontent.com/user/repo/master/fdroid"
url[2] = "raw.githubusercontent.com"
url.extend([branch, folder])
elif hostname == "gitlab.com":
# Gitlab like RAW url "https://gitlab.com/user/repo/raw/master/fdroid"
url.extend(["raw", branch, folder])
else:
return None
url = "/".join(url)
return url
def make_index(apps, sortedids, apks, repodir, archive):
"""Generate the repo index files.
@ -1012,6 +1038,10 @@ def make_index(apps, sortedids, apks, repodir, archive):
mirrors.append(mirror)
else:
mirrors.append(mirror + '/')
for mirror in config.get('servergitmirrors', []):
mirror = get_raw_mirror(mirror)
if mirror is not None:
mirrors.append(mirror + '/')
if mirrorcheckfailed:
sys.exit(1)