# -*- 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                aspnetcore-runtime-devel
set main_version    11.0.0
# See patch version in https://dotnet.microsoft.com/download/dotnet/10.0
set patch_version   rc.2.26504.105
version             ${main_version}-${patch_version}
revision            0
categories          dotnet
license             MIT
maintainers         @BjarneDMat {@judaew judaew} openmaintainer

description         ASP.NET Core is a cross-platform .NET framework for building modern \
                    cloud-based web applications on Windows, Mac, or Linux.

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            aspnetcore-runtime-${version}-osx-x64
        checksums           rmd160  2b6a0adbde411e574b0edd5c7071fdde0d58d8bc \
                            sha256  540991ad107b3ac7b390cec57e885d524bf6f735fb66193baa1b1493ce768c6f \
                            size    50087829
    }
    arm64 {
        distname            aspnetcore-runtime-${version}-osx-arm64
        checksums           rmd160  cedfcc0f256dd58645815f22c9be97547377fc02 \
                            sha256  b1ecdde4be73a1e26952cea34d6da671bb75d3ef6ce2a32f8634d2ad0f45847e \
                            size    46886036
    }
    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/aspnetcore/Runtime/${version}/

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

use_configure       no

depends_run         port:dotnet-cli \
                    port:dotnet-runtime-devel

build {}

destroot {
    set dotnet_home ${prefix}/share/dotnet
    set runtime_dir /shared/Microsoft.AspNetCore.App
    xinstall -d ${destroot}${dotnet_home}${runtime_dir}

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

livecheck.version   [join [lrange [split ${patch_version} .] 0 0] .]
livecheck.type      regex
livecheck.url       https://dotnet.microsoft.com/download/dotnet/10.0
livecheck.regex     "ASP.NET Core Runtime ${main_version}-(\\d)"
