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

github.setup        apple container 0.9.0
github.tarball_from archive

revision            1
categories          devel
license             Apache-2
maintainers         nomaintainer

description         A tool to create and run Linux containers on your Mac
long_description    container is a tool that you can use to create and run Linux \
                    containers as lightweight virtual machines on your Mac. \
                    The tool consumes and produces OCI-compatible container images, \
                    so you can pull and run images from any standard container \
                    registry. You can push images that you build to those registries \
                    as well, and run the images in any other OCI-compatible application.

checksums           rmd160  13601de4f8fa745c9d2945b5edcf79e5949e80b3 \
                    sha256  2199d9f7241d7363a7cd3687e4fc3dd571c0b6a52c971266b9f2fe24fdb66eda \
                    size    786836

# The version number for macosx is the darwin version number (os.major)
platforms           {macosx >= 25}
supported_archs     arm64

if {${os.platform} eq "darwin" && (${os.major} < 25 || ${os.arch} ne "arm")} {
    known_fail yes
    pre-fetch {
        ui_error "${name} requires macOS 26 or later on Apple Silicon (arm64)."
        return -code error "incompatible macOS version or architecture"
    }
}

use_configure       no
use_parallel_build  no
installs_libs       no

build.target        build
# Disable the swift sandbox since the port build already runs in a sandbox
build.pre_args      BUILD_CONFIGURATION=release SWIFT_CONFIGURATION="--disable-sandbox --cache-path ${workpath}/.swiftpm/cache --security-path ${workpath}/.swiftpm/security --config-path ${workpath}/.swiftpm/config" ${build.target}

destroot.target     install
destroot.pre_args   BUILD_CONFIGURATION=release DEST_DIR="${destroot}${prefix}/" RELEASE_VERSION=${version} SUDO= ${destroot.target}

post-destroot {
    # Remove the unnecessary uninstall script
    file delete -force ${destroot}${prefix}/bin/uninstall-container.sh
}
