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

set version         0.20.0
revision            0

checksums           rmd160  057d1ee189055af41b1e02c43ebaaef9194bfd54 \
                    sha256  fbe469b4b3d70a171a94cc86e4aa32b4e3ccef65ba2440421d3bd3ffeff66eb2 \
                    size    15477176

# the last IPFS which can be build 1.17.13
if {${os.platform} eq "darwin" && ${os.major} <= 16} {
    version         0.15.0
    revision        0
    epoch           1

    checksums       rmd160  b946e1023c492cb06e50cb69ed43123e414ac9ac \
                    sha256  e0666fb11ec4164f5a9bedfc4cd3e7b1f85ca7f18e27c44ed667022898bb9f66 \
                    size    13319349
}

go.setup            github.com/ipfs/kubo ${version} v
go.author           go
go.project          ipfs
name                ipfs

description         Global, versioned, peer-to-peer filesystem

long_description    IPFS is a global, versioned, peer-to-peer filesystem. \
                    It combines good ideas from Git, BitTorrent, Kademlia, \
                    SFS, and the Web. It is like a single bittorrent swarm, \
                    exchanging git objects. IPFS provides an interface as \
                    simple as the HTTP web, but with permanence built in.

categories          net
installs_libs       no
license             MIT
maintainers         {ogsite.net:sirn @sirn} \
                    {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

set tagged_version  ${github.tag_prefix}${version}
set ipfs_dist_url   https://dist.ipfs.io/go-ipfs/
homepage            https://ipfs.io
master_sites        ${ipfs_dist_url}${tagged_version}/
distname            go-ipfs-source
dist_subdir         ${name}/${version}

build.cmd           make
build.target        build

# FIXME: This port currently can't be built without allowing go mod to fetch
# dependencies during the build phase. See
# https://trac.macports.org/ticket/61192
build.env-delete    GOPROXY=off GO111MODULE=off

extract.dir         ${workpath}/${go.author}-${go.project}-${version}

destroot {
    xinstall -m 0755 ${worksrcpath}/cmd/ipfs/ipfs ${destroot}${prefix}/bin
    xinstall -d ${destroot}${prefix}/share/examples/${name}
    xinstall -W ${worksrcpath}/misc/launchd io.ipfs.ipfs-daemon.plist ${destroot}${prefix}/share/examples/${name}/ipfs.plist
    reinplace "s|{{IPFS_BIN}}|${prefix}/bin/ipfs|g" ${destroot}${prefix}/share/examples/${name}/ipfs.plist
    reinplace "s|{{IPFS_PATH}}|/Users/USERNAME/.ipfs|g" ${destroot}${prefix}/share/examples/${name}/ipfs.plist
}

notes-append \
    "IPFS provides an example launchd plist. To use it:" \
    "1. Copy ${prefix}/share/examples/${name}/ipfs.plist to ~/Library/LaunchAgents" \
    "2. Edit ipfs.plist by replacing USERNAME with your actual username" \
    "3. Log out and in again, or run: launchctl load ~/Library/LaunchAgents/ipfs.plist"

livecheck.url       ${ipfs_dist_url}
livecheck.regex     {go-ipfs/v([0-9.]+)}
livecheck.type      regex
