# -*- 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           golang 1.0

go.setup            github.com/crc-org/vfkit 0.6.3 v
categories          sysutils
maintainers         {judaew @judaew} openmaintainer
license             Apache-2

description         Simple command line tool to start VMs through \
    virtualization framework
long_description    {*}${description}.

checksums           ${distname}${extract.suffix} \
                        rmd160  b2bbda7a971913de4a05145542bf74c41a6e0af1 \
                        sha256  bb2a7f9d1bf41d2f823412ca20912bade606ae30b41afcd1366d32e3d100a09e \
                        size    130690

# FIXME: This port currently can't be built without allowing go mod to fetch
go.offline_build no

build.cmd           make
build.pre_args      GIT_VERSION=${version}

switch ${build_arch} {
    x86_64 {
        destroot {
            xinstall -m 0755 ${worksrcpath}/out/${name}-amd64 \
                ${destroot}${prefix}/bin/vfkit
        }
    }
    arm64 {
        destroot {
            xinstall -m 0755 ${worksrcpath}/out/${name}-arm64 \
                ${destroot}${prefix}/bin/vfkit
        }
    }
    default {
        known_fail yes
        pre-fetch {
            ui_error "${subport} @ ${version} only supported for architectures ${supported_archs}"
            return -code error "Unsupported architecture: ${build_arch}"
        }
    }
}
