#!/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

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

    link = "https://download.freebsd.org/ftp/releases/ISO-IMAGES/12.1/FreeBSD-12.1-RELEASE-amd64-disc1.iso.xz"
    csum = "7394c3f60a1e236e7bd3a05809cf43ae39a3b8e5d42d782004cf2f26b1cfcd88"
    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 = [
            "-bios", "pc-bios/bios-256k.bin",
            "-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",    "a\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))
