support configing buildserver VM per-build with sudo=

This adds the 'sudo' build field, which is just a script that is run as
root.  For more info, see the issue that this closes:

refs #318
closes #317
This commit is contained in:
Hans-Christoph Steiner 2017-06-28 23:01:45 +02:00
parent 747ac52a62
commit dfb07808d3
9 changed files with 138 additions and 14 deletions

View file

@ -393,10 +393,23 @@ def build_local(app, build, vcs, build_dir, output_dir, log_dir, srclib_dir, ext
# create ..._toolsversion.log when running in builder vm
if onserver:
# before doing anything, run the sudo commands to setup the VM
if build.sudo:
logging.info("Running 'sudo' commands in %s" % os.getcwd())
p = FDroidPopen(['sudo', 'bash', '-x', '-c', build.sudo])
if p.returncode != 0:
raise BuildException("Error running sudo command for %s:%s" %
(app.id, build.versionName), p.output)
log_path = os.path.join(log_dir,
common.get_toolsversion_logname(app, build))
with open(log_path, 'w') as f:
f.write(get_android_tools_version_log(build.ndk_path()))
else:
if build.sudo:
logging.warning('%s:%s runs this on the buildserver with sudo:\n\t%s'
% (app.id, build.versionName, build.sudo))
# Prepare the source code...
root_dir, srclibpaths = common.prepare_source(vcs, app, build,