5 # Copyright 2017-2019 Red Hat Inc.
11 # This code is licensed under the GPL version 2 or later. See
12 # the COPYING file in the top-level directory.
21 class OpenBSDVM(basevm.BaseVM):
25 link = "https://cdn.openbsd.org/pub/OpenBSD/7.2/amd64/install72.iso"
26 csum = "0369ef40a3329efcb978c578c7fdc7bda71e502aecec930a74b44160928c91d3"
66 rm -rf /home/qemu/qemu-test.*
67 cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
68 mkdir src build; cd src;
71 ../src/configure --cc=cc --python=python3 {configure_opts};
72 gmake --output-sync -j{jobs} {target} {verbose};
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"
82 self.print_step("Preparing iso and disk image")
83 subprocess.check_call(["cp", "-f", cimg, iso])
84 self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)
86 self.print_step("Booting installer")
87 self.boot(img_tmp, extra_args = [
88 "-machine", "graphics=off",
93 self.console_wait_send("boot>", "set tty com0\n")
94 self.console_wait_send("boot>", "\n")
96 # pre-install configuration
97 self.console_wait_send("(I)nstall", "i\n")
98 self.console_wait_send("Terminal type", "xterm\n")
99 self.console_wait_send("System hostname", "openbsd\n")
100 self.console_wait_send("Which network interface", "vio0\n")
101 self.console_wait_send("IPv4 address", "autoconf\n")
102 self.console_wait_send("IPv6 address", "none\n")
103 self.console_wait_send("Which network interface", "done\n")
104 self.console_wait("Password for root account")
105 self.console_send("%s\n" % self._config["root_pass"])
106 self.console_wait("Password for root account")
107 self.console_send("%s\n" % self._config["root_pass"])
108 self.console_wait_send("Start sshd(8)", "yes\n")
109 self.console_wait_send("X Window System", "\n")
110 self.console_wait_send("xenodm", "\n")
111 self.console_wait_send("console to com0", "\n")
112 self.console_wait_send("Which speed", "\n")
114 self.console_wait("Setup a user")
115 self.console_send("%s\n" % self._config["guest_user"])
116 self.console_wait("Full name")
117 self.console_send("%s\n" % self._config["guest_user"])
118 self.console_wait("Password")
119 self.console_send("%s\n" % self._config["guest_pass"])
120 self.console_wait("Password")
121 self.console_send("%s\n" % self._config["guest_pass"])
123 self.console_wait_send("Allow root ssh login", "yes\n")
124 self.console_wait_send("timezone", "UTC\n")
125 self.console_wait_send("root disk", "\n")
126 self.console_wait_send("(W)hole disk", "\n")
127 self.console_wait_send("(A)uto layout", "\n")
128 self.console_wait_send("Location of sets", "cd0\n")
129 self.console_wait_send("Pathname to the sets", "\n")
130 self.console_wait_send("Set name(s)", "\n")
131 self.console_wait_send("without verification", "yes\n")
133 self.print_step("Installation started now, this will take a while")
134 self.console_wait_send("Location of sets", "done\n")
136 self.console_wait("successfully completed")
137 self.print_step("Installation finished, rebooting")
138 self.console_wait_send("(R)eboot", "reboot\n")
142 self.console_ssh_init(prompt, self._config["guest_user"],
143 self._config["guest_pass"])
144 self.console_wait_send(prompt, "exit\n")
148 self.console_ssh_init(prompt, "root", self._config["root_pass"])
149 self.console_sshd_config(prompt)
151 # setup virtio-blk #1 (tarfile)
152 self.console_wait(prompt)
153 self.console_send("echo 'chmod 666 /dev/rsd1c' >> /etc/rc.local\n")
155 # enable w+x for /home
156 self.console_wait(prompt)
157 self.console_send("sed -i -e '/home/s/rw,/rw,wxallowed,/' /etc/fstab\n")
159 # tweak datasize limit
160 self.console_wait(prompt)
161 self.console_send("sed -i -e 's/\\(datasize[^=]*\\)=[^:]*/\\1=infinity/' /etc/login.conf\n")
163 # use http (be proxy cache friendly)
164 self.console_wait(prompt)
165 self.console_send("sed -i -e 's/https/http/' /etc/installurl\n")
167 self.print_step("Configuration finished, rebooting")
168 self.console_wait_send(prompt, "reboot\n")
169 self.console_wait("login:")
172 self.print_step("Installing packages")
173 self.ssh_root_check("pkg_add %s\n" % " ".join(self.pkgs))
176 self.ssh_root(self.poweroff)
179 if os.path.exists(img):
181 os.rename(img_tmp, img)
183 self.print_step("All done")
185 if __name__ == "__main__":
186 sys.exit(basevm.main(OpenBSDVM))