mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-10 17:20:29 +03:00
Run shell scripts with -e (Closes: #1035)
Make sudo, init prebuild, build and Prepare fields lists and only concatenate them with '; ' before execution. This allows arbitrary commands inside the fileds (even && and ';') as we don't need to split the commands again for rewritemeta.
This commit is contained in:
parent
49d8ba3b9b
commit
557fe87d44
10 changed files with 477 additions and 254 deletions
|
|
@ -516,8 +516,11 @@ def parse_yaml_srclib(metadatapath):
|
|||
thisinfo[key] = data[key]
|
||||
elif data[key] is None:
|
||||
thisinfo[key] = ['']
|
||||
elif key == 'Prepare' and isinstance(data[key], list):
|
||||
thisinfo[key] = ' && '.join(data[key])
|
||||
elif key == 'Prepare' or flagtype(key) == TYPE_SCRIPT:
|
||||
if isinstance(data[key], list):
|
||||
thisinfo[key] = data[key]
|
||||
else:
|
||||
thisinfo[key] = [data[key]] if data[key] else []
|
||||
else:
|
||||
thisinfo[key] = str(data[key] or '')
|
||||
|
||||
|
|
@ -847,9 +850,8 @@ def post_parse_yaml_metadata(yamldata):
|
|||
_flagtype = flagtype(flag)
|
||||
|
||||
if _flagtype is TYPE_SCRIPT:
|
||||
# concatenate script flags into a single string if they are stored as list
|
||||
if isinstance(build[flag], list):
|
||||
build[flag] = ' && '.join(build[flag])
|
||||
if isinstance(build[flag], str):
|
||||
build[flag] = [build[flag]]
|
||||
elif _flagtype is TYPE_STRING:
|
||||
# things like versionNames are strings, but without quotes can be numbers
|
||||
if isinstance(build[flag], float) or isinstance(build[flag], int):
|
||||
|
|
@ -916,12 +918,6 @@ def write_yaml(mf, app):
|
|||
return value[0]
|
||||
else:
|
||||
return value
|
||||
else:
|
||||
script_lines = value.split(' && ')
|
||||
if len(script_lines) > 1:
|
||||
return script_lines
|
||||
else:
|
||||
return value
|
||||
else:
|
||||
return value
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue