]> git.proxmox.com Git - mirror_qemu.git/blame - tests/vm/ubuntu.i386
Merge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' into...
[mirror_qemu.git] / tests / vm / ubuntu.i386
CommitLineData
c88ee46c 1#!/usr/bin/env python3
fb15a570
FZ
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
14import os
15import sys
16import subprocess
17import basevm
18import time
19
20class UbuntuX86VM(basevm.BaseVM):
21 name = "ubuntu.i386"
31719c37 22 arch = "i386"
fb15a570
FZ
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};
5c2ec9b6 29 make --output-sync {target} -j{jobs} {verbose};
fb15a570
FZ
30 """
31
fb15a570 32 def build_image(self, img):
40309abb 33 cimg = self._download_with_cache(
b3b9a433
AB
34 "https://cloud-images.ubuntu.com/releases/bionic/release-20191114/ubuntu-18.04-server-cloudimg-i386.img",
35 sha256sum="28969840626d1ea80bb249c08eef1a4533e8904aa51a327b40f37ac4b4ff04ef")
fb15a570
FZ
36 img_tmp = img + ".tmp"
37 subprocess.check_call(["cp", "-f", cimg, img_tmp])
1e48931c 38 self.exec_qemu_img("resize", img_tmp, "50G")
b081986c 39 self.boot(img_tmp, extra_args = ["-cdrom", self.gen_cloud_init_iso()])
fb15a570
FZ
40 self.wait_ssh()
41 self.ssh_root_check("touch /etc/cloud/cloud-init.disabled")
42 self.ssh_root_check("apt-get update")
43 self.ssh_root_check("apt-get install -y cloud-initramfs-growroot")
44 # Don't check the status in case the guest hang up too quickly
45 self.ssh_root("sync && reboot")
46 time.sleep(5)
47 self.wait_ssh()
48 # The previous update sometimes doesn't survive a reboot, so do it again
95c44c25 49 self.ssh_root_check("sed -ie s/^#\ deb-src/deb-src/g /etc/apt/sources.list")
fb15a570
FZ
50 self.ssh_root_check("apt-get update")
51 self.ssh_root_check("apt-get build-dep -y qemu")
b4eca581 52 self.ssh_root_check("apt-get install -y libfdt-dev flex bison language-pack-en")
fb15a570
FZ
53 self.ssh_root("poweroff")
54 self.wait()
fb15a570
FZ
55 os.rename(img_tmp, img)
56 return 0
57
58if __name__ == "__main__":
59 sys.exit(basevm.main(UbuntuX86VM))