2015-05-15 15:27:21 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
|
|
|
export DH_OPTIONS
|
all: use Go Modules instead of Glide
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>
2018-08-28 20:53:57 +00:00
|
|
|
export GO111MODULE=on
|
2015-05-15 15:27:21 +00:00
|
|
|
|
2015-07-26 15:26:57 +00:00
|
|
|
#dh_golang doesn't do this for you
|
2015-07-26 17:02:57 +00:00
|
|
|
ifeq ($(DEB_HOST_ARCH), i386)
|
2015-07-26 15:26:57 +00:00
|
|
|
export GOARCH := 386
|
2015-07-26 17:02:57 +00:00
|
|
|
else ifeq ($(DEB_HOST_ARCH), amd64)
|
2015-07-26 15:26:57 +00:00
|
|
|
export GOARCH := amd64
|
2017-03-25 22:11:06 +00:00
|
|
|
else ifeq ($(DEB_HOST_ARCH), armhf)
|
|
|
|
export GOARCH := arm
|
|
|
|
else ifeq ($(DEB_HOST_ARCH), arm64)
|
|
|
|
export GOARCH := arm64
|
2015-07-26 15:26:57 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
|
2016-11-15 17:07:11 +00:00
|
|
|
export DH_GOPKG := github.com/git-lfs/git-lfs
|
2018-07-16 21:25:54 +00:00
|
|
|
# DH_GOLANG_EXCLUDES typically incorporates vendor exclusions
|
2018-02-15 22:44:56 +00:00
|
|
|
export DH_GOLANG_EXCLUDES := test github.com/olekukonko/ts/* github.com/xeipuuv/* github.com/spf13/cobra/* github.com/kr/* github.com/pkg/errors github.com/alexbrainman/sspi/*
|
2015-05-15 15:27:21 +00:00
|
|
|
export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
|
2016-07-27 13:49:23 +00:00
|
|
|
|
2016-06-05 19:08:23 +00:00
|
|
|
# by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
|
|
|
|
export DH_GOLANG_INSTALL_ALL := 1
|
2015-05-15 15:27:21 +00:00
|
|
|
|
|
|
|
%:
|
|
|
|
dh $@ --buildsystem=golang --with=golang
|
|
|
|
|
|
|
|
override_dh_clean:
|
|
|
|
rm -f debian/debhelper.log
|
|
|
|
rm -rf man
|
|
|
|
dh_clean
|
|
|
|
|
|
|
|
override_dh_auto_build:
|
2018-06-22 22:49:52 +00:00
|
|
|
cd ${BUILD_DIR}/src/github.com/git-lfs/git-lfs && go generate ./commands
|
2015-05-15 15:27:21 +00:00
|
|
|
dh_auto_build
|
2016-05-23 21:03:25 +00:00
|
|
|
#dh_golang doesn't do anything here in deb 8, and it's needed in both
|
2015-07-26 17:02:57 +00:00
|
|
|
if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
|
|
|
|
cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
|
|
|
|
cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
|
2015-07-26 15:26:57 +00:00
|
|
|
fi
|
2015-05-15 15:27:21 +00:00
|
|
|
rm $(BUILD_DIR)/bin/script
|
2016-02-25 05:04:55 +00:00
|
|
|
rm $(BUILD_DIR)/bin/man
|
2018-07-19 19:03:54 +00:00
|
|
|
make man
|
2015-05-15 15:27:21 +00:00
|
|
|
|
|
|
|
override_dh_strip:
|
|
|
|
# strip disabled as golang upstream doesn't support it and it makes go
|
|
|
|
# crash. See https://launchpad.net/bugs/1200255.
|
|
|
|
|
2017-05-07 23:34:58 +00:00
|
|
|
override_dh_golang:
|
|
|
|
# The dh_golang is used to add the Built-using field to the deb. This is only for reference.
|
|
|
|
# As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
|
|
|
|
# dh_golang errors out because the go compiler used was not installed via a package. Therefore the step is skipped
|
|
|
|
|
2015-05-15 15:27:21 +00:00
|
|
|
override_dh_auto_install:
|
|
|
|
mkdir -p debian/git-lfs/usr/bin
|
|
|
|
cp $(BUILD_DIR)/bin/git-lfs debian/git-lfs/usr/bin/
|
|
|
|
|
|
|
|
override_dh_auto_test:
|
2016-11-15 17:07:11 +00:00
|
|
|
ln -s ../../../../../../commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/commands/repos
|
|
|
|
ln -s ../../../../bin $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/bin
|
2015-07-26 15:26:57 +00:00
|
|
|
#dh_golang uses the wrong dir to test on. This tricks everything into being happy
|
|
|
|
DEB_BUILD_GNU_TYPE=$(DEB_HOST_GNU_TYPE) dh_auto_test
|
2016-11-15 17:07:11 +00:00
|
|
|
rm $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/bin
|