Re: Looking for help with kustomize port (Go)
Nils Breunese wrote: > Thanks. I know actually about this mechanism, but I guess I should have > specified that I don’t know how to find out what the exact names of the flags > are that I should set. Is there an easy way to find out? Should I go and read > the source code? Or ask the developers? Ok, I finally figured it out myself. The problem wasn’t the ldflags, but another build argument. I created a new pull request for kustomize now: https://github.com/macports/macports-ports/pull/7069 Nils.
Re: Looking for help with kustomize port (Go)
Aaron Madlon-Kay wrote: > 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\" Thanks. I know actually about this mechanism, but I guess I should have specified that I don’t know how to find out what the exact names of the flags are that I should set. Is there an easy way to find out? Should I go and read the source code? Or ask the developers? Nils.
Re: Looking for help with kustomize port (Go)
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 wrote: > > Nils Breunese wrote: > > >> Op 28 apr. 2020 om 06:30 heeft Ryan Schmidt 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
Re: Looking for help with kustomize port (Go)
Nils Breunese wrote: >> Op 28 apr. 2020 om 06:30 heeft Ryan Schmidt 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
Re: Looking for help with kustomize port (Go)
> Op 28 apr. 2020 om 06:30 heeft Ryan Schmidt 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. Nils.
Re: Looking for help with kustomize port (Go)
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
Looking for help with kustomize port (Go)
Hello, I was looking for kustomize [0] in MacPorts and when I didn’t find it, I decided to try to create a port for it myself. Although I already maintain a couple of other Go-based ports I couldn’t get this one to work, so I decided to use the pre-built binary [1] for now. I submitted this as a pull request [2] and got the feedback that a port that builds from source is preferred. The main issue I have when trying a Portfile that builds from source is that the build instructions [4] say to go into the kustomize subdir in the archive and run 'go install .’. I couldn’t figure out how to make MacPorts do the equivalent of ‘cd kustomize’ after unpacking the archive and I also don’t think ‘go install .’ is the command that should be run, because that tries to install the file into ~/go/bin. Maybe someone who is a bit more familiar with Go could take a look at my initial attempt to build from source and modify it to work? I would be fine with maintaining it for updates afterwards. Nils. [0] https://kustomize.io [1] https://github.com/breun/macports-ports/blob/kustomize-3.5.4/devel/kustomize/Portfile [2] https://github.com/macports/macports-ports/pull/6875 [3] https://github.com/breun/macports-ports/blob/kustomize-from-source/devel/kustomize/Portfile [4] https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md#build-the-kustomize-cli-from-local-source