subprocess.call(['vagrant', 'suspend'], cwd='builder')
if subprocess.call(['vagrant', 'snap', 'go', 'fdroidclean'],
cwd='builder') == 0:
- if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
- raise BuildException("Failed to start build server")
+ #if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
+ # raise BuildException("Failed to start build server")
print "...reset to snapshot - server is valid"
vm_ok = True
else:
sshs = ssh.SSHClient()
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
- port=int(sshconfig['port']), timeout=60, look_for_keys=False,
+ port=int(sshconfig['port']), timeout=300, look_for_keys=False,
key_filename=sshconfig['identityfile'])
+ sshs.close()
print "Saving clean state of new build server"
if subprocess.call(['vagrant', 'snap', 'take', '-n', 'fdroidclean'],
sshs = ssh.SSHClient()
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
- port=int(sshconfig['port']), timeout=60, look_for_keys=False,
+ port=int(sshconfig['port']), timeout=300, look_for_keys=False,
key_filename=sshconfig['identityfile'])
# Get an SFTP connection...
# Execute the build script...
print "Starting build..."
chan = sshs.get_transport().open_session()
- stdoutf = chan.makefile('rb')
- stderrf = chan.makefile_stderr('rb')
+ stdoutf = chan.makefile('r')
+ stderrf = chan.makefile_stderr('r')
chan.exec_command('python build.py --on-server -p ' +
app['id'] + ' --vercode ' + thisbuild['vercode'])
+ output = ''
+ error = ''
+ while not chan.exit_status_ready():
+ output += stdoutf.read()
+ error += stderrf.read()
returncode = chan.recv_exit_status()
- output = stdoutf.read()
- error = stderrf.read()
if returncode != 0:
raise BuildException("Build.py failed on server for %s:%s" % (app['id'], thisbuild['version']), output.strip(), error.strip())
finally:
# Suspend the build server.
+ print "Suspending build server"
subprocess.call(['vagrant', 'suspend'], cwd='builder')
options.install, options.force, options.verbose):
build_succeeded.append(app)
except BuildException as be:
+ logfile = open(os.path.join(log_dir, app['id'] + '.log'), 'a+')
+ logfile.write(str(be))
+ logfile.close()
if options.stop:
- raise
+ sys.exit(1)
print "Could not build app %s due to BuildException: %s" % (app['id'], be)
logfile = open(os.path.join(log_dir, app['id'] + '.log'), 'a+')
logfile.write(str(be))
- logfile.close
+ logfile.close()
failed_apps[app['id']] = be
except VCSException as vcse:
if options.stop:
- raise
+ sys.exit(1)
print "VCS error while building app %s: %s" % (app['id'], vcse)
failed_apps[app['id']] = vcse
except Exception as e:
if options.stop:
- raise
+ sys.exit(1)
print "Could not build app %s due to unknown error: %s" % (app['id'], traceback.format_exc())
failed_apps[app['id']] = e
if len(failed_apps) > 0:
print str(len(failed_apps)) + ' builds failed'
+ sys.exit(0)
if __name__ == "__main__":
main()