mock icon indicating copy to clipboard operation
mock copied to clipboard

Support for Go external dependencies

Open istiak101 opened this issue 2 years ago • 4 comments

Is it possible to add support for Go dependencies?

https://rpm-software-management.github.io/mock/Feature-external-deps

[  1%] Built target global_target
make[2]: *** Deleting file 'crypto_test_data.cc'
go: golang.org/x/[email protected]: Get "https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20210513164829-c07d793c2f9a.mod": dial tcp: lookup proxy.golang.org on [::1]:53: read udp [::1]:44672->[::1]:53: read: connection refused
go: golang.org/x/[email protected]: Get "https://proxy.golang.org/golang.org/x/crypto/@v/v0.0.0-20210513164829-c07d793c2f9a.mod": dial tcp: lookup proxy.golang.org on [::1]:53: read udp [::1]:44672->[::1]:53: read: connection refused
make[2]: *** [CMakeFiles/crypto_test_data.dir/build.make:251: crypto_test_data.cc] Error 1
[  1%] Generating crypto_test_data.cc

I am trying to build BoringSSL and without --enable-network the build will fail. I don't want to enable network for any build.

istiak101 avatar Jun 17 '22 01:06 istiak101

Yes, it is possible. However, neither of us is fluent in go. Therefore I need an expert who will tell us what is the best way to install go dependencies? On Fedora and RHEL. And help to test the pull request.

xsuchy avatar Jun 17 '22 04:06 xsuchy

Hmm, this seems to be right way https://developer.fedoraproject.org/tech/languages/go/go-packages.html

xsuchy avatar Jun 17 '22 04:06 xsuchy

Hmm, this seems to be right way https://developer.fedoraproject.org/tech/languages/go/go-packages.html

I made a pull request to the repository to make that documentation up-to-date.

https://github.com/developer-portal/content/pull/440

alexsaezm avatar Jun 17 '22 10:06 alexsaezm

Also spent a day for a debug why go build fails "in docker in mock in chroot". I was thinking it was a some hardcoded ipv6 problems, cause ::1 in log

docker golang proxy.golang.org on [::1]:53: dial udp [::1]:53: connect: cannot assign requested address

Then changed GOPROXY env, to direct and find out the network in mock chroot is missing 🙂

+ umask 022
+ cd /builddir/build/BUILD
+ cd smartctl_exporter-0.9.1
+ export GOPROXY=direct
+ GOPROXY=direct
+ export GOPATH=/builddir/build/BUILD/gopath
+ GOPATH=/builddir/build/BUILD/gopath
+ export GOBIN=/builddir/build/BUILD/gopath/bin
+ GOBIN=/builddir/build/BUILD/gopath/bin
+ cd /builddir/build/BUILD/gopath/src/github.com/prometheus-community/smartctl_exporter
+ GOOS=linux
+ go build
go: downloading github.com/prometheus/client_golang v1.13.1
go: downloading github.com/go-kit/log v0.2.1
go: downloading github.com/prometheus/common v0.37.0
go: downloading github.com/prometheus/exporter-toolkit v0.8.1
go: downloading github.com/tidwall/gjson v1.14.3
go: downloading gopkg.in/alecthomas/kingpin.v2 v2.2.6
main.go:21:2: reading github.com/go-kit/log/go.mod at revision v0.2.1: git ls-remote -q origin in /builddir/build/BUILD/gopath/pkg/mod/cache/vcs/1d9f54c61284fbaef5d8f72908c527abe27fa06148d686c887c372c251cb48e0: exit status 128:
	fatal: unable to access 'https://github.com/go-kit/log/': Could not resolve host: github.com
main.go:22:2: reading github.com/go-kit/log/go.mod at revision v0.2.1: git ls-remote -q origin in /builddir/build/BUILD/gopath/pkg/mod/cache/vcs/1d9f54c61284fbaef5d8f72908c527abe27fa06148d686c887c372c251cb48e0: exit status 128:
	fatal: unable to access 'https://github.com/go-kit/log/': Could not resolve host: github.com
main.go:23:2: reading github.com/prometheus/client_golang/go.mod at revision v1.13.1: git ls-remote -q origin in /builddir/build/BUILD/gopath/pkg/mod/cache/vcs/6ffa6057942360db9e438bbc1bc03e3efd3ae1d41df4abeb5328ef376a815bfa: exit status 128:
	fatal: unable to access 'https://github.com/prometheus/client_golang/': Could not resolve host: github.com

Fortunately, suggestion from @istiak101 works for me: --enable-network option resolves the impossibility of building golang application

k0ste avatar Feb 09 '23 03:02 k0ste