# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        libkrun libkrunfw 5.6.2 v
github.tarball_from releases

revision            0

categories          emulators
license             GPL-2 LGPL-2.1
maintainers         {jesuschapman.me:developer @JesusChapman} openmaintainer

description         Dynamic library bundling a Linux kernel in a convenient storage format

long_description    {*}${description}. It is loaded at runtime by libkrun \
                    to boot Linux guests, and is required by krunvm to \
                    create microVMs on macOS.

# Upstream publishes a prebuilt aarch64 bundle (Linux kernel sources plus a
# Makefile that only compiles the bundled kernel.c into the dylib, so no
# kernel rebuild happens here). The distfile is a release asset rather than
# the source archive, hence the distname/extract.suffix/worksrcdir overrides.
distname            libkrunfw-prebuilt-aarch64
extract.suffix      .tgz
worksrcdir          libkrunfw

checksums           ${distname}${extract.suffix} \
                    rmd160  c85d1b39f597dd4dfe3325411f70af8e9af46332 \
                    sha256  adef6739cc3bda2a1b57f04c08ccbfdf206a6c831d76b32de1beddc0e7984e86 \
                    size    20019726

# Prebuilt aarch64 bundle; libkrun only supports Hypervisor.framework on arm64.
supported_archs     arm64

use_configure       no

destroot.args-append \
                    PREFIX=${prefix}

notes "
To create microVMs with krunvm, install this port alongside krunvm: libkrun \
locates ${prefix}/lib/libkrunfw.5.dylib at runtime.
"
