Looking for help with kustomize port (Go)

Aaron Madlon-Kay amake at macports.org
Sun May 10 23:22:00 UTC 2020


It's common in Go to specify version strings as linker flags. Grep the
ports tree like so to see existing ports that successfully set these
flags. It's not uncommon to use the string 'unknown' for e.g. the git
commit when it is redundant or not readily available.

% grep -R -- "-ldflags '-X" .
./devel/git-sizer/Portfile:build.args              -ldflags '-X
main.BuildVersion=${version}'
./devel/shfmt/Portfile:build.pre_args      -ldflags '-X main.version=${version}'
./security/mkcert/Portfile:build.args          -ldflags '-X
main.Version=${version}'
./www/minio-mc/Portfile:      -ldflags '-X ${goproj}/cmd.Version=${relversion} \
./www/minio/Portfile:      -ldflags '-X ${goproj}/cmd.Version=${relversion} \
Aarons-MBP:macports-ports amake% grep -R -- "-ldflags.*-X" .
./devel/git-sizer/Portfile:build.args              -ldflags '-X
main.BuildVersion=${version}'
./devel/shfmt/Portfile:build.pre_args      -ldflags '-X main.version=${version}'
./security/mkcert/Portfile:build.args          -ldflags '-X
main.Version=${version}'
./www/minio-mc/Portfile:      -ldflags '-X ${goproj}/cmd.Version=${relversion} \
./www/minio/Portfile:      -ldflags '-X ${goproj}/cmd.Version=${relversion} \
./www/caddy/Portfile:build.args          -ldflags \"-X
${go.package}/${name}/caddymain.gitTag=v${version}\"
./sysutils/go2port/Portfile:build.args          -ldflags "'-X
main.version=${version}'"
./sysutils/go2port/Portfile~:build.args          -ldflags "'-X
main.version=${version}'"
./sysutils/chezmoi/Portfile:build.args          -ldflags \"-X
main.version=${version} -X main.builtBy=macports\"

-Aaron

On Mon, May 11, 2020 at 12:09 AM Nils Breunese <nils at breun.nl> wrote:
>
> Nils Breunese <nils at breun.nl> wrote:
>
> >> Op 28 apr. 2020 om 06:30 heeft Ryan Schmidt <ryandesign at macports.org> het volgende geschreven:
> >>
> >>> On Apr 27, 2020, at 09:46, Nils Breunese wrote:
> >>>
> >>> I couldn’t figure out how to make MacPorts do the equivalent of ‘cd kustomize’ after unpacking the archive
> >>
> >> Perhaps you want:
> >>
> >> build.dir    ${worksrcpath}/kustomize
> >
> > Thanks, that was indeed also suggested to me via GitHub and turned out to work. I was previously trying to override worksrcpath itself (I remember going through the Docs for the build.* settings, but managed to miss this one apparently). I’ve got some Go-specific ldflags left to fix, but at least it builds and runs now.
>
> I have a working Portfile for Kustomize [0] at https://github.com/breun/macports-ports/blob/kustomize-from-source/devel/kustomize/Portfile which builds and installs a working `kustomize` binary, but I believe I still need to set the correct flags to correctly set the version, because currently the output of 'kustomize version’ is this:
>
> ----
> % kustomize version
> Version: {KustomizeVersion:unknown GitCommit:$Format:%H$ BuildDate:1970-01-01T00:00:00Z GoOs:darwin GoArch:amd64}
> ----
>
> I’d like at least KustomizeVersion to have a value, BuildDate would be nice as well. GitCommit might not be doable when building from a source tarball. I tried adding the flags that are also set by the kustomize Homebrew formula [1], but they don't seem to have any effect.
>
> Anyone familiar enough with Go builds to tell me how to fix this?
>
> Thanks, Nils.
>
> [0] https://github.com/kubernetes-sigs/kustomize
> [1] https://github.com/Homebrew/homebrew-core/blob/master/Formula/kustomize.rb#L23


More information about the macports-dev mailing list