~chad.smith/landscape-client/mocker-to-mock-package-reporter-2

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
PYDOCTOR ?= pydoctor
TXT2MAN ?= txt2man 
PYTHON ?= python
TRIAL_ARGS ?= 
TEST_COMMAND = trial --unclean-warnings $(TRIAL_ARGS) landscape
UBUNTU_RELEASE := $(shell lsb_release -cs)
# version in the code is authoritative
# Use := here, not =, it's really important, otherwise UPSTREAM_VERSION
# will be updated behind your back with the current result of that
# command everytime it is mentioned/used.
UPSTREAM_VERSION := $(shell python -c "from landscape import UPSTREAM_VERSION; print UPSTREAM_VERSION")
CHANGELOG_VERSION := $(shell dpkg-parsechangelog | grep ^Version | cut -f 2 -d " " | cut -f 1 -d '-')
BZR_REVNO := $(shell bzr revno)
ifeq (+bzr,$(findstring +bzr,$(UPSTREAM_VERSION)))
TARBALL_VERSION := $(UPSTREAM_VERSION)
else
TARBALL_VERSION := $(UPSTREAM_VERSION)+bzr$(BZR_REVNO)
endif

all: build

build:
	$(PYTHON) setup.py build_ext -i

check: build
	@if [ -z "$$DBUS_SESSION_BUS_ADDRESS" ]; then \
		OUTPUT=`dbus-daemon --print-address=1 --print-pid=1 --session --fork`; \
		export DBUS_SESSION_BUS_ADDRESS=`echo $$OUTPUT | cut -f1 -d ' '`; \
		DBUS_PID=`echo $$OUTPUT | cut -f2 -d ' '`; \
		trap "kill $$DBUS_PID" EXIT; \
	fi; \
	if [ -z "$$DISPLAY" ]; then \
		xvfb-run $(TEST_COMMAND); \
	else \
	    $(TEST_COMMAND); \
	fi

lint:
	bzr ls-lint

pyflakes:
	-pyflakes `find landscape -name \*py|grep -v twisted_amp\.py|grep -v configobj\.py|grep -v mocker\.py`

clean:
	-find landscape -name \*.pyc -exec rm -f {} \;
	-rm tags
	-rm _trial_temp -rf
	-rm docs/api -rf;
	-rm man/\*.1 -rf
	-rm sdist -rf

doc: docs/api/twisted/pickle
	mkdir -p docs/api
	${PYDOCTOR} --make-html --html-output docs/api --add-package landscape --extra-system=docs/api/twisted/pickle:twisted/

docs/api/twisted/pickle:
	mkdir -p docs/api/twisted
	-${PYDOCTOR} --make-html --html-output docs/api/twisted --add-package /usr/share/pyshared/twisted -o docs/api/twisted/pickle

manpages:
	LC_ALL=C ${TXT2MAN} -P Landscape -s 1 -t landscape-client < man/landscape-client.txt > man/landscape-client.1
	LC_ALL=C ${TXT2MAN} -P Landscape -s 1 -t landscape-config < man/landscape-config.txt > man/landscape-config.1
	LC_ALL=C ${TXT2MAN} -P Landscape -s 1 -t landscape-message < man/landscape-message.txt > man/landscape-message.1
	LC_ALL=C ${TXT2MAN} -P Landscape -s 1 -t landscape-sysinfo < man/landscape-sysinfo.txt > man/landscape-sysinfo.1

origtarball: sdist
	cp -f sdist/landscape-client-$(TARBALL_VERSION).tar.gz \
		../landscape-client_$(TARBALL_VERSION).orig.tar.gz

prepchangelog:
# add a temporary entry for a local build if needed
ifeq (,$(findstring +bzr,$(CHANGELOG_VERSION)))
	dch -v $(TARBALL_VERSION)-0ubuntu0 "New local test build" --distribution $(UBUNTU_RELEASE)
else
# just update the timestamp
	dch --distribution $(UBUNTU_RELEASE) --release $(UBUNTU_RELEASE)
endif

updateversion:
	sed -i -e "s/^UPSTREAM_VERSION.*/UPSTREAM_VERSION = \"$(TARBALL_VERSION)\"/g" \
		landscape/__init__.py

package: clean prepchangelog updateversion
	debuild -b $(DEBUILD_OPTS)

sourcepackage: clean origtarball prepchangelog updateversion
	# need to remove sdist here because it doesn't exist in the
	# orig tarball
	rm -rf sdist
	debuild -S $(DEBUILD_OPTS)

MESSAGE_DIR = `pwd`/runclient-messages
LOG_FILE = `pwd`/runclient.log

freshdata:
	-sudo rm -rf $(MESSAGE_DIR)
	-sudo mkdir $(MESSAGE_DIR)

run:
	-sudo ./landscape-client \
		-a onward -t "John's PC" \
		-u http://localhost:8080/message-system \
		-d $(MESSAGE_DIR) \
		--urgent-exchange-interval=5 \
		--log-level=debug \
		--ping-url=http://localhost:8081/ping \

freshrun: freshdata run

tags:
	-ctags --languages=python -R .

etags:
	-etags --languages=python -R .

releasetarball:
	make sdist TARBALL_VERSION=$(UPSTREAM_VERSION)

sdist: clean
	mkdir -p sdist
	# --uncommitted because we want any changes the developer might have made
	# locally to be included in the package without having to commit
	bzr export --uncommitted sdist/landscape-client-$(TARBALL_VERSION)
	rm -rf sdist/landscape-client-$(TARBALL_VERSION)/debian
	sed -i -e "s/^UPSTREAM_VERSION.*/UPSTREAM_VERSION = \"$(TARBALL_VERSION)\"/g" \
		sdist/landscape-client-$(TARBALL_VERSION)/landscape/__init__.py
	cd sdist && tar cfz landscape-client-$(TARBALL_VERSION).tar.gz landscape-client-$(TARBALL_VERSION)
	cd sdist && md5sum landscape-client-$(TARBALL_VERSION).tar.gz > landscape-client-$(TARBALL_VERSION).tar.gz.md5
	rm -rf sdist/landscape-client-$(TARBALL_VERSION)

.PHONY: tags etags freshdata run freshrun package sourcepackage updateversion origtarball prepchangelog lint build check releasetarball