Settings the version in rke does not work

Hi all, can someone help me and find my mistake? Package rke: https://build.opensuse.org/package/show/home:ojkastl_buildservice/rke main.go allows setting the version: https://github.com/rancher/rke/blob/master/main.go#L18 I have added this flag to the %gobuild but still the version is reported as "dev": %gobuild -mod=vendor -ldflags="-X main.Version=%{version}" . The grafana package used a "manual build" without the macro to set this (this is where I stole the syntax from), but I thought handing over parameters like -mod=vendor worked with %gobuild in the meantime? Sadly enough, this is not mentioned at all in the Packaging Go documentation... https://en.opensuse.org/openSUSE:Packaging_Go But it states:
As I know, %goprep, %gofix, %gobuild, %goinstall, %gosrc, %gotest are macros that can not be quoted because they allow arguments. which sounds like %gobuild should except arguments?
Thanks in advance! Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

The 03/11/2021 19:57, Johannes Kastl wrote:
Hi all,
can someone help me and find my mistake?
Package rke: https://build.opensuse.org/package/show/home:ojkastl_buildservice/rke
main.go allows setting the version: https://github.com/rancher/rke/blob/master/main.go#L18
I have added this flag to the %gobuild but still the version is reported as "dev": %gobuild -mod=vendor -ldflags="-X main.Version=%{version}" .
The grafana package used a "manual build" without the macro to set this (this is where I stole the syntax from), but I thought handing over parameters like -mod=vendor worked with %gobuild in the meantime?
Sadly enough, this is not mentioned at all in the Packaging Go documentation... https://en.opensuse.org/openSUSE:Packaging_Go But it states:
As I know, %goprep, %gofix, %gobuild, %goinstall, %gosrc, %gotest are macros that can not be quoted because they allow arguments. which sounds like %gobuild should except arguments?
Hello Johannes, golang-packaging macros are in maintenance mode and designed for GOPATH. At this time I recommend calling go build and other commands directly, ensuring that -mod=vendor mode is active to prevent online access attempts. -- Jeff Kowalczyk Software Engineer, Go Developer Experience SUSE Linux Email jkowalczyk@suse.com Timezone US/Pacific http://suse.com --

The 03/11/2021 14:47, Jeff Kowalczyk wrote:
The 03/11/2021 19:57, Johannes Kastl wrote:
Hi all,
can someone help me and find my mistake?
Package rke: https://build.opensuse.org/package/show/home:ojkastl_buildservice/rke
main.go allows setting the version: https://github.com/rancher/rke/blob/master/main.go#L18
I have added this flag to the %gobuild but still the version is reported as "dev": %gobuild -mod=vendor -ldflags="-X main.Version=%{version}" .
The grafana package used a "manual build" without the macro to set this (this is where I stole the syntax from), but I thought handing over parameters like -mod=vendor worked with %gobuild in the meantime?
Sadly enough, this is not mentioned at all in the Packaging Go documentation... https://en.opensuse.org/openSUSE:Packaging_Go But it states:
As I know, %goprep, %gofix, %gobuild, %goinstall, %gosrc, %gotest are macros that can not be quoted because they allow arguments. which sounds like %gobuild should except arguments?
Hello Johannes,
golang-packaging macros are in maintenance mode and designed for GOPATH. At this time I recommend calling go build and other commands directly, ensuring that -mod=vendor mode is active to prevent online access attempts.
SR https://build.opensuse.org/request/show/878426 has been submitted to your branch with the suggested changes. The current golang-packaging macros provide no benefit when building with go modules. I am working on a deprecation and migration plan for a much smaller set of macros that add go modules conveniences. As you discovered, quoting of arguments to bash macros can a hurdle with typical go tools usage e.g. ldflags. -- Jeff Kowalczyk Software Engineer, Go Developer Experience SUSE Linux Email jkowalczyk@suse.com Timezone US/Pacific http://suse.com

Hi Jeff, thanks for your help! On 12.03.21 at 02:15 Jeff Kowalczyk wrote:
golang-packaging macros are in maintenance mode and designed for GOPATH.
That means? Sorry, but that sentence is just to deep for me with my limited go skills :-)
At this time I recommend calling go build and other commands directly, ensuring that -mod=vendor mode is active to prevent online access attempts.
OK, nice to know that. I was just following the wiki.
SR https://build.opensuse.org/request/show/878426 has been submitted to your branch with the suggested changes.
Thanks!
The current golang-packaging macros provide no benefit when building with go modules. I am working on a deprecation and migration plan for a much smaller set of macros that add go modules conveniences. As you discovered, quoting of arguments to bash macros can a hurdle with typical go tools usage e.g. ldflags.
Thank you for your work on that, Jeff! Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537

Hi Jeff, hi all, On 13.03.21 at 14:59 Johannes Kastl wrote:
SR https://build.opensuse.org/request/show/878426 has been submitted to your branch with the suggested changes.
It seems there is currently an issue with OBS, all my rebuilds are ignored and I find no change. Also, the packages was not rebuilt after the SR was accepted. But even when building locally with the modifications, the binary still reports the version as "dev". Any ideas? Kind Regards, Johannes -- Johannes Kastl Linux Consultant & Trainer Tel.: +49 (0) 151 2372 5802 Mail: kastl@b1-systems.de B1 Systems GmbH Osterfeldstraße 7 / 85088 Vohburg http://www.b1-systems.de GF: Ralph Dehner Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
participants (2)
-
Jeff Kowalczyk
-
Johannes Kastl