Installing local dependencies while offline, without PyPI access, requires the python3-setuptools and python3-wheel packages. Most distributions have these available anyway for one reason or another, but not all of them. If you are asking yourself "Wait, aren't these packages guaranteed via installation of pip, via the ensurepip module, which mkvenv takes immense pains to provide for us?" - Well... since Python 3.13, "pip" does not actually come with "setuptools" or "wheel" anymore, and so if we want to build and install a python package, we actually need these available in the host environment. (Note that you don't need these packages just to install a pre-built package, you only need them to *build* a package. With cutting edge setuptools and pip, all locally installed packages, even in editable mode, must be "built" first before being installed. Thus, these dependencies are being added specifically to facilitate installing qemu.git/python/qemu to the configure-time venv.) Reviewed-by: Thomas Huth <thuth@redhat.com> Message-ID: <20260218213416.674483-12-jsnow@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com>
125 lines
3.4 KiB
Python
Executable File
125 lines
3.4 KiB
Python
Executable File
#!/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/r1beta4-x86_64/versions/20230114/providers/libvirt.box"
|
|
csum = "6e72a2a470e03dbc3c5e808664e057bb4022b390dca88e4c7da6188f26f6a3c9"
|
|
|
|
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",
|
|
"pip",
|
|
"tomli_python310",
|
|
"wheel_python310",
|
|
"setuptools_python310",
|
|
]
|
|
|
|
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/1/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("echo yes | pkgman add-repo https://eu.hpkg.haiku-os.org/haiku/r1beta5/$(getarch)/current")
|
|
self.ssh_root("echo yes | pkgman add-repo https://eu.hpkg.haiku-os.org/haikuports/r1beta5/$(getarch)/current")
|
|
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))
|