# -*- 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 1.1.0
github.tarball_from archive

revision            0
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  5c954dba9d45e62618f13ce0162f25761ae81837 \
                    sha256  beb7f2536d714de6863a056b677a2b51aa498bb7caec6011cfb01c0c95bcbe8c \
                    size    1001406

# 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
    # Remove the unnecessary update script
    file delete -force ${destroot}${prefix}/bin/update-container.sh
}
