mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +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:
parent
413c3836d5
commit
2993674aa8
@ -12,6 +12,8 @@ import tarfile
|
|||||||
import vagrant
|
import vagrant
|
||||||
import hashlib
|
import hashlib
|
||||||
import yaml
|
import yaml
|
||||||
|
import math
|
||||||
|
import json
|
||||||
from clint.textui import progress
|
from clint.textui import progress
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import fdroidserver.tail
|
import fdroidserver.tail
|
||||||
@ -334,12 +336,13 @@ def kvm_package(boxfile):
|
|||||||
subprocess.check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
|
subprocess.check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
|
||||||
shutil.copy2(imagepath, 'box.img')
|
shutil.copy2(imagepath, 'box.img')
|
||||||
subprocess.check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
|
subprocess.check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
|
||||||
metadata = """{
|
img_info_raw = subprocess.check_output('sudo qemu-img info --output=json box.img', shell=True)
|
||||||
"provider": "libvirt",
|
img_info = json.loads(img_info_raw.decode('utf-8'))
|
||||||
"format": "qcow2",
|
metadata = {"provider": "libvirt",
|
||||||
"virtual_size": 1000
|
"format": img_info['format'],
|
||||||
|
"virtual_size": math.ceil(img_info['virtual-size'] / 1024.**3),
|
||||||
}
|
}
|
||||||
"""
|
|
||||||
vagrantfile = """Vagrant.configure("2") do |config|
|
vagrantfile = """Vagrant.configure("2") do |config|
|
||||||
config.ssh.username = "vagrant"
|
config.ssh.username = "vagrant"
|
||||||
config.ssh.password = "vagrant"
|
config.ssh.password = "vagrant"
|
||||||
@ -355,7 +358,7 @@ def kvm_package(boxfile):
|
|||||||
end
|
end
|
||||||
"""
|
"""
|
||||||
with open('metadata.json', 'w') as fp:
|
with open('metadata.json', 'w') as fp:
|
||||||
fp.write(metadata)
|
fp.write(json.dumps(metadata))
|
||||||
with open('Vagrantfile', 'w') as fp:
|
with open('Vagrantfile', 'w') as fp:
|
||||||
fp.write(vagrantfile)
|
fp.write(vagrantfile)
|
||||||
with tarfile.open(boxfile, 'w:gz') as tar:
|
with tarfile.open(boxfile, 'w:gz') as tar:
|
||||||
|
Loading…
Reference in New Issue
Block a user