leave VirtualBox vagrant package as it was originally

We only need Vagrantfile hacks for KVM.
This commit is contained in:
Hans-Christoph Steiner 2017-05-22 15:50:32 +02:00
parent 8f1fabfed6
commit 9ef936c21a
2 changed files with 20 additions and 24 deletions

View file

@ -181,8 +181,8 @@ class FDroidBuildVm():
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
logger.debug('pruning global vagrant status failed: %s', e) logger.debug('pruning global vagrant status failed: %s', e)
def package(self, output=None, vagrantfile=None, keep_box_file=None): def package(self, output=None):
self.vgrnt.package(output=output, vagrantfile=vagrantfile) self.vgrnt.package(output=output)
def vagrant_uuid_okay(self): def vagrant_uuid_okay(self):
'''Having an uuid means that vagrant up has run successfully.''' '''Having an uuid means that vagrant up has run successfully.'''
@ -309,7 +309,7 @@ class LibvirtBuildVm(FDroidBuildVm):
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
logger.info("could not undefine libvirt domain '%s': %s", self.srvname, e) logger.info("could not undefine libvirt domain '%s': %s", self.srvname, e)
def package(self, output=None, vagrantfile=None, keep_box_file=False): def package(self, output=None, keep_box_file=False):
if not output: if not output:
output = "buildserver.box" output = "buildserver.box"
logger.debug('no output name set for packaging \'%s\',' + logger.debug('no output name set for packaging \'%s\',' +
@ -338,14 +338,24 @@ class LibvirtBuildVm(FDroidBuildVm):
"virtual_size": math.ceil(img_info['virtual-size'] / (1024. ** 3)), "virtual_size": math.ceil(img_info['virtual-size'] / (1024. ** 3)),
} }
if not vagrantfile:
logger.debug('no Vagrantfile supplied for box, generating a minimal one...')
vagrantfile = 'Vagrant.configure("2") do |config|\nend'
logger.debug('preparing metadata.json for box %s', output) logger.debug('preparing metadata.json for box %s', output)
with open('metadata.json', 'w') as fp: with open('metadata.json', 'w') as fp:
fp.write(json.dumps(metadata)) fp.write(json.dumps(metadata))
logger.debug('preparing Vagrantfile for box %s', output) logger.debug('preparing Vagrantfile for box %s', output)
vagrantfile = textwrap.dedent("""\
Vagrant.configure("2") do |config|
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.host = ""
libvirt.connect_via_ssh = false
libvirt.storage_pool_name = "default"
end
end""")
with open('Vagrantfile', 'w') as fp: with open('Vagrantfile', 'w') as fp:
fp.write(vagrantfile) fp.write(vagrantfile)
with tarfile.open(output, 'w:gz') as tar: with tarfile.open(output, 'w:gz') as tar:

View file

@ -30,7 +30,8 @@ parser.add_option('--skip-cache-update', action="store_true", default=False,
help="""Skip downloading and checking cache.""" help="""Skip downloading and checking cache."""
"""This assumes that the cache is already downloaded completely.""") """This assumes that the cache is already downloaded completely.""")
parser.add_option('--keep-box-file', action="store_true", default=False, parser.add_option('--keep-box-file', action="store_true", default=False,
help="""Box file will not be deleted after adding it to box storage.""") help="""Box file will not be deleted after adding it to box storage"""
""" (KVM-only).""")
options, args = parser.parse_args() options, args = parser.parse_args()
logger = logging.getLogger('fdroidserver-makebuildserver') logger = logging.getLogger('fdroidserver-makebuildserver')
@ -536,22 +537,7 @@ def main():
if os.path.exists(boxfile): if os.path.exists(boxfile):
os.remove(boxfile) os.remove(boxfile)
vagrantfile = textwrap.dedent("""\ vm.package(output=boxfile)
Vagrant.configure("2") do |config|
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.host = ""
libvirt.connect_via_ssh = false
libvirt.storage_pool_name = "default"
end
end""")
vm.package(output=boxfile, vagrantfile=vagrantfile, keep_box_file=options.keep_box_file)
logger.info("Adding box") logger.info("Adding box")
vm.box_add('buildserver', boxfile, force=True) vm.box_add('buildserver', boxfile, force=True)