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

name                dotnet-runtime-10
version             10.0.1
revision            0
categories          dotnet
license             MIT
maintainers         @BjarneDMat {@judaew judaew} openmaintainer

description         .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.

long_description    .NET is a free, cross-platform, open source developer platform \
                    for building many different types of applications. \
                    \
                    With .NET, you can use multiple languages, editors, and libraries \
                    to build for web, mobile, desktop, games, and IoT.

homepage            https://dotnet.microsoft.com/
platforms           {darwin any} {darwin >= 21}
supported_archs     x86_64 arm64

switch ${build_arch} {
    x86_64 {
        distname            dotnet-runtime-${version}-osx-x64
        checksums           rmd160  5d1a67d45b4bcf6ee406310cd9b049fc2748969b \
                            sha256  50319c87ed9c9985b0d9b1c209bbdfc8de59355782515d706c5b2d78c215c309 \
                            size    35573405
    }
    arm64 {
        distname            dotnet-runtime-${version}-osx-arm64
        checksums           rmd160  54e9541f2989cd016c0d087e85133d907e1b5fe9 \
                            sha256  cd0fdaeff18b56590bd8b7c6d254f9737000c456d337cfb1dc9ce464734dd3d1 \
                            size    33204846
    }
    default {
        known_fail yes
        pre-fetch {
            ui_error "${subport} @ ${version} only supported for architectures ${supported_archs}"
            return -code error "Unsupported architecture: ${build_arch}"
        }
    }
}

master_sites        https://builds.dotnet.microsoft.com/dotnet/Runtime/${version}/

worksrcdir          ${name}-${version}
extract.mkdir       yes

use_configure       no

depends_run         port:dotnet-cli

build {}

destroot {
    set dotnet_home ${prefix}/share/dotnet
    set hostfxr_dir /host/fxr
    set runtime_dir /shared/Microsoft.NETCore.App
    xinstall -d ${destroot}${dotnet_home}${hostfxr_dir}
    xinstall -d ${destroot}${dotnet_home}${runtime_dir}

    move ${worksrcpath}${hostfxr_dir}/${version} ${destroot}${dotnet_home}${hostfxr_dir}
    move ${worksrcpath}${runtime_dir}/${version} ${destroot}${dotnet_home}${runtime_dir}
}

livecheck.type      regex
livecheck.url       https://dotnet.microsoft.com/download/dotnet/10.0
livecheck.regex     ".NET Runtime (\\d+(?:\\.\\d+)*)"
