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

go.setup            github.com/golang-migrate/migrate 4.18.2 v
name                go-migrate
revision            0

description         CLI for Go library performing database migrations.

long_description    {*}${description} Migrate reads migrations from sources \
                    and applies them in the correct order to the database. \
                    Sources include the filesystem, go-bindata, GitHub \
                    repositories, Gitlab repositories, AWS S3 & Google Cloud \
                    Storage.

categories          devel databases
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  6bc5ce44c328bdb22d7d28a6ef54c4a419052164 \
                    sha256  a7bd48cd45dc2546f23f01750486fbba5b70b723500a881bb56221b11533a6f0 \
                    size    214859

build.cmd           make
build.pre_args      VERSION=${version}
build.args          build-cli

# 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
go.offline_build no

post-extract {
    # Comment out builds for non-Darwin platforms
    reinplace -E "s/(\s*)(.*GOOS=\[^d\]\[^a\]\[^r\]\[^w\])/\\1#\\2/g" Makefile
    # Comment out build steps that create tarballs
    reinplace -E "s/(\s*)(.*cli\\/build.*tar czf)/\\1#\\2/g" Makefile
    # Comment out any build steps involved with generating the SHA sums text file.
    reinplace -E "s/(\s*)(.*sha256sum)/\\1#\\2/g" Makefile
}

destroot {
    xinstall -m 0755 \
        ${worksrcpath}/cli/build/migrate.darwin-amd64 \
        ${destroot}${prefix}/bin/migrate
}
