#!/usr/bin/env python3
#
# OpenBSD VM image
#
# Copyright 2017-2019 Red Hat Inc.
#
# Authors:
#  Fam Zheng <famz@redhat.com>
#  Gerd Hoffmann <kraxel@redhat.com>
#
# This code is licensed under the GPL version 2 or later.  See
# the COPYING file in the top-level directory.
#

import os
import sys
import socket
import subprocess
import basevm

class OpenBSDVM(basevm.BaseVM):
    name = "openbsd"
    arch = "x86_64"

    link = "https://cdn.openbsd.org/pub/OpenBSD/7.6/amd64/install76.iso"
    csum = "60cba8cb391b50bba8fa10fc768bd0529636f5345d82133c93e22c798d8e5269"
    size = "20G"
    pkgs = [
        # tools
        "dtc",
        "git",
        "pkgconf",
        "bzip2", "xz",
        "ninja",

        # gnu tools
        "bash",
        "gmake",
        "gsed",
        "gettext-tools",

        # libs: usb
        "libusb1--",

        # libs: crypto
        "gnutls",

        # libs: images
        "jpeg",
        "png",

        # libs: ui
        "capstone",
        "sdl2",
        "gtk+3",
        "libxkbcommon",

        # libs: migration
        "zstd",

        # libs: networking
        "libslirp",
    ]

    BUILD_SCRIPT = """
        set -e;
        rm -rf /home/qemu/qemu-test.*
        cd $(mktemp -d /home/qemu/qemu-test.XXXXXX);
        mkdir src build; cd src;
        tar -xf /dev/rsd1c;
        cd ../build;
        ../src/configure --cc=cc  --extra-cflags=-I/usr/local/include \
                         --extra-ldflags=-L/usr/local/lib {configure_opts};
        gmake --output-sync -j{jobs} {target} {verbose};
    """
    poweroff = "halt -p"

    def build_image(self, img):
        self.print_step("Downloading install iso")
        cimg = self._download_with_cache(self.link, sha256sum=self.csum)
        img_tmp = img + ".tmp"
        iso = img + ".install.iso"

        self.print_step("Preparing iso and disk image")
        subprocess.check_call(["cp", "-f", cimg, iso])
        self.exec_qemu_img("create", "-f", "qcow2", img_tmp, self.size)

        self.print_step("Booting installer")
        self.boot(img_tmp, extra_args = [
            "-machine", "graphics=off",
            "-device", "VGA",
            "-cdrom", iso
        ])
        self.console_init()
        self.console_wait_send("boot>", "set tty com0\n")
        self.console_wait_send("boot>", "\n")

        # pre-install configuration
        self.console_wait_send("(I)nstall",               "i\n")
        self.console_wait_send("Terminal type",           "xterm\n")
        self.console_wait_send("System hostname",         "openbsd\n")
        self.console_wait_send("Network interface to configure", "vio0\n")
        self.console_wait_send("IPv4 address",            "autoconf\n")
        self.console_wait_send("IPv6 address",            "none\n")
        self.console_wait_send("Network interface to configure", "done\n")
        self.console_wait("Password for root account")
        self.console_send("%s\n" % self._config["root_pass"])
        self.console_wait("Password for root account")
        self.console_send("%s\n" % self._config["root_pass"])
        self.console_wait_send("Start sshd(8)",           "yes\n")
        self.console_wait_send("X Window System",         "no\n")
        self.console_wait_send("console to com0",         "\n")
        self.console_wait_send("Which speed",             "\n")

        self.console_wait("Setup a user")
        self.console_send("%s\n" % self._config["guest_user"])
        self.console_wait("Full name")
        self.console_send("%s\n" % self._config["guest_user"])
        self.console_wait("Password")
        self.console_send("%s\n" % self._config["guest_pass"])
        self.console_wait("Password")
        self.console_send("%s\n" % self._config["guest_pass"])

        self.console_wait_send("Allow root ssh login",    "yes\n")
        self.console_wait_send("timezone",                "UTC\n")
        self.console_wait_send("root disk",               "\n")
        self.console_wait_send("Encrypt the root disk with a (p)assphrase", "no\n")
        self.console_wait_send("(W)hole disk",            "\n")
        self.console_wait_send("(A)uto layout",           "c\n")

        # 4000 MB / as /dev/sd0a, at start of disk
        self.console_wait_send("sd0>", "a a\n")
        self.console_wait_send("offset:", "\n")
        self.console_wait_send("size:", "4000M\n")
        self.console_wait_send("FS type", "4.2BSD\n")
        self.console_wait_send("mount point:", "/\n")

        # 256 MB swap as /dev/sd0b
        self.console_wait_send("sd0*>", "a b\n")
        self.console_wait_send("offset:", "\n")
        self.console_wait_send("size:", "256M\n")
        self.console_wait_send("FS type", "swap\n")

        # All remaining space for /home as /dev/sd0d
        # NB, 'c' isn't allowed to be used.
        self.console_wait_send("sd0*>", "a d\n")
        self.console_wait_send("offset:", "\n")
        self.console_wait_send("size:", "\n")
        self.console_wait_send("FS type", "4.2BSD\n")
        self.console_wait_send("mount point:", "/home\n")

        self.console_wait_send("sd0*>", "q\n")
        self.console_wait_send("Write new label?:", "y\n")

        self.console_wait_send("Location of sets",        "cd0\n")
        self.console_wait_send("Pathname to the sets",    "\n")
        self.console_wait_send("Set name(s)",             "\n")
        self.console_wait_send("without verification",    "yes\n")

        self.print_step("Installation started now, this will take a while")
        self.console_wait_send("Location of sets",        "done\n")
        self.console_wait_send("Time appears wrong.  Set to", "\n")

        self.console_wait("successfully completed")
        self.print_step("Installation finished, rebooting")
        self.console_wait_send("(R)eboot",                "reboot\n")

        # setup qemu user
        prompt = "$"
        self.console_ssh_init(prompt, self._config["guest_user"],
                                      self._config["guest_pass"])
        self.console_wait_send(prompt, "exit\n")

        # setup root user
        prompt = "openbsd#"
        self.console_ssh_init(prompt, "root", self._config["root_pass"])
        self.console_sshd_config(prompt)

        # setup virtio-blk #1 (tarfile)
        self.console_wait(prompt)
        self.console_send("echo 'chmod 666 /dev/rsd1c' >> /etc/rc.local\n")

        # enable w+x for /home
        self.console_wait(prompt)
        self.console_send("sed -i -e '/home/s/rw,/rw,wxallowed,/' /etc/fstab\n")

        # tweak datasize limit
        self.console_wait(prompt)
        self.console_send("sed -i -e 's/\\(datasize[^=]*\\)=[^:]*/\\1=infinity/' /etc/login.conf\n")

        # use http (be proxy cache friendly)
        self.console_wait(prompt)
        self.console_send("sed -i -e 's/https/http/' /etc/installurl\n")

        self.print_step("Configuration finished, rebooting")
        self.console_wait_send(prompt, "reboot\n")
        self.console_wait("login:")
        self.wait_ssh()

        self.print_step("Installing packages")
        self.ssh_root_check("pkg_add %s\n" % " ".join(self.pkgs))

        # shutdown
        self.ssh_root(self.poweroff)
        self.wait()

        if os.path.exists(img):
            os.remove(img)
        os.rename(img_tmp, img)
        os.remove(iso)
        self.print_step("All done")

if __name__ == "__main__":
    sys.exit(basevm.main(OpenBSDVM))
