# -*- 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.0 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  648572ff60e04c7da8e38b1c07781e2911fa7165 \
                        sha256  4efaf318729101076d3bf821baf88e5f5bf89374684b35b2674c824a76feafdf \
                        size    113281

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