#!/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.0/images/NetBSD-9.0-amd64.iso"
    csum = "34da4882ee61bdbf69f241195a8933dc800949d30b43fc6988da853d57fc2b8cac50cf97a0d2adaf93250b4e329d189c1a8b83c33bd515226f37745d50c33369"
    size = "20G"
    pkgs = [
        # tools
        "git-base",
        "pkgconf",
        "xz",
        "python37",

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

        # libs: crypto
        "gnutls",

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

	# libs: ui
        "SDL2",
        "gtk3+",
        "libxkbcommon",

        # libs: migration
        "zstd",
    ]

    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 --python=python3.7 --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 = [
            "-bios", "pc-bios/bios-256k.bin",
            "-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.ROOT_PASS)
        self.console_wait("New password:")
        self.console_send("%s\n" % self.ROOT_PASS)
        self.console_wait("Retype new password:")
        self.console_send("%s\n" % self.ROOT_PASS)

        self.console_wait_send("o: Add a user",            "o\n")
        self.console_wait("username")
        self.console_send("%s\n" % self.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.GUEST_PASS)
        self.console_wait("New password:")
        self.console_send("%s\n" % self.GUEST_PASS)
        self.console_wait("Retype new password:")
        self.console_send("%s\n" % self.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.GUEST_USER, self.GUEST_PASS)
        self.console_wait_send(prompt, "exit\n")

        # setup root user
        prompt = "localhost#"
        self.console_ssh_init(prompt, "root", self.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))
