# -*- 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.19.1 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  55f5cd17b392c7fac2c3f21feb0f1fc5c0e8c647 \
                    sha256  677bf03c19d684dc5bef47e981ec1b4564482cbf5f9b190cb48e110183fd6d25 \
                    size    257266

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
}
