File: rules

package info (click to toggle)
mongo-tools 3.2.11-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,612 kB
  • ctags: 10,571
  • sloc: python: 5,428; ansic: 589; sh: 397; makefile: 62; lisp: 19
file content (68 lines) | stat: -rwxr-xr-x 2,252 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1

export DH_GOPKG := github.com/mongodb/mongo-tools

TOOLS = bsondump mongodump mongoexport mongofiles \
        mongoimport mongooplog mongorestore mongostat mongotop

# Use the following vendorized deps instead of system copies
VENDORIZED_DEPS = github.com/spacemonkeygo/spacelog \
                  github.com/spacemonkeygo/openssl \
		  github.com/jessevdk/go-flags \
		  github.com/howeyc/gopass \
		  github.com/3rf/mongo-lint \
                  gopkg.in/mgo.v2

export GOPATH = $(CURDIR)/_build
export GOBIN = $(CURDIR)/debian/bin

%:
	dh $@ --with=golang --builddirectory=_build --buildsystem=golang

override_dh_auto_configure:
	# First create the base for all vendorized deps. This is needed to
	# avoid having dh-golang symlink a whole hierarchy (e.g. github.com)
	# under which we have vendorized deps.
	for dep in $(VENDORIZED_DEPS); do \
		mkdir -p $(CURDIR)/_build/src/$$(dirname $$dep); \
	done
	# Let dh-golang symlink all libraries from the system path
	dh_auto_configure --buildsystem=golang
	# Finally replace any symlinks to system copies with the vendorized versions
	for dep in $(VENDORIZED_DEPS); do \
		rm -f $(CURDIR)/_build/src/$$dep; \
		ln -r -s $(CURDIR)/vendor/src/$$dep $(CURDIR)/_build/src/$$dep; \
	done

override_dh_auto_build:
	for tool in $(TOOLS); do \
		go install -v -tags="ssl sasl" -ldflags -extldflags=-Wl,-z,now,-z,relro $$tool/main/$$tool.go; \
	done

override_dh_auto_test:
	# Run only the unit tests for each tool (+ common)
	set -e; for tool in $(TOOLS) common; do \
		cd $(CURDIR)/$$tool && go test -v -test.types=unit; \
	done

override_dh_auto_install:
	# Do not install any Go source code

override_dh_auto_clean:
	rm -rf debian/bin
	rm -rf _build
	find $(CURDIR)/vendor -type f -name '*.a' -exec rm -rf {} \;
	dh_auto_clean

override_dh_golang:
	# We need to run dh_golang once for every tool
	for tool in $(TOOLS); do \
		DH_GOLANG_BUILDPKG=github.com/mongodb/mongo-tools/$$tool dh_golang -O--builddirectory=_build; \
	done

.PHONY: override_dh_auto_build override_dh_auto_install \
	override_dh_auto_clean override_dh_golang \
	override_dh_auto_test