git-lfs/debian/rules
brian m. carlson 20b25b975f
debian/rules: update for Go 1.12
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.
2019-07-15 16:40:31 +00:00

64 lines
2.4 KiB
Makefile
Executable File

#!/usr/bin/make -f
export DH_OPTIONS
#dh_golang doesn't do this for you
ifeq ($(DEB_HOST_ARCH), i386)
export GOARCH := 386
else ifeq ($(DEB_HOST_ARCH), amd64)
export GOARCH := amd64
else ifeq ($(DEB_HOST_ARCH), armhf)
export GOARCH := arm
else ifeq ($(DEB_HOST_ARCH), arm64)
export GOARCH := arm64
endif
BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
export DH_GOPKG := github.com/git-lfs/git-lfs
# DH_GOLANG_EXCLUDES typically incorporates vendor exclusions
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/*
export DH_GOLANG_GO_GENERATE := 1
export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
# by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
export DH_GOLANG_INSTALL_ALL := 1
%:
mkdir -p /tmp/gocache
GO111MODULE=on GOFLAGS=-mod=vendor GOCACHE=/tmp/gocache dh $@ --buildsystem=golang --with=golang
override_dh_clean:
rm -f debian/debhelper.log
rm -rf man
dh_clean
override_dh_auto_build:
dh_auto_build
#dh_golang doesn't do anything here in deb 8, and it's needed in both
if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
fi
rm $(BUILD_DIR)/bin/script
rm $(BUILD_DIR)/bin/man
make man
override_dh_strip:
# strip disabled as golang upstream doesn't support it and it makes go
# crash. See https://launchpad.net/bugs/1200255.
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
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:
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
#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
rm $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/bin