#!/usr/bin/env python3
#
# FreeBSD 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 re
import sys
import time
import socket
import subprocess
import basevm

FREEBSD_CONFIG = {
    'cpu'	: "max,sse4.2=off",
}

class FreeBSDVM(basevm.BaseVM):
    name = "freebsd"
    arch = "x86_64"

    link = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.3/FreeBSD-12.3-RELEASE-amd64-disc1.iso.xz"
    csum = "36dd0de50f1fe5f0a88e181e94657656de26fb64254412f74e80e128e8b938b4"
    size = "20G"
    pkgs = [
        # build tools
        "git",
        "pkgconf",
        "bzip2",
        "python37",
        "ninja",

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

        # libs: crypto
        "gnutls",

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

        # libs: ui
        "sdl2",
        "gtk3",
        "libxkbcommon",

        # libs: opengl
        "libepoxy",
        "mesa-libs",

        # 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/vtbd1;
        cd ../build
        ../src/configure --python=python3.7 {configure_opts};
        gmake --output-sync -j{jobs} {target} {verbose};
    """

    def console_boot_serial(self):
        self.console_wait_send("Autoboot", "3")
        self.console_wait_send("OK", "set console=comconsole\n")
        self.console_wait_send("OK", "boot\n")

    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"
        iso_xz = iso + ".xz"

        self.print_step("Preparing iso and disk image")
        subprocess.check_call(["cp", "-f", cimg, iso_xz])
        subprocess.check_call(["xz", "-dvf", iso_xz])
        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_boot_serial()
        self.console_wait_send("Console type",          "xterm\n")

        # pre-install configuration
        self.console_wait_send("Welcome",               "\n")
        self.console_wait_send("Keymap Selection",      "\n")
        self.console_wait_send("Set Hostname",          "freebsd\n")
        self.console_wait_send("Distribution Select",   "\n")
        self.console_wait_send("Partitioning",          "\n")
        self.console_wait_send("Partition",             "\n")
        self.console_wait_send("Scheme",                "\n")
        self.console_wait_send("Editor",                "f")
        self.console_wait_send("Confirmation",          "c")

        self.print_step("Installation started now, this will take a while")

        # post-install configuration
        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("Network Configuration", "\n")
        self.console_wait_send("IPv4",                  "y")
        self.console_wait_send("DHCP",                  "y")
        self.console_wait_send("IPv6",                  "n")
        self.console_wait_send("Resolver",              "\n")

        self.console_wait_send("Time Zone Selector",    "0\n")
        self.console_wait_send("Confirmation",          "y")
        self.console_wait_send("Time & Date",           "\n")
        self.console_wait_send("Time & Date",           "\n")

        self.console_wait_send("System Configuration",  "\n")
        self.console_wait_send("System Hardening",      "\n")

        # qemu user
        self.console_wait_send("Add User Accounts", "y")
        self.console_wait("Username")
        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_send("Uid",                   "\n")
        self.console_wait_send("Login group",           "\n")
        self.console_wait_send("Login group",           "\n")
        self.console_wait_send("Login class",           "\n")
        self.console_wait_send("Shell",                 "\n")
        self.console_wait_send("Home directory",        "\n")
        self.console_wait_send("Home directory perm",   "\n")
        self.console_wait_send("Use password",          "\n")
        self.console_wait_send("Use an empty password", "\n")
        self.console_wait_send("Use a random password", "\n")
        self.console_wait("Enter password:")
        self.console_send("%s\n" % self._config["guest_pass"])
        self.console_wait("Enter password again:")
        self.console_send("%s\n" % self._config["guest_pass"])
        self.console_wait_send("Lock out",              "\n")
        self.console_wait_send("OK",                    "yes\n")
        self.console_wait_send("Add another user",      "no\n")

        self.console_wait_send("Final Configuration",   "\n")
        self.console_wait_send("Manual Configuration",  "\n")
        self.console_wait_send("Complete",              "\n")

        self.print_step("Installation finished, rebooting")
        self.console_boot_serial()

        # 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 = "root@freebsd:~ #"
        self.console_ssh_init(prompt, "root", self._config["root_pass"])
        self.console_sshd_config(prompt)

        # setup serial console
        self.console_wait(prompt)
        self.console_send("echo 'console=comconsole' >> /boot/loader.conf\n")

        # setup boot delay
        self.console_wait(prompt)
        self.console_send("echo 'autoboot_delay=1' >> /boot/loader.conf\n")

        # setup virtio-blk #1 (tarfile)
        self.console_wait(prompt)
        self.console_send("echo 'chmod 666 /dev/vtbd1' >> /etc/rc.local\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 install -y %s\n" % " ".join(self.pkgs))

        # shutdown
        self.ssh_root(self.poweroff)
        self.console_wait("Uptime:")
        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(FreeBSDVM, config=FREEBSD_CONFIG))
