gofed / go-macros

Rpm mechanics for Go packaging
4 stars 7 forks source link

macros.go-rpm: Support %gobuildroot without global %goipath #59

Closed dm0- closed 5 years ago

dm0- commented 6 years ago

For some complicated packages (such as Docker), there can be multiple Go buildroots in the same package. In this case, it would be helpful to share the %gobuildroot code, but it currently expects to have a global %goipath definition due to the line

goipath="${goipath:-%{goipath}}"

which expands to a bash expression ${goipath:-%{goipath} when %goipath is undefined. This is due to the shell not understanding nested braces, so there is an extra } on the symlink that breaks paths.

With this change, the undefined %goipath macro is dropped during expansion so the shell expression is evaluated as expected. This allows multiple %gobuildroot uses in subshells with -i.

nim-nim commented 5 years ago

Hi David,

FYI the go macros devel branch I'm currently working on is deprecating %gobuildroot

It builds on the redhat-rpm-config forge macro rework that landed this week in rawhide to allow one to specify as many import path sources as one wishes in his spec.

So, for every Go import path you need to use in a spec, you have an archive source, and every source is unpacked then symlinked to the corresponding point in a single import path tree in %prep

That makes is much easier to use in %build afterwards as you can just point GOPATH to this tree and things just work. It removed many workarounds from the current Go macros

Will that approach work with your use case?

You can take a peek at the current state in https://copr.fedorainfracloud.org/coprs/nim/go-macros-3/builds/

I've not announced it yet widely as part of the new stuff depends on the mock pm request plugin, which is not deployed infra-side yet (but I have hopes)

dm0- commented 5 years ago

Sorry for losing track of this. I can work without this PR until the new configuration is available, so I'll close it, thanks.