#!/usr/bin/env python3
#
# Haiku VM image
#
# Copyright 2020 Haiku, Inc.
#
# Authors:
#  Alexander von Gluck IV <kallisti5@unixzen.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

VAGRANT_KEY_FILE = os.path.join(os.path.dirname(__file__),
    "..", "keys", "vagrant")

VAGRANT_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__),
    "..", "keys", "vagrant.pub")

HAIKU_CONFIG = {
    'cpu'             : "max",
    'machine'         : 'pc',
    'guest_user'      : "vagrant",
    'guest_pass'      : "",
    'root_user'       : "vagrant",
    'root_pass'       : "",
    'ssh_key_file'    : VAGRANT_KEY_FILE,
    'ssh_pub_key_file': VAGRANT_PUB_KEY_FILE,
    'memory'          : "4G",
    'extra_args'      : [],
    'qemu_args'       : "-device VGA",
    'dns'             : "",
    'ssh_port'        : 0,
    'install_cmds'    : "",
    'boot_dev_type'   : "block",
    'ssh_timeout'     : 1,
}

class HaikuVM(basevm.BaseVM):
    name = "haiku"
    arch = "x86_64"

    link = "https://app.vagrantup.com/haiku-os/boxes/r1beta2-x86_64/versions/20200702/providers/libvirt.box"
    csum = "41c38b316e0cbdbc66b5dbaf3612b866700a4f35807cb1eb266a5bf83e9e68d5"

    poweroff = "shutdown"

    requirements = [
        "devel:libbz2",
        "devel:libcapstone",
        "devel:libcurl",
        "devel:libfdt",
        "devel:libgcrypt",
        "devel:libgl",
        "devel:libglib_2.0",
        "devel:libgnutls",
        "devel:libgpg_error",
        "devel:libintl",
        "devel:libjpeg",
        "devel:liblzo2",
        "devel:libncursesw",
        "devel:libnettle",
        "devel:libpixman_1",
        "devel:libpng16",
        "devel:libsdl2_2.0",
        "devel:libsnappy",
        "devel:libssh2",
        "devel:libtasn1",
        "devel:libusb_1.0",
        "devel:libz",
        "ninja",
    ]

    # https://dev.haiku-os.org/ticket/16512 virtio disk1 shows up as 0 (reversed order)
    BUILD_SCRIPT = """
        set -e;
        rm -rf /tmp/qemu-test.*
        cd $(mktemp -d /tmp/qemu-test.XXXXXX);
        mkdir src build; cd src;
        tar -xf /dev/disk/virtual/virtio_block/0/raw;
        mkdir -p /usr/bin
        ln -s /boot/system/bin/env /usr/bin/env
        cd ../build
        ../src/configure --disable-slirp {configure_opts};
        make --output-sync -j{jobs} {target} {verbose};
    """

    def build_image(self, img):
        self.print_step("Downloading disk image")
        tarball = self._download_with_cache(self.link, sha256sum=self.csum)

        self.print_step("Extracting disk image")

        subprocess.check_call(["tar", "xzf", tarball, "./box.img", "-O"],
                              stdout=open(img, 'wb'))

        self.print_step("Preparing disk image")
        self.boot(img)

        # Wait for ssh to be available.
        self.wait_ssh(wait_root=True, cmd="exit 0")

        # Install packages
        self.ssh_root("pkgman install -y %s" % " ".join(self.requirements))
        self.graceful_shutdown()

        self.print_step("All done")

if __name__ == "__main__":
    sys.exit(basevm.main(HaikuVM, config=HAIKU_CONFIG))
