1#!/usr/bin/make -f
2
3export DH_OPTIONS
4
5#dh_golang doesn't do this for you
6ifeq ($(DEB_HOST_ARCH), i386)
7	export GOARCH := 386
8else ifeq ($(DEB_HOST_ARCH), amd64)
9	export GOARCH := amd64
10else ifeq ($(DEB_HOST_ARCH), armhf)
11	export GOARCH := arm
12else ifeq ($(DEB_HOST_ARCH), arm64)
13	export GOARCH := arm64
14endif
15
16BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
17export DH_GOPKG := github.com/git-lfs/git-lfs/v3
18# DH_GOLANG_EXCLUDES typically incorporates vendor exclusions
19export 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/*
20export DH_GOLANG_GO_GENERATE := 1
21export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
22
23# by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
24export DH_GOLANG_INSTALL_ALL := 1
25
26%:
27	mkdir -p /tmp/gocache
28	GO111MODULE=on GOFLAGS=-mod=vendor GOCACHE=/tmp/gocache dh $@ --buildsystem=golang --with=golang
29
30override_dh_clean:
31	rm -f debian/debhelper.log
32	rm -rf man
33	dh_clean
34
35override_dh_auto_build:
36	dh_auto_build
37	#dh_golang doesn't do anything here in deb 8, and it's needed in both
38	if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
39		cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
40	fi
41	rm $(BUILD_DIR)/bin/script
42	rm $(BUILD_DIR)/bin/man
43	make man
44
45override_dh_strip:
46	# strip disabled as golang upstream doesn't support it and it makes go
47	# crash. See https://launchpad.net/bugs/1200255.
48
49override_dh_golang:
50	# The dh_golang is used to add the Built-using field to the deb.  This is only for reference.
51	# As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
52	# dh_golang errors out because the go compiler used was not installed via a package.  Therefore the step is skipped
53
54override_dh_auto_install:
55	mkdir -p debian/git-lfs/usr/bin
56	cp $(BUILD_DIR)/bin/git-lfs debian/git-lfs/usr/bin/
57
58override_dh_auto_test:
59	ln -s ../../../../../../../commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/v3/commands/repos
60	ln -s ../../../../../bin $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/v3/bin
61	#dh_golang uses the wrong dir to test on. This tricks everything into being happy
62	DEB_BUILD_GNU_TYPE=$(DEB_HOST_GNU_TYPE) dh_auto_test
63	rm $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/v3/commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/v3/bin
64