mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-06 07:20:29 +03:00
Lose a lot of vbox/vagrant/general output noise
This commit is contained in:
parent
c75aa26115
commit
5a0bf1ddfb
1 changed files with 50 additions and 20 deletions
|
|
@ -62,6 +62,22 @@ def got_valid_builder_vm():
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def vagrant(params, cwd=None, printout=False):
|
||||||
|
"""Run vagrant.
|
||||||
|
|
||||||
|
:param: list of parameters to pass to vagrant
|
||||||
|
:cwd: directory to run in, or None for current directory
|
||||||
|
:returns: (ret, out) where ret is the return code, and out
|
||||||
|
is the stdout (and stderr) from vagrant
|
||||||
|
"""
|
||||||
|
p = subprocess.Popen(['vagrant'] + params, cwd=cwd,
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
out = p.communicate()[0]
|
||||||
|
if options.verbose:
|
||||||
|
print out
|
||||||
|
return (p.returncode, out)
|
||||||
|
|
||||||
|
|
||||||
# Note that 'force' here also implies test mode.
|
# Note that 'force' here also implies test mode.
|
||||||
def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
"""Do a build on the build server."""
|
"""Do a build on the build server."""
|
||||||
|
|
@ -75,20 +91,25 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
if got_valid_builder_vm():
|
if got_valid_builder_vm():
|
||||||
print "...VM is present"
|
print "...VM is present"
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
||||||
cwd='builder', stdout=subprocess.PIPE)
|
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if output.find('fdroidclean') != -1:
|
if output.find('fdroidclean') != -1:
|
||||||
|
if options.verbose:
|
||||||
print "...snapshot exists - resetting build server to clean state"
|
print "...snapshot exists - resetting build server to clean state"
|
||||||
p = subprocess.Popen(['vagrant', 'status'],
|
retcode, output = vagrant(['status'], cwd='builder')
|
||||||
cwd='builder', stdout=subprocess.PIPE)
|
|
||||||
output = p.communicate()[0]
|
|
||||||
if output.find('running') != -1:
|
if output.find('running') != -1:
|
||||||
|
if options.verbose:
|
||||||
print "...suspending"
|
print "...suspending"
|
||||||
subprocess.call(['vagrant', 'suspend'], cwd='builder')
|
vagrant(['suspend'], cwd='builder')
|
||||||
if subprocess.call(['VBoxManage', 'snapshot', get_builder_vm_id(), 'restore', 'fdroidclean'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'restore', 'fdroidclean'],
|
||||||
cwd='builder') == 0:
|
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
output = p.communicate()[0]
|
||||||
|
if options.verbose:
|
||||||
|
print output
|
||||||
|
if p.returncode == 0:
|
||||||
print "...reset to snapshot - server is valid"
|
print "...reset to snapshot - server is valid"
|
||||||
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
retcode, output = vagrant(['up'], cwd='builder')
|
||||||
|
if retcode != 0:
|
||||||
raise BuildException("Failed to start build server")
|
raise BuildException("Failed to start build server")
|
||||||
vm_ok = True
|
vm_ok = True
|
||||||
else:
|
else:
|
||||||
|
|
@ -101,7 +122,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
if not vm_ok:
|
if not vm_ok:
|
||||||
if os.path.exists('builder'):
|
if os.path.exists('builder'):
|
||||||
print "Removing broken/incomplete/unwanted build server"
|
print "Removing broken/incomplete/unwanted build server"
|
||||||
subprocess.call(['vagrant', 'destroy', '-f'], cwd='builder')
|
vagrant(['destroy', '-f'], cwd='builder')
|
||||||
shutil.rmtree('builder')
|
shutil.rmtree('builder')
|
||||||
os.mkdir('builder')
|
os.mkdir('builder')
|
||||||
|
|
||||||
|
|
@ -119,7 +140,8 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
vf.write('end\n')
|
vf.write('end\n')
|
||||||
|
|
||||||
print "Starting new build server"
|
print "Starting new build server"
|
||||||
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
retcode, _ = vagrant(['up'], cwd='builder')
|
||||||
|
if retcode != 0:
|
||||||
raise BuildException("Failed to start build server")
|
raise BuildException("Failed to start build server")
|
||||||
|
|
||||||
# Open SSH connection to make sure it's working and ready...
|
# Open SSH connection to make sure it's working and ready...
|
||||||
|
|
@ -144,19 +166,24 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
sshs.close()
|
sshs.close()
|
||||||
|
|
||||||
print "Saving clean state of new build server"
|
print "Saving clean state of new build server"
|
||||||
if subprocess.call(['vagrant', 'suspend'], cwd='builder') != 0:
|
retcode, _ = vagrant(['suspend'], cwd='builder')
|
||||||
|
if retcode != 0:
|
||||||
raise BuildException("Failed to suspend build server")
|
raise BuildException("Failed to suspend build server")
|
||||||
print "...waiting a sec..."
|
print "...waiting a sec..."
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
if subprocess.call(['VBoxManage', 'snapshot', get_builder_vm_id(), 'take', 'fdroidclean'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'take', 'fdroidclean'],
|
||||||
cwd='builder') != 0:
|
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
|
output = p.communicate()[0]
|
||||||
|
if p.returncode != 0:
|
||||||
|
print output
|
||||||
raise BuildException("Failed to take snapshot")
|
raise BuildException("Failed to take snapshot")
|
||||||
print "Restarting new build server"
|
print "Restarting new build server"
|
||||||
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
retcode, _ = vagrant(['up'], cwd='builder')
|
||||||
|
if retcode != 0:
|
||||||
raise BuildException("Failed to start build server")
|
raise BuildException("Failed to start build server")
|
||||||
# Make sure it worked...
|
# Make sure it worked...
|
||||||
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
||||||
cwd='builder', stdout=subprocess.PIPE)
|
cwd='builder', stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if output.find('fdroidclean') == -1:
|
if output.find('fdroidclean') == -1:
|
||||||
raise BuildException("Failed to take snapshot.")
|
raise BuildException("Failed to take snapshot.")
|
||||||
|
|
@ -164,6 +191,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# Get SSH configuration settings for us to connect...
|
# Get SSH configuration settings for us to connect...
|
||||||
|
if options.verbose:
|
||||||
print "Getting ssh configuration..."
|
print "Getting ssh configuration..."
|
||||||
subprocess.call('vagrant ssh-config >sshconfig',
|
subprocess.call('vagrant ssh-config >sshconfig',
|
||||||
cwd='builder', shell=True)
|
cwd='builder', shell=True)
|
||||||
|
|
@ -177,6 +205,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
sshconfig = sshconfig.lookup(vagranthost)
|
sshconfig = sshconfig.lookup(vagranthost)
|
||||||
|
|
||||||
# Open SSH connection...
|
# Open SSH connection...
|
||||||
|
if options.verbose:
|
||||||
print "Connecting to virtual machine..."
|
print "Connecting to virtual machine..."
|
||||||
sshs = ssh.SSHClient()
|
sshs = ssh.SSHClient()
|
||||||
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
||||||
|
|
@ -266,6 +295,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, force):
|
||||||
if basesrclib:
|
if basesrclib:
|
||||||
srclibpaths.append(basesrclib)
|
srclibpaths.append(basesrclib)
|
||||||
for name, lib in srclibpaths:
|
for name, lib in srclibpaths:
|
||||||
|
if options.verbose:
|
||||||
print "Sending srclib '" + lib + "'"
|
print "Sending srclib '" + lib + "'"
|
||||||
ftp.chdir('/home/vagrant/build/srclib')
|
ftp.chdir('/home/vagrant/build/srclib')
|
||||||
if not os.path.exists(lib):
|
if not os.path.exists(lib):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue