1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!/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))
|