dh_golang wants to turn off the module cache because attempting to use
it breaks sbuild, a component of Debian's package build system. However,
as of Go 1.12, the package build cache is required. Create a temporary
directory for the cache and override the environment variable so that we
can build with Go 1.12. Pass the environment variables to the dh command
directly, since export only affects submakes, not individual commands.
In addition, stop copying the pkg directory into the archive, because it
is no longer produced and attempting to copy nonexisting files causes
the build to fail.
This fixes#2013. For some reason I could only reproduce the issue from
within the docker builder, not when running outside of docker.
Regardless, this appears to fix the problem and is a generally cleaner
solution anyway that will continue to work if any other generate
commands are added to git-lfs.
Since we are now building on Go 1.11 (as of 074a2d4f (all: use Go 1.11
in CI, 2018-08-28)) and Go 1.11 supports Go Modules [1], let's stop
using Glide, and begin using Go Modules.
This involves a few things:
* Teach the Makefile how to build go.sum files instead of glide.lock
files.
* Teach continuous integration services to build Git LFS in a
non-$GOPATH environment, since (without setting GO111MODULE=on
explicitly, which we choose not to do), this will break compiling
Git LFS, because Go 1.11 will ignore modules present in a Go
checkout beneath $GOPATH.
* In order to do the above, let's also make sure that we are
un-setting $GOCACHE in the environment, as this causes Go to work
without modules support [2].
* Because we're no longer building in a `$GOPATH`-based location,
let's instruct the CircleCI base image to archive the new location,
too.
* Similarly, teach the RPM spec to build in a non-$GOPATH location.
* By contrast, since we use dh_golang to build git-lfs binaries on
Debian, let's wait until the upstream dh_golang package is released
with support for Go 1.11 module support explicitly. Therefore, force
GO111MODULE to be on so that we can build a copy of Git LFS whose
checkout is within a $GOPATH.
Although the go.mod versions match the glide.yaml ones, the diff
attached is large because Go Modules do not vendor `_test.go` files,
whereas Glide does.
[1]: https://golang.org/doc/go1.11#modules
[2]: `GOCACHE=on` will be deprecated in Go 1.12, so this change makes
sense for that reason, too.
Co-authored-by: brian m. carlson <bk2204@github.com>
This option was introduced historically in order to build Go packages in
Go 1.5 with vendored dependencies in the vendor tree.
GO15VENDOREXPERIMENT has long since been deprecated, and is no longer
required in modern versions of Go in order to instruct to the 'go' tool
to look in this directory.
Co-authored-by: brian m. carlson <bk2204@github.com>
The deb packages don't currently run `go generate` when building which
means commands like `git-lfs help` don't work properly. This changes
the packaging script to run it.
Fixes#3043
This commit skips the `dh_golang` step which is used to add the
Built-using field to the resulting deb. The field is only used to track
the version of go used to build a package so omitting it shouldn't be a
problem. In the commit at https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
the dh-golang maintainers changed the logic used to determine the
version of go used to check the installed package. This fails because
git-lfs gets built using a manually installed version of go.