mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
server: git push for binary transparency in fdroid server update
Since `fdroid server update` is the place where all uploads to servers happens, it makes sense to also handle the git push for the binary transparency log here instead of `fdroid btlog`
This commit is contained in:
parent
e3152e9ef0
commit
299ba86948
@ -42,6 +42,7 @@ import zipfile
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from . import common
|
||||
from . import server
|
||||
|
||||
|
||||
options = None
|
||||
@ -49,8 +50,7 @@ options = None
|
||||
|
||||
def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
|
||||
url=None,
|
||||
commit_title='fdroid update',
|
||||
git_remote=None):
|
||||
commit_title='fdroid update'):
|
||||
'''Log the indexes in a standalone git repo to serve as a "binary
|
||||
transparency" log.
|
||||
|
||||
@ -142,17 +142,6 @@ For more info on this idea:
|
||||
gitrepo.index.add([os.path.join(repodir, os.path.basename(f)), ])
|
||||
|
||||
gitrepo.index.commit(commit_title)
|
||||
if git_remote:
|
||||
logging.info('Pushing binary transparency log to ' + git_remote)
|
||||
origin = git.remote.Remote(gitrepo, 'origin')
|
||||
if origin in gitrepo.remotes:
|
||||
origin = gitrepo.remote('origin')
|
||||
if 'set_url' in dir(origin): # added in GitPython 2.x
|
||||
origin.set_url(git_remote)
|
||||
else:
|
||||
origin = gitrepo.create_remote('origin', git_remote)
|
||||
origin.fetch()
|
||||
origin.push('master')
|
||||
|
||||
|
||||
def main():
|
||||
@ -227,8 +216,9 @@ def main():
|
||||
|
||||
if new_files:
|
||||
os.chdir(tempdirbase)
|
||||
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog',
|
||||
git_remote=options.git_remote)
|
||||
make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog')
|
||||
if options.git_remote:
|
||||
server.push_binary_transparency(options.git_repo, options.git_remote)
|
||||
shutil.rmtree(tempdirbase, ignore_errors=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -281,20 +281,20 @@ def upload_to_virustotal(repo_section, vt_apikey):
|
||||
logging.info(response['verbose_msg'] + " " + response['permalink'])
|
||||
|
||||
|
||||
def push_binary_transparency(binary_transparency_remote):
|
||||
def push_binary_transparency(git_repo_path, git_remote):
|
||||
'''push the binary transparency git repo to the specifed remote'''
|
||||
import git
|
||||
|
||||
repo = git.Repo('binary_transparency_log')
|
||||
pushremote = None
|
||||
for remote in repo.remotes:
|
||||
if remote.url == binary_transparency_remote:
|
||||
pushremote = remote
|
||||
break
|
||||
|
||||
if not pushremote:
|
||||
pushremote = repo.create_remote('fdroid_server_update', binary_transparency_remote)
|
||||
pushremote.push('master')
|
||||
logging.info('Pushing binary transparency log to ' + git_remote)
|
||||
gitrepo = git.Repo(git_repo_path)
|
||||
origin = git.remote.Remote(gitrepo, 'origin')
|
||||
if origin in gitrepo.remotes:
|
||||
origin = gitrepo.remote('origin')
|
||||
if 'set_url' in dir(origin): # added in GitPython 2.x
|
||||
origin.set_url(git_remote)
|
||||
else:
|
||||
origin = gitrepo.create_remote('origin', git_remote)
|
||||
origin.push('master')
|
||||
|
||||
|
||||
def main():
|
||||
@ -377,10 +377,11 @@ def main():
|
||||
and not config.get('serverwebroot') \
|
||||
and not config.get('servergitmirrors') \
|
||||
and not config.get('androidobservatory') \
|
||||
and not config.get('binary_transparency_remote') \
|
||||
and not config.get('virustotal_apikey') \
|
||||
and local_copy_dir is None:
|
||||
logging.warn('No option set! Edit your config.py to set at least one among:\n'
|
||||
+ 'serverwebroot, servergitmirrors, local_copy_dir, awsbucket, virustotal_apikey or androidobservatory')
|
||||
+ 'serverwebroot, servergitmirrors, local_copy_dir, awsbucket, virustotal_apikey, androidobservatory, or binary_transparency_remote')
|
||||
sys.exit(1)
|
||||
|
||||
repo_sections = ['repo']
|
||||
@ -435,7 +436,7 @@ def main():
|
||||
|
||||
binary_transparency_remote = config.get('binary_transparency_remote')
|
||||
if binary_transparency_remote:
|
||||
push_binary_transparency(binary_transparency_remote)
|
||||
push_binary_transparency('binary_transparency', binary_transparency_remote)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
@ -1410,7 +1410,7 @@ def main():
|
||||
|
||||
git_remote = config.get('binary_transparency_remote')
|
||||
if git_remote or os.path.isdir(os.path.join('binary_transparency', '.git')):
|
||||
btlog.make_binary_transparency_log(repodirs, git_remote=git_remote)
|
||||
btlog.make_binary_transparency_log(repodirs)
|
||||
|
||||
if config['update_stats']:
|
||||
# Update known apks info...
|
||||
|
@ -602,7 +602,8 @@ echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.p
|
||||
echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
|
||||
echo "binary_transparency_remote = '$REPOROOT/git_remote'" >> config.py
|
||||
echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
|
||||
$fdroid update --verbose --pretty
|
||||
$fdroid update --verbose
|
||||
$fdroid server update --verbose
|
||||
test -e repo/index.xml
|
||||
test -e repo/index.jar
|
||||
test -e repo/index-v1.jar
|
||||
|
Loading…
Reference in New Issue
Block a user