# -*- 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 git_commit      "0b142f65e139525881b6a343bc56d8d98e5a1f90"

go.setup            github.com/mongodb/mongo-tools 100.17.0
revision            0
checksums           rmd160  82b1c13e856c73ddd6e5915142c85ba2a66bc1c7 \
                    sha256  27d00697a7715443912ce0c76f11e760cfec450a885ac18b499412d4097eeab2 \
                    size    7622264

categories          devel
maintainers         {ryandesign @ryandesign} openmaintainer
license             Apache-2

# On older OS versions, the go port uses an older version of go with which this
# port is not compatible.
platforms           {darwin >= 17}

description         utilities for working with mongodb databases: bsondump, \
                    mongoimport, mongoexport, mongodump, mongorestore, \
                    mongostat, mongofiles, mongooplog, mongotop

long_description    mongo-tools is a collection of utilities for working with \
                    mongodb databases: \
                    \
                    \n\n* bsondump: display BSON files in a human-readable format \
                    \n* mongoimport: Convert data from JSON, TSV or CSV and insert them into a collection \
                    \n* mongoexport: Write an existing collection to CSV or JSON format \
                    \n* mongodump: Dump MongoDB backups to disk in .BSON format \
                    \n* mongorestore: Restore MongoDB backups in .BSON format to a live database \
                    \n* mongostat: Monitor live MongoDB servers, replica sets, or sharded clusters \
                    \n* mongofiles: Read, write, delete, or update files in GridFS \
                    \n* mongotop: Monitor read/write activity on a mongo server

extract.rename      no
dist_subdir         ${name}

patchfiles          deployment_target.patch \
                    version.patch

post-patch {
    reinplace -W ${worksrcpath} "s|@GIT_COMMIT@|${git_commit}|g" \
        buildscript/build.go \
        release/version/version.go
    reinplace -W ${worksrcpath} "s|@VERSION@|${version}|g" \
        release/version/version.go
}

build.cmd           ./make
build.target        build

destroot {
    copy {*}[glob ${worksrcpath}/bin/*] ${destroot}${prefix}/bin/

    set docdir ${prefix}/share/doc/${subport}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        CONTRIBUTING.md \
        LICENSE.md \
        README.md \
        ${destroot}${docdir}
}
