]> git.proxmox.com Git - mirror_qemu.git/blob - tests/vm/ubuntu.i386
tests/vm: Remove flex/bison packages
[mirror_qemu.git] / tests / vm / ubuntu.i386
1 #!/usr/bin/env python3
2 #
3 # Ubuntu i386 image
4 #
5 # Copyright 2017 Red Hat Inc.
6 #
7 # Authors:
8 # Fam Zheng <famz@redhat.com>
9 #
10 # This code is licensed under the GPL version 2 or later. See
11 # the COPYING file in the top-level directory.
12 #
13
14 import os
15 import sys
16 import subprocess
17 import basevm
18 import time
19
20 class UbuntuX86VM(basevm.BaseVM):
21 name = "ubuntu.i386"
22 arch = "i386"
23 BUILD_SCRIPT = """
24 set -e;
25 cd $(mktemp -d);
26 sudo chmod a+r /dev/vdb;
27 tar -xf /dev/vdb;
28 ./configure {configure_opts};
29 make --output-sync {target} -j{jobs} {verbose};
30 """
31
32 def build_image(self, img):
33 cimg = self._download_with_cache(
34 "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img",
35 sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
36 img_tmp = img + ".tmp"
37 subprocess.check_call(["cp", "-f", cimg, img_tmp])
38 self.exec_qemu_img("resize", img_tmp, "50G")
39 self.boot(img_tmp, extra_args = [
40 "-device", "VGA",
41 "-cdrom", self.gen_cloud_init_iso()
42 ])
43 self.wait_ssh()
44 self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
45 self.ssh_root_check("apt-get update")
46 self.ssh_root_check("apt-get install -y cloud-initramfs-growroot")
47 # Don't check the status in case the guest hang up too quickly
48 self.ssh_root("sync && reboot")
49 time.sleep(5)
50 self.wait_ssh()
51 # The previous update sometimes doesn't survive a reboot, so do it again
52 self.ssh_root_check("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list")
53 self.ssh_root_check("apt-get update")
54 self.ssh_root_check("apt-get build-dep -y qemu")
55 self.ssh_root_check("apt-get install -y libfdt-dev language-pack-en")
56 self.ssh_root("poweroff")
57 self.wait()
58 os.rename(img_tmp, img)
59 return 0
60
61 if __name__ == "__main__":
62 sys.exit(basevm.main(UbuntuX86VM))