def make_binary_transparency_log(repodirs, btrepo='binary_transparency',
url=None,
- commit_title='fdroid update'):
+ commit_title='fdroid update',
+ git_remote=None):
'''Log the indexes in a standalone git repo to serve as a "binary
transparency" log.
'''
+ logging.info('Committing indexes to ' + btrepo)
if os.path.exists(os.path.join(btrepo, '.git')):
gitrepo = git.Repo(btrepo)
else:
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():
parser.add_argument("-u", "--url", default='https://f-droid.org',
help="The base URL for the repo to log (default: https://f-droid.org)")
parser.add_argument("--git-remote", default=None,
- help="Create a repo signing key in a keystore")
+ help="Push the log to this git remote repository")
options = parser.parse_args()
if options.verbose:
if new_files:
os.chdir(tempdirbase)
- make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog')
+ make_binary_transparency_log(repodirs, options.git_repo, options.url, 'fdroid btlog',
+ git_remote=options.git_remote)
shutil.rmtree(tempdirbase, ignore_errors=True)
if __name__ == "__main__":
index.make(apps, sortedids, archapks, repodirs[1], True)
if config.get('binary_transparency_remote'):
- btlog.make_binary_transparency_log(repodirs)
+ btlog.make_binary_transparency_log(repodirs, git_remote=config['binary_transparency_remote'])
if config['update_stats']:
# Update known apks info...