#!/usr/bin/env python3
#
# NetBSD 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 time
import subprocess
import basevm

class NetBSDVM(basevm.BaseVM):
    name = "netbsd"
    arch = "x86_64"

    link = "https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/images/NetBSD-9.3-amd64.iso"
    csum = "2bfce544f762a579f61478e7106c436fc48731ff25cf6f79b392ba5752e6f5ec130364286f7471716290a5f033637cf56aacee7fedb91095face59adf36300c3"
    size = "20G"
    pkgs = [
        # tools
        "git-base",
        "pkgconf",
        "xz",
        "python310",
        "py310-expat",
        "ninja-build",

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

        # libs: crypto
        "gnutls",

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

        # libs: ui
        "capstone",
        "SDL2",
        "gtk3+",
        "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/rld1a;
        cd ../build
        ../src/configure --disable-opengl {configure_opts};
        gmake --output-sync -j{jobs} {target} {verbose};
    """
    poweroff = "/sbin/poweroff"

    # Workaround for NetBSD + IPv6 + slirp issues.
    # NetBSD seems to ignore the ICMPv6 Destination Unreachable
    # messages generated by slirp.  When the host has no IPv6
    # connectivity, this causes every connection to ftp.NetBSD.org
    # take more than a minute to be established.
    ipv6 = False

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

        self.print_step("Preparing iso and disk image")
        subprocess.check_call(["ln", "-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",
            "-cdrom", iso
        ])
        self.console_init()
        self.console_wait_send("3. Drop to boot prompt", "3")
        self.console_wait_send("> ", "consdev com0\n")
        self.console_wait_send("> ", "boot\n")

        self.console_wait_send("Terminal type",            "xterm\n")
        self.console_wait_send("a: Installation messages", "a\n")
        self.console_wait_send("a: Install NetBSD",        "a\n")
        self.console_wait("Shall we continue?")
        self.console_wait_send("b: Yes",                   "b\n")

        self.console_wait_send("a: ld0",                   "a\n")
        self.console_wait_send("a: Guid Partition Table",  "a\n")
        self.console_wait_send("a: This is the correct",   "a\n")
        self.console_wait_send("b: Use default part",      "b\n")
        self.console_wait_send("x: Partition sizes ok",    "x\n")
        self.console_wait("Shall we continue?")
        self.console_wait_send("b: Yes",                   "b\n")

        self.console_wait_send("b: Use serial port com0",  "b\n")
        self.console_wait_send("f: Set serial baud rate",  "f\n")
        self.console_wait_send("a: 9600",                  "a\n")
        self.console_wait_send("x: Continue",              "x\n")

        self.console_wait_send("a: Full installation",     "a\n")
        self.console_wait_send("a: CD-ROM",                "a\n")

        self.print_step("Installation started now, this will take a while")
        self.console_wait_send("Hit enter to continue",    "\n")

        self.console_wait_send("d: Change root password",  "d\n")
        self.console_wait_send("a: Yes",                   "a\n")
        self.console_wait("New password:")
        self.console_send("%s\n" % self._config["root_pass"])
        self.console_wait("New password:")
        self.console_send("%s\n" % self._config["root_pass"])
        self.console_wait("Retype new password:")
        self.console_send("%s\n" % self._config["root_pass"])

        self.console_wait_send("o: Add a user",            "o\n")
        self.console_wait("username")
        self.console_send("%s\n" % self._config["guest_user"])
        self.console_wait("to group wheel")
        self.console_wait_send("a: Yes",                   "a\n")
        self.console_wait_send("a: /bin/sh",               "a\n")
        self.console_wait("New password:")
        self.console_send("%s\n" % self._config["guest_pass"])
        self.console_wait("New password:")
        self.console_send("%s\n" % self._config["guest_pass"])
        self.console_wait("Retype new password:")
        self.console_send("%s\n" % self._config["guest_pass"])

        self.console_wait_send("a: Configure network",     "a\n")
        self.console_wait_send("a: vioif0",                "a\n")
        self.console_wait_send("Network media type",       "\n")
        self.console_wait("autoconfiguration")
        self.console_wait_send("a: Yes",                   "a\n")
        self.console_wait_send("DNS domain",               "localnet\n")
        self.console_wait("Are they OK?")
        self.console_wait_send("a: Yes",                   "a\n")
        self.console_wait("installed in /etc")
        self.console_wait_send("a: Yes",                   "a\n")

        self.console_wait_send("e: Enable install",        "e\n")
        proxy = os.environ.get("http_proxy")
        if not proxy is None:
            self.console_wait_send("f: Proxy",             "f\n")
            self.console_wait("Proxy")
            self.console_send("%s\n" % proxy)
        self.console_wait_send("x: Install pkgin",         "x\n")
        self.console_init(1200)
        self.console_wait_send("Hit enter to continue", "\n")
        self.console_init()

        self.console_wait_send("g: Enable sshd",           "g\n")
        self.console_wait_send("x: Finished conf",         "x\n")
        self.console_wait_send("Hit enter to continue",    "\n")

        self.print_step("Installation finished, rebooting")
        self.console_wait_send("d: Reboot the computer",   "d\n")

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

        # setup root user
        prompt = "localhost#"
        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/rld1a' >> /etc/rc.local\n")

        # turn off mprotect (conflicts with tcg)
        self.console_wait(prompt)
        self.console_send("echo security.pax.mprotect.enabled=0 >> /etc/sysctl.conf\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("pkgin update\n")
        self.ssh_root_check("pkgin -y install %s\n" % " ".join(self.pkgs))

        # shutdown
        self.ssh_root(self.poweroff)
        self.console_wait("entering state S5")
        self.wait()

        os.rename(img_tmp, img)
        os.remove(iso)
        self.print_step("All done")

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