Imported Upstream version 2.3.0
[scm/test.git] / debian / rules
1 #!/usr/bin/make -f
2
3 export DH_OPTIONS
4 export GO15VENDOREXPERIMENT=1
5
6 #dh_golang doesn't do this for you
7 ifeq ($(DEB_HOST_ARCH), i386)
8         export GOARCH := 386
9 else ifeq ($(DEB_HOST_ARCH), amd64)
10         export GOARCH := amd64
11 else ifeq ($(DEB_HOST_ARCH), armhf)
12         export GOARCH := arm
13 else ifeq ($(DEB_HOST_ARCH), arm64)
14         export GOARCH := arm64
15 endif
16
17 BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
18 export DH_GOPKG := github.com/git-lfs/git-lfs
19 # DH_GOLANG_EXCLUDES typically incorporates vendor exclusions from script/test
20 export DH_GOLANG_EXCLUDES := test github.com/olekukonko/ts/* github.com/xeipuuv/* github.com/spf13/cobra/* github.com/kr/* github.com/pkg/errors
21 export 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
24 export DH_GOLANG_INSTALL_ALL := 1
25
26 %:
27         dh $@ --buildsystem=golang --with=golang
28
29 override_dh_clean:
30         rm -f debian/debhelper.log
31         rm -rf man
32         dh_clean
33
34 override_dh_auto_build:
35         dh_auto_build
36         #dh_golang doesn't do anything here in deb 8, and it's needed in both
37         if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
38                 cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
39                 cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
40         fi
41         rm $(BUILD_DIR)/bin/script
42         rm $(BUILD_DIR)/bin/man
43         ./script/man
44
45 override_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
49 override_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
54 override_dh_auto_install:
55         mkdir -p debian/git-lfs/usr/bin
56         cp $(BUILD_DIR)/bin/git-lfs debian/git-lfs/usr/bin/
57
58 override_dh_auto_test:
59         ln -s ../../../../../../commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/commands/repos
60         ln -s ../../../../bin $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/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/commands/repos $(BUILD_DIR)/src/github.com/git-lfs/git-lfs/bin