mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 22:42:29 +03:00
Stop using vagrant-snap
a) too unreliable, b) doesn't work at all with various vagrant and ruby versions
This commit is contained in:
parent
05735e9fca
commit
ecaf475fc8
2 changed files with 29 additions and 17 deletions
|
@ -112,12 +112,10 @@ If you intend to use the 'Build Server' system, for secure and clean builds
|
||||||
@item
|
@item
|
||||||
VirtualBox (debian package virtualbox-ose)
|
VirtualBox (debian package virtualbox-ose)
|
||||||
@item
|
@item
|
||||||
Ruby (debian package ruby)
|
Ruby (debian packages ruby and rubygems)
|
||||||
@item
|
@item
|
||||||
Vagrant (gem install vagrant)
|
Vagrant (gem install vagrant)
|
||||||
@item
|
@item
|
||||||
Vagrant-snap (gem install vagrant-snap)
|
|
||||||
@item
|
|
||||||
Paramiko (debian package python-paramiko)
|
Paramiko (debian package python-paramiko)
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import re
|
||||||
import tarfile
|
import tarfile
|
||||||
import traceback
|
import traceback
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
|
||||||
import common
|
import common
|
||||||
|
@ -32,6 +33,12 @@ from common import BuildException
|
||||||
from common import VCSException
|
from common import VCSException
|
||||||
|
|
||||||
|
|
||||||
|
def get_builder_vm_id():
|
||||||
|
with open(os.path.join('builder', '.vagrant')) as vf:
|
||||||
|
v = json.load(vf)
|
||||||
|
return v['active']['default']
|
||||||
|
|
||||||
|
|
||||||
# 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, sdk_path, force):
|
def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
"""Do a build on the build server."""
|
"""Do a build on the build server."""
|
||||||
|
@ -44,7 +51,7 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
print "Checking for valid existing build server"
|
print "Checking for valid existing build server"
|
||||||
if os.path.exists(os.path.join('builder', 'Vagrantfile')):
|
if os.path.exists(os.path.join('builder', 'Vagrantfile')):
|
||||||
print "...directory exists"
|
print "...directory exists"
|
||||||
p = subprocess.Popen(['vagrant', 'snap', 'list'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
||||||
cwd='builder', stdout=subprocess.PIPE)
|
cwd='builder', stdout=subprocess.PIPE)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if output.find('fdroidclean') != -1:
|
if output.find('fdroidclean') != -1:
|
||||||
|
@ -55,11 +62,11 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
if output.find('running') != -1:
|
if output.find('running') != -1:
|
||||||
print "...suspending"
|
print "...suspending"
|
||||||
subprocess.call(['vagrant', 'suspend'], cwd='builder')
|
subprocess.call(['vagrant', 'suspend'], cwd='builder')
|
||||||
if subprocess.call(['vagrant', 'snap', 'go', 'fdroidclean'],
|
if subprocess.call(['VBoxManage', 'snapshot', get_builder_vm_id(), 'restore', 'fdroidclean'],
|
||||||
cwd='builder') == 0:
|
cwd='builder') == 0:
|
||||||
#if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
|
||||||
# raise BuildException("Failed to start build server")
|
|
||||||
print "...reset to snapshot - server is valid"
|
print "...reset to snapshot - server is valid"
|
||||||
|
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
||||||
|
raise BuildException("Failed to start build server")
|
||||||
vm_ok = True
|
vm_ok = True
|
||||||
else:
|
else:
|
||||||
print "...failed to reset to snapshot"
|
print "...failed to reset to snapshot"
|
||||||
|
@ -74,12 +81,12 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
subprocess.call(['vagrant', 'destroy', '-f'], cwd='builder')
|
subprocess.call(['vagrant', 'destroy', '-f'], cwd='builder')
|
||||||
shutil.rmtree('builder')
|
shutil.rmtree('builder')
|
||||||
os.mkdir('builder')
|
os.mkdir('builder')
|
||||||
vf = open('builder/Vagrantfile', 'w')
|
with open('builder/Vagrantfile', 'w') as vf:
|
||||||
vf.write('Vagrant::Config.run do |config|\n')
|
vf.write('Vagrant::Config.run do |config|\n')
|
||||||
vf.write('config.vm.box = "buildserver"\n')
|
vf.write('config.vm.box = "buildserver"\n')
|
||||||
vf.write('config.vm.customize ["modifyvm", :id, "--memory", "768"]\n')
|
vf.write('config.vm.customize ["modifyvm", :id, "--memory", "768"]\n')
|
||||||
vf.write('end\n')
|
vf.write('end\n')
|
||||||
vf.close()
|
|
||||||
print "Starting new build server"
|
print "Starting new build server"
|
||||||
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
if subprocess.call(['vagrant', 'up'], cwd='builder') != 0:
|
||||||
raise BuildException("Failed to start build server")
|
raise BuildException("Failed to start build server")
|
||||||
|
@ -97,20 +104,24 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
sshconfig = sshconfig.lookup(vagranthost)
|
sshconfig = sshconfig.lookup(vagranthost)
|
||||||
sshs = ssh.SSHClient()
|
sshs = ssh.SSHClient()
|
||||||
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
sshs.set_missing_host_key_policy(ssh.AutoAddPolicy())
|
||||||
|
idfile = sshconfig['identityfile']
|
||||||
|
if idfile.startswith('"') and idfile.endswith('"'):
|
||||||
|
idfile = idfile[1:-1]
|
||||||
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
|
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
|
||||||
port=int(sshconfig['port']), timeout=300, look_for_keys=False,
|
port=int(sshconfig['port']), timeout=300, look_for_keys=False,
|
||||||
key_filename=sshconfig['identityfile'])
|
key_filename=idfile)
|
||||||
sshs.close()
|
sshs.close()
|
||||||
|
|
||||||
print "Saving clean state of new build server"
|
print "Saving clean state of new build server"
|
||||||
if subprocess.call(['vagrant', 'snap', 'take', '-n', 'fdroidclean'],
|
subprocess.call(['vagrant', 'suspend'], cwd='builder')
|
||||||
|
if subprocess.call(['VBoxManage', 'snapshot', get_builder_vm_id(), 'take', 'fdroidclean'],
|
||||||
cwd='builder') != 0:
|
cwd='builder') != 0:
|
||||||
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:
|
if subprocess.call(['vagrant', 'up'], cwd='builder') != 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(['vagrant', 'snap', 'list'],
|
p = subprocess.Popen(['VBoxManage', 'snapshot', get_builder_vm_id(), 'list', '--details'],
|
||||||
cwd='builder', stdout=subprocess.PIPE)
|
cwd='builder', stdout=subprocess.PIPE)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if output.find('fdroidclean') == -1:
|
if output.find('fdroidclean') == -1:
|
||||||
|
@ -135,9 +146,12 @@ def build_server(app, thisbuild, vcs, build_dir, output_dir, sdk_path, force):
|
||||||
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())
|
||||||
|
idfile = sshconfig['identityfile']
|
||||||
|
if idfile.startswith('"') and idfile.endswith('"'):
|
||||||
|
idfile = idfile[1:-1]
|
||||||
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
|
sshs.connect(sshconfig['hostname'], username=sshconfig['user'],
|
||||||
port=int(sshconfig['port']), timeout=300, look_for_keys=False,
|
port=int(sshconfig['port']), timeout=300, look_for_keys=False,
|
||||||
key_filename=sshconfig['identityfile'])
|
key_filename=idfile)
|
||||||
|
|
||||||
# Get an SFTP connection...
|
# Get an SFTP connection...
|
||||||
ftp = sshs.open_sftp()
|
ftp = sshs.open_sftp()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue