#!/usr/bin/env python3
#
# Haiku VM image
#
# Copyright 2020-2022 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/r1beta3-x86_64/versions/20220216/providers/libvirt.box"
    csum = "e67d4aacbcc687013d5cc91990ddd86cc5d70a5d28432ae2691944f8ce5d5041"

    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:libslirp",
        "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 {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))
