#!/usr/bin/env python
#
# 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.0/FreeBSD-12.0-RELEASE-amd64-disc1.iso.xz"
    csum = "1d40015bea89d05b8bd13e2ed80c40b522a9ec1abd8e7c8b80954fb485fb99db"
    size = "20G"
    pkgs = [
        # build tools
        "git",
        "pkgconf",
        "bzip2",

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

        # libs: crypto
        "gnutls",

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

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

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

    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.6 {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",
            "-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.ROOT_PASS)
        self.console_wait("Retype New Password:")
        self.console_send("%s\n" % self.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.GUEST_USER)
        self.console_wait("Full name")
        self.console_send("%s\n" % self.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.GUEST_PASS)
        self.console_wait("Enter password again:")
        self.console_send("%s\n" % self.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.GUEST_USER, self.GUEST_PASS)
        self.console_wait_send(prompt, "exit\n")

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