# -*- 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.2 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  bfd7abaefdaa16d8c3d203b3b0c42a35efd65eb4 \
                        sha256  a2485d090932eb1b2a7d9801c737c010ab76ae0730f32effe26af702afd3fd7a \
                        size    130534

# 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}"
        }
    }
}
