File: rules

package info (click to toggle)
libmongodb-perl 1.4.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,004 kB
  • ctags: 2,932
  • sloc: perl: 12,511; ansic: 9,566; makefile: 22
file content (33 lines) | stat: -rwxr-xr-x 1,210 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
#!/usr/bin/make -f

BUILDHOME = $(CURDIR)/debian/build
PIDFILE = $(BUILDHOME)/mongod.pid
PORT := $(shell /bin/netstat -want | perl -w -e 'while (<>) { $$used{$$1}=1 if /127\.0\.0\.1:(\d+)/;}; $$port = 12345; while ($$used{$$port}) { $$port++ }; print "$$port\n";')

# pass PORT to test through MONGOD variable in t/lib/MongoDBTest.pm
MONGOD = localhost:$(PORT)

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

%:
	dh $@

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	mkdir -p $(BUILDHOME)
	# mongod is required during build only on i386 amd64
	# "until netstat" command wait for mongod to be listening on PORT
	if [ -x /usr/bin/mongod ]; then \
	  mongod --dbpath $(BUILDHOME) --noprealloc --bind_ip 127.0.0.1 --nojournal --port $(PORT) --quiet --fork --logpath $(BUILDHOME)/mongod.log --pidfilepath $(PIDFILE); \
	  i=10; \
	  until (/bin/netstat -want | grep -q 127.0.0.1:$(PORT) ) || [ $$i = 0 ]; do sleep 1; i=$$((i-1)); echo waiting for mongod; done \
	fi
	export MONGOD=localhost:$(PORT);\
	dh_auto_test
	# The server process might not have actually started
	[ ! -s $(PIDFILE) ] || /bin/kill `cat $(PIDFILE)` || true
endif

override_dh_clean:
	dh_clean
	rm -rf $(BUILDHOME)