]> git.proxmox.com Git - mirror_qemu.git/blob - tests/vm/fedora
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
[mirror_qemu.git] / tests / vm / fedora
1 #!/usr/bin/env python
2 #
3 # Fedora VM image
4 #
5 # Copyright 2019 Red Hat Inc.
6 #
7 # Authors:
8 # Gerd Hoffmann <kraxel@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 re
16 import sys
17 import time
18 import socket
19 import subprocess
20 import basevm
21
22 class FedoraVM(basevm.BaseVM):
23 name = "fedora"
24 arch = "x86_64"
25
26 base = "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/"
27 link = base + "Server/x86_64/iso/Fedora-Server-netinst-x86_64-30-1.2.iso"
28 repo = base + "Server/x86_64/os/"
29 full = base + "Everything/x86_64/os/"
30 csum = "5e4eac4566d8c572bfb3bcf54b7d6c82006ec3c6c882a2c9235c6d3494d7b100"
31 size = "20G"
32 pkgs = [
33 # tools
34 'git-core',
35 'flex', 'bison',
36 'gcc', 'binutils', 'make',
37
38 # perl
39 'perl-Test-Harness',
40
41 # libs: usb
42 '"pkgconfig(libusb-1.0)"',
43 '"pkgconfig(libusbredirparser-0.5)"',
44
45 # libs: crypto
46 '"pkgconfig(gnutls)"',
47
48 # libs: ui
49 '"pkgconfig(sdl2)"',
50 '"pkgconfig(gtk+-3.0)"',
51 '"pkgconfig(ncursesw)"',
52
53 # libs: audio
54 '"pkgconfig(libpulse)"',
55 '"pkgconfig(alsa)"',
56 ]
57
58 BUILD_SCRIPT = """
59 set -e;
60 rm -rf /home/qemu/qemu-test.*
61 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
62 mkdir src build; cd src;
63 tar -xf /dev/vdb;
64 cd ../build
65 ../src/configure --python=python3 {configure_opts};
66 gmake --output-sync -j{jobs} {target} {verbose};
67 """
68
69 def build_image(self, img):
70 self.print_step("Downloading install iso")
71 cimg = self._download_with_cache(self.link, sha256sum=self.csum)
72 img_tmp = img + ".tmp"
73 iso = img + ".install.iso"
74
75 self.print_step("Preparing iso and disk image")
76 subprocess.check_call(["cp", "-f", cimg, iso])
77 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
78 self.print_step("Booting installer")
79 self.boot(img_tmp, extra_args = [
80 "-bios", "pc-bios/bios-256k.bin",
81 "-machine", "graphics=off",
82 "-cdrom", iso
83 ])
84 self.console_init(300)
85 self.console_wait("installation process.")
86 time.sleep(0.3)
87 self.console_send("\t")
88 time.sleep(0.3)
89 self.console_send(" console=ttyS0")
90 proxy = os.environ.get("http_proxy")
91 if not proxy is None:
92 self.console_send(" proxy=%s" % proxy)
93 self.console_send(" inst.proxy=%s" % proxy)
94 self.console_send(" inst.repo=%s" % self.repo)
95 self.console_send("\n")
96
97 self.console_wait_send("2) Use text mode", "2\n")
98
99 self.console_wait_send("5) [!] Installation Dest", "5\n")
100 self.console_wait_send("1) [x]", "c\n")
101 self.console_wait_send("2) [ ] Use All Space", "2\n")
102 self.console_wait_send("2) [x] Use All Space", "c\n")
103 self.console_wait_send("1) [ ] Standard Part", "1\n")
104 self.console_wait_send("1) [x] Standard Part", "c\n")
105
106 self.console_wait_send("7) [!] Root password", "7\n")
107 self.console_wait("Password:")
108 self.console_send("%s\n" % self.ROOT_PASS)
109 self.console_wait("Password (confirm):")
110 self.console_send("%s\n" % self.ROOT_PASS)
111
112 self.console_wait_send("8) [ ] User creation", "8\n")
113 self.console_wait_send("1) [ ] Create user", "1\n")
114 self.console_wait_send("3) User name", "3\n")
115 self.console_wait_send("ENTER:", "%s\n" % self.GUEST_USER)
116 self.console_wait_send("4) [ ] Use password", "4\n")
117 self.console_wait_send("5) Password", "5\n")
118 self.console_wait("Password:")
119 self.console_send("%s\n" % self.GUEST_PASS)
120 self.console_wait("Password (confirm):")
121 self.console_send("%s\n" % self.GUEST_PASS)
122 self.console_wait_send("7) Groups", "c\n")
123
124 while True:
125 good = self.console_wait("3) [x] Installation",
126 "3) [!] Installation")
127 self.console_send("r\n")
128 if good:
129 break
130 time.sleep(10)
131
132 while True:
133 good = self.console_wait("4) [x] Software",
134 "4) [!] Software")
135 self.console_send("r\n")
136 if good:
137 break
138 time.sleep(10)
139 self.console_send("r\n" % self.GUEST_PASS)
140
141 self.console_wait_send("'b' to begin install", "b\n")
142
143 self.print_step("Installation started now, this will take a while")
144
145 self.console_wait_send("Installation complete", "\n")
146 self.print_step("Installation finished, rebooting")
147
148 # setup qemu user
149 prompt = " ~]$"
150 self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
151 self.console_wait_send(prompt, "exit\n")
152
153 # setup root user
154 prompt = " ~]#"
155 self.console_ssh_init(prompt, "root", self.ROOT_PASS)
156 self.console_sshd_config(prompt)
157
158 # setup virtio-blk #1 (tarfile)
159 self.console_wait(prompt)
160 self.console_send("echo 'KERNEL==\"vdb\" MODE=\"666\"' >> %s\n" %
161 "/etc/udev/rules.d/99-qemu.rules")
162
163 self.print_step("Configuration finished, rebooting")
164 self.console_wait_send(prompt, "reboot\n")
165 self.console_wait("login:")
166 self.wait_ssh()
167
168 self.print_step("Installing packages")
169 self.ssh_root_check("rm -vf /etc/yum.repos.d/fedora*.repo\n")
170 self.ssh_root_check("echo '[fedora]' >> /etc/yum.repos.d/qemu.repo\n")
171 self.ssh_root_check("echo 'baseurl=%s' >> /etc/yum.repos.d/qemu.repo\n" % self.full)
172 self.ssh_root_check("echo 'gpgcheck=0' >> /etc/yum.repos.d/qemu.repo\n")
173 self.ssh_root_check("dnf install -y %s\n" % " ".join(self.pkgs))
174
175 # shutdown
176 self.ssh_root(self.poweroff)
177 self.console_wait("sleep state S5")
178 self.wait()
179
180 if os.path.exists(img):
181 os.remove(img)
182 os.rename(img_tmp, img)
183 os.remove(iso)
184 self.print_step("All done")
185
186 if __name__ == "__main__":
187 sys.exit(basevm.main(FedoraVM))