5 # Copyright 2017-2019 Red Hat Inc.
8 # Fam Zheng <famz@redhat.com>
9 # Gerd Hoffmann <kraxel@redhat.com>
11 # This code is licensed under the GPL version 2 or later. See
12 # the COPYING file in the top-level directory.
23 class FreeBSDVM(basevm.BaseVM):
27 link = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz"
28 csum = "1d40015bea89d05b8bd13e2ed80c40b522a9ec1abd8e7c8b80954fb485fb99db"
62 rm -rf /home/qemu/qemu-test.*
63 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
64 mkdir src build; cd src;
67 ../src/configure --python=python3.7 {configure_opts};
68 gmake --output-sync -j{jobs} {target} {verbose};
71 def console_boot_serial(self):
72 self.console_wait_send("Autoboot", "3")
73 self.console_wait_send("OK", "set console=comconsole\n")
74 self.console_wait_send("OK", "boot\n")
76 def build_image(self, img):
77 self.print_step("Downloading install iso")
78 cimg = self._download_with_cache(self.link, sha256sum=self.csum)
79 img_tmp = img + ".tmp"
80 iso = img + ".install.iso"
83 self.print_step("Preparing iso and disk image")
84 subprocess.check_call(["cp", "-f", cimg, iso_xz])
85 subprocess.check_call(["xz", "-dvf", iso_xz])
86 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
88 self.print_step("Booting installer")
89 self.boot(img_tmp, extra_args = [
90 "-bios", "pc-bios/bios-256k.bin",
91 "-machine", "graphics=off",
95 self.console_boot_serial()
96 self.console_wait_send("Console type", "xterm\n")
98 # pre-install configuration
99 self.console_wait_send("Welcome", "\n")
100 self.console_wait_send("Keymap Selection", "\n")
101 self.console_wait_send("Set Hostname", "freebsd\n")
102 self.console_wait_send("Distribution Select", "\n")
103 self.console_wait_send("Partitioning", "\n")
104 self.console_wait_send("Partition", "\n")
105 self.console_wait_send("Scheme", "\n")
106 self.console_wait_send("Editor", "f")
107 self.console_wait_send("Confirmation", "c")
109 self.print_step("Installation started now, this will take a while")
111 # post-install configuration
112 self.console_wait("New Password:")
113 self.console_send("%s\n" % self.ROOT_PASS)
114 self.console_wait("Retype New Password:")
115 self.console_send("%s\n" % self.ROOT_PASS)
117 self.console_wait_send("Network Configuration", "\n")
118 self.console_wait_send("IPv4", "y")
119 self.console_wait_send("DHCP", "y")
120 self.console_wait_send("IPv6", "n")
121 self.console_wait_send("Resolver", "\n")
123 self.console_wait_send("Time Zone Selector", "a\n")
124 self.console_wait_send("Confirmation", "y")
125 self.console_wait_send("Time & Date", "\n")
126 self.console_wait_send("Time & Date", "\n")
128 self.console_wait_send("System Configuration", "\n")
129 self.console_wait_send("System Hardening", "\n")
132 self.console_wait_send("Add User Accounts", "y")
133 self.console_wait("Username")
134 self.console_send("%s\n" % self.GUEST_USER)
135 self.console_wait("Full name")
136 self.console_send("%s\n" % self.GUEST_USER)
137 self.console_wait_send("Uid", "\n")
138 self.console_wait_send("Login group", "\n")
139 self.console_wait_send("Login group", "\n")
140 self.console_wait_send("Login class", "\n")
141 self.console_wait_send("Shell", "\n")
142 self.console_wait_send("Home directory", "\n")
143 self.console_wait_send("Home directory perm", "\n")
144 self.console_wait_send("Use password", "\n")
145 self.console_wait_send("Use an empty password", "\n")
146 self.console_wait_send("Use a random password", "\n")
147 self.console_wait("Enter password:")
148 self.console_send("%s\n" % self.GUEST_PASS)
149 self.console_wait("Enter password again:")
150 self.console_send("%s\n" % self.GUEST_PASS)
151 self.console_wait_send("Lock out", "\n")
152 self.console_wait_send("OK", "yes\n")
153 self.console_wait_send("Add another user", "no\n")
155 self.console_wait_send("Final Configuration", "\n")
156 self.console_wait_send("Manual Configuration", "\n")
157 self.console_wait_send("Complete", "\n")
159 self.print_step("Installation finished, rebooting")
160 self.console_boot_serial()
164 self.console_ssh_init(prompt, self.GUEST_USER, self.GUEST_PASS)
165 self.console_wait_send(prompt, "exit\n")
168 prompt = "root@freebsd:~ #"
169 self.console_ssh_init(prompt, "root", self.ROOT_PASS)
170 self.console_sshd_config(prompt)
172 # setup serial console
173 self.console_wait(prompt)
174 self.console_send("echo 'console=comconsole' >> /boot/loader.conf\n")
177 self.console_wait(prompt)
178 self.console_send("echo 'autoboot_delay=1' >> /boot/loader.conf\n")
180 # setup virtio-blk #1 (tarfile)
181 self.console_wait(prompt)
182 self.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\n")
184 self.print_step("Configuration finished, rebooting")
185 self.console_wait_send(prompt, "reboot\n")
186 self.console_wait("login:")
189 self.print_step("Installing packages")
190 self.ssh_root_check("pkg install -y %s\n" % " ".join(self.pkgs))
193 self.ssh_root(self.poweroff)
194 self.console_wait("Uptime:")
197 if os.path.exists(img):
199 os.rename(img_tmp, img)
201 self.print_step("All done")
203 if __name__ == "__main__":
204 sys.exit(basevm.main(FreeBSDVM))