5 # Copyright 2020 Haiku, Inc.
8 # Alexander von Gluck IV <kallisti5@unixzen.com>
10 # This code is licensed under the GPL version 2 or later. See
11 # the COPYING file in the top-level directory.
22 VAGRANT_KEY_FILE = os.path.join(os.path.dirname(__file__),
23 "..", "keys", "vagrant")
25 VAGRANT_PUB_KEY_FILE = os.path.join(os.path.dirname(__file__),
26 "..", "keys", "vagrant.pub")
31 'guest_user' : "vagrant",
33 'root_user' : "vagrant",
35 'ssh_key_file' : VAGRANT_KEY_FILE,
36 'ssh_pub_key_file': VAGRANT_PUB_KEY_FILE,
39 'qemu_args' : "-device VGA",
43 'boot_dev_type' : "block",
47 class HaikuVM(basevm.BaseVM):
51 link = "https://app.vagrantup.com/haiku-os/boxes/r1beta2-x86_64/versions/20200702/providers/libvirt.box"
52 csum = "41c38b316e0cbdbc66b5dbaf3612b866700a4f35807cb1eb266a5bf83e9e68d5"
82 # https://dev.haiku-os.org/ticket/16512 virtio disk1 shows up as 0 (reversed order)
85 rm -rf /tmp/qemu-test.*
86 cd $(mktemp -d /tmp/qemu-test.XXXXXX);
87 mkdir src build; cd src;
88 tar -xf /dev/disk/virtual/virtio_block/0/raw;
90 ln -s /boot/system/bin/env /usr/bin/env
92 ../src/configure --disable-slirp {configure_opts};
93 make --output-sync -j{jobs} {target} {verbose};
96 def build_image(self, img):
97 self.print_step("Downloading disk image")
98 tarball = self._download_with_cache(self.link, sha256sum=self.csum)
100 self.print_step("Extracting disk image")
102 subprocess.check_call(["tar", "xzf", tarball, "./box.img", "-O"],
103 stdout=open(img, 'wb'))
105 self.print_step("Preparing disk image")
108 # Wait for ssh to be available.
109 self.wait_ssh(wait_root=True, cmd="exit 0")
112 self.ssh_root("pkgman install -y %s" % " ".join(self.requirements))
113 self.graceful_shutdown()
115 self.print_step("All done")
117 if __name__ == "__main__":
118 sys.exit(basevm.main(HaikuVM, config=HAIKU_CONFIG))