mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-16 16:02:33 +03:00
Fix crashes when writing boolean metadata fields
This commit is contained in:
parent
47f31b72c0
commit
355dc1bfd9
1 changed files with 14 additions and 5 deletions
|
@ -31,6 +31,12 @@ import magic
|
||||||
config = None
|
config = None
|
||||||
options = None
|
options = None
|
||||||
|
|
||||||
|
# These can only contain 'yes' or 'no'
|
||||||
|
bool_keys = (
|
||||||
|
'submodules', 'oldsdkloc',
|
||||||
|
'forceversion', 'forcevercode',
|
||||||
|
'fixtrans', 'fixapos', 'novcheck')
|
||||||
|
|
||||||
def read_config(opts, config_file='config.py'):
|
def read_config(opts, config_file='config.py'):
|
||||||
"""Read the repository config
|
"""Read the repository config
|
||||||
|
|
||||||
|
@ -686,8 +692,7 @@ def parse_metadata(metafile):
|
||||||
mode = 0
|
mode = 0
|
||||||
add_comments(None)
|
add_comments(None)
|
||||||
|
|
||||||
# These can only contain 'yes' or 'no'
|
for key in bool_keys:
|
||||||
for key in ('submodules', 'oldsdkloc', 'forceversion', 'forcevercode', 'fixtrans', 'fixapos', 'novcheck'):
|
|
||||||
for build in thisinfo['builds']:
|
for build in thisinfo['builds']:
|
||||||
if key not in build:
|
if key not in build:
|
||||||
build[key] = False
|
build[key] = False
|
||||||
|
@ -821,13 +826,17 @@ def write_metadata(dest, app):
|
||||||
|
|
||||||
def write_builditem(key, value):
|
def write_builditem(key, value):
|
||||||
if key not in ['version', 'vercode', 'origlines']:
|
if key not in ['version', 'vercode', 'origlines']:
|
||||||
|
if key in bool_keys:
|
||||||
|
if not value:
|
||||||
|
return
|
||||||
|
value = 'yes'
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
print "...writing {0} : {1}".format(key, value)
|
print "...writing {0} : {1}".format(key, value)
|
||||||
outline = ' ' + key + '='
|
outline = ' %s=' % key
|
||||||
bits = value.split('&& ')
|
outline += '&& \\\n '.join([s.lstrip() for s in value.split('&& ')])
|
||||||
outline += '&& \\\n '.join([s.lstrip() for s in bits])
|
|
||||||
outline += '\n'
|
outline += '\n'
|
||||||
mf.write(outline)
|
mf.write(outline)
|
||||||
|
|
||||||
for key in keyorder:
|
for key in keyorder:
|
||||||
if key in build:
|
if key in build:
|
||||||
write_builditem(key, build[key])
|
write_builditem(key, build[key])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue