1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

calculate correct size for buildserver-box in makebuildserver

https://gitlab.com/fdroid/fdroidserver/issues/238#note_24000153
"Our hard-coded image size meta-data (1000) is for some interpreted as less
than the size of the box-image by my kvm setup. This makes grub/initrd
refuse to boot. So I've changed the metadata size to 9999 which resulted in
an actually booting vm. I can log in on the builder-vm via virt-manager
and virsh.
This commit is contained in:
Hans-Christoph Steiner 2017-05-22 16:57:47 +02:00
parent 413c3836d5
commit 2993674aa8

View File

@ -12,6 +12,8 @@ import tarfile
import vagrant
import hashlib
import yaml
import math
import json
from clint.textui import progress
from optparse import OptionParser
import fdroidserver.tail
@ -334,12 +336,13 @@ def kvm_package(boxfile):
subprocess.check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
shutil.copy2(imagepath, 'box.img')
subprocess.check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
metadata = """{
"provider": "libvirt",
"format": "qcow2",
"virtual_size": 1000
}
"""
img_info_raw = subprocess.check_output('sudo qemu-img info --output=json box.img', shell=True)
img_info = json.loads(img_info_raw.decode('utf-8'))
metadata = {"provider": "libvirt",
"format": img_info['format'],
"virtual_size": math.ceil(img_info['virtual-size'] / 1024.**3),
}
vagrantfile = """Vagrant.configure("2") do |config|
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
@ -355,7 +358,7 @@ def kvm_package(boxfile):
end
"""
with open('metadata.json', 'w') as fp:
fp.write(metadata)
fp.write(json.dumps(metadata))
with open('Vagrantfile', 'w') as fp:
fp.write(vagrantfile)
with tarfile.open(boxfile, 'w:gz') as tar: