mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-08 08:20:28 +03:00
config: convert serverwebroot: to list-of-dicts format
This allows for more metadata about the server and deploy mode.
This commit is contained in:
parent
3f50372d8d
commit
7a656d45e3
5 changed files with 44 additions and 24 deletions
|
|
@ -462,18 +462,22 @@ def read_config(opts=None):
|
|||
|
||||
if 'serverwebroot' in config:
|
||||
if isinstance(config['serverwebroot'], str):
|
||||
roots = [config['serverwebroot']]
|
||||
roots = [{'url': config['serverwebroot']}]
|
||||
elif all(isinstance(item, str) for item in config['serverwebroot']):
|
||||
roots = [{'url': i} for i in config['serverwebroot']]
|
||||
elif all(isinstance(item, dict) for item in config['serverwebroot']):
|
||||
roots = config['serverwebroot']
|
||||
else:
|
||||
raise TypeError(_('only accepts strings, lists, and tuples'))
|
||||
rootlist = []
|
||||
for rootstr in roots:
|
||||
for d in roots:
|
||||
# since this is used with rsync, where trailing slashes have
|
||||
# meaning, ensure there is always a trailing slash
|
||||
rootstr = d['url']
|
||||
if rootstr[-1] != '/':
|
||||
rootstr += '/'
|
||||
rootlist.append(rootstr.replace('//', '/'))
|
||||
d['url'] = rootstr.replace('//', '/')
|
||||
rootlist.append(d)
|
||||
config['serverwebroot'] = rootlist
|
||||
|
||||
if 'servergitmirrors' in config:
|
||||
|
|
@ -4052,7 +4056,8 @@ def rsync_status_file_to_repo(path, repo_subdir=None):
|
|||
logging.debug(_('skip deploying full build logs: not enabled in config'))
|
||||
return
|
||||
|
||||
for webroot in config.get('serverwebroot', []):
|
||||
for d in config.get('serverwebroot', []):
|
||||
webroot = d['url']
|
||||
cmd = ['rsync',
|
||||
'--archive',
|
||||
'--delete-after',
|
||||
|
|
|
|||
|
|
@ -294,11 +294,12 @@ def update_serverwebroot(serverwebroot, repo_section):
|
|||
rsyncargs += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + options.identity_file]
|
||||
elif 'identity_file' in config:
|
||||
rsyncargs += ['-e', 'ssh -oBatchMode=yes -oIdentitiesOnly=yes -i ' + config['identity_file']]
|
||||
logging.info('rsyncing ' + repo_section + ' to ' + serverwebroot)
|
||||
url = serverwebroot['url']
|
||||
logging.info('rsyncing ' + repo_section + ' to ' + url)
|
||||
excludes = _get_index_excludes(repo_section)
|
||||
if subprocess.call(rsyncargs + excludes + [repo_section, serverwebroot]) != 0:
|
||||
if subprocess.call(rsyncargs + excludes + [repo_section, url]) != 0:
|
||||
raise FDroidException()
|
||||
if subprocess.call(rsyncargs + [repo_section, serverwebroot]) != 0:
|
||||
if subprocess.call(rsyncargs + [repo_section, url]) != 0:
|
||||
raise FDroidException()
|
||||
# upload "current version" symlinks if requested
|
||||
if config['make_current_version_link'] and repo_section == 'repo':
|
||||
|
|
@ -308,7 +309,7 @@ def update_serverwebroot(serverwebroot, repo_section):
|
|||
if os.path.islink(f):
|
||||
links_to_upload.append(f)
|
||||
if len(links_to_upload) > 0:
|
||||
if subprocess.call(rsyncargs + links_to_upload + [serverwebroot]) != 0:
|
||||
if subprocess.call(rsyncargs + links_to_upload + [url]) != 0:
|
||||
raise FDroidException()
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue