~allenap/maas/repackage

544.1.1 by Gavin Panella
Simplify convert-enums by working with files only, not trying to do module jiggery pokery.
1
python := python2.7
1062.1.1 by Gavin Panella
Really really tell buildout to stay off the network.
2
3
# Network activity can be suppressed by setting offline=true (or any
4
# non-empty string) at the command-line.
5
ifeq ($(offline),)
634.3.5 by Gavin Panella
Add --never-download to virtualenv's flags when using build-offline.
6
virtualenv := virtualenv
1062.1.1 by Gavin Panella
Really really tell buildout to stay off the network.
7
else
8
virtualenv := virtualenv --never-download
9
endif
544.1.1 by Gavin Panella
Simplify convert-enums by working with files only, not trying to do module jiggery pokery.
10
1170.1.2 by Gavin Panella
Set bogus proxies to try and thwart more network activity.
11
# If offline has been selected, attempt to further block HTTP/HTTPS
12
# activity by setting bogus proxies in the environment.
13
ifneq ($(offline),)
14
export http_proxy := broken
15
export https_proxy := broken
16
endif
17
576.2.2 by Gavin Panella
New global dbrun.
18
# Prefix commands with this when they need access to the database.
19
# Remember to add a dependency on bin/database from the targets in
20
# which those commands appear.
21
dbrun := bin/database --preserve run --
22
510.4.63 by Gavin Panella
Default the database to maas, and use bin/database run when mutating the database.
23
# For things that care, postgresfixture for example, we always want to
24
# use the "maas" databases.
25
export PGDATABASE := maas
26
1853 by Gavin Panella
Work in progress on the top Makefile.
27
# Executables that are usual for a development environment.
28
define executables
1834 by Gavin Panella
Start of removal of buildout.
29
  bin/database
1854 by Gavin Panella
Move responsibility for flake8 into maas-develop.
30
  bin/flake8
1834 by Gavin Panella
Start of removal of buildout.
31
  bin/ipython
1882 by Gavin Panella
Update targets.
32
  bin/sphinx
33
34
  bin/maas-dns-server
1967 by Gavin Panella
Some more maascli/maas-cli fixes.
35
  bin/maas-region-admin
1882 by Gavin Panella
Update targets.
36
  bin/maas-region-twistd
37
  bin/maas-region-worker
38
39
  bin/maas-cluster-twistd
40
  bin/maas-cluster-worker
1834 by Gavin Panella
Start of removal of buildout.
41
  bin/maas-probe-dhcp
42
  bin/maas-provision
1882 by Gavin Panella
Update targets.
43
1967 by Gavin Panella
Some more maascli/maas-cli fixes.
44
  bin/maas
1834 by Gavin Panella
Start of removal of buildout.
45
endef
1853 by Gavin Panella
Work in progress on the top Makefile.
46
executables := $(strip $(executables))
1834 by Gavin Panella
Start of removal of buildout.
47
48
# The Python packages that form MAAS, in order of installation (pip is
49
# not great at resolving dependencies in the correct order).
50
define python-packages
51
  maas-apiclient
52
  maas-client
53
  maas-cluster
54
  maas-region
55
  maas-testing
56
  maas-develop
57
endef
1853 by Gavin Panella
Work in progress on the top Makefile.
58
python-packages := $(strip $(python-packages))
59
60
build: $(executables) enums
61
62
all: build doc
63
1745.73.1 by Gavin Panella
virtualenv in Trusty does not install the pip executable when using --system-site-packages.
64
bin/python:
1853 by Gavin Panella
Work in progress on the top Makefile.
65
	$(virtualenv) --python=$(python) --system-site-packages $(CURDIR)
66
1952 by Gavin Panella
bin/pip is no longer guaranteed to be made.
67
$(executables): bin/python
1853 by Gavin Panella
Work in progress on the top Makefile.
68
	$(MAKE) -C pkg
1909 by Gavin Panella
Install deps before installing packages.
69
	@for dep in $(python-packages); do \
70
	    (cd pkg/$${dep} && python setup.py install_deps); done
1945 by Gavin Panella
Merge trunk, resolving lots of conflicts.
71
	bin/python -m pip install \
72
	    $(addprefix --editable pkg/,$(python-packages))
1834 by Gavin Panella
Start of removal of buildout.
73
	@touch --no-create $@
74
75
test:
1796 by Gavin Panella
Ensure that pkg tests are run when the original tests are too.
76
	$(MAKE) -C pkg test
1 by Raphael Badin
Initial commit.
77
1745.437.1 by jtv at canonical
Move Python linting into its own target, lint-py.
78
lint: lint-py lint-js lint-doc
1 by Raphael Badin
Initial commit.
79
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
80
pocketlint = $(call available,pocketlint,python-pocket-lint)
81
1745.242.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
82
# XXX jtv 2014-02-25: Clean up this lint, then make it part of "make lint".
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
83
lint-css: sources = src/maasserver/static/css
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
84
lint-css:
1845 by Gavin Panella
Fix lint-css and lint-js.
85
	@find . -type f -name '*.css' -print0 | \
86
	    xargs -r0 $(pocketlint) --max-length=120
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
87
2210 by Gavin Panella
Merge trunk r2181, resolving minor conflicts.
88
lint-py: sources = src/*/ templates utilities pkg/common
89
lint-py: sources += pkg/*/contrib pkg/*/etc pkg/*/*.py pkg/*/twisted
1745.437.1 by jtv at canonical
Move Python linting into its own target, lint-py.
90
lint-py: bin/flake8
2210 by Gavin Panella
Merge trunk r2181, resolving minor conflicts.
91
	@find $(sources) -type f -name '*.py' \
92
	    ! -path '*/migrations/*' ! -path '*/setup.py' -print0 | \
93
	    xargs -r0 bin/flake8 --ignore=E123 --config=/dev/null
1745.437.1 by jtv at canonical
Move Python linting into its own target, lint-py.
94
1745.242.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
95
lint-doc:
2210 by Gavin Panella
Merge trunk r2181, resolving minor conflicts.
96
	@utilities/doc-lint
1745.242.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
97
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
98
lint-js: sources = src/maasserver/static/js
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
99
lint-js:
1845 by Gavin Panella
Fix lint-css and lint-js.
100
	@find . -type f -name '*.js' -print0 | \
101
	    xargs -r0 $(pocketlint) --max-length=120
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
102
1745.437.2 by jtv at canonical
Add ‘format’ target to Makefile.
103
# Apply automated formatting to all Python files.
2210 by Gavin Panella
Merge trunk r2181, resolving minor conflicts.
104
format: sources = src/*/ templates utilities pkg/common
105
format: sources += pkg/*/contrib pkg/*/etc pkg/*/*.py pkg/*/twisted
1745.437.2 by jtv at canonical
Add ‘format’ target to Makefile.
106
format:
2210 by Gavin Panella
Merge trunk r2181, resolving minor conflicts.
107
	@find $(sources) -name '*.py' -print0 | \
108
	    xargs -r0 utilities/format-imports
1745.437.2 by jtv at canonical
Add ‘format’ target to Makefile.
109
620.1.2 by Gavin Panella
Fix dependencies in Makefile.
110
check: clean test
1 by Raphael Badin
Initial commit.
111
1929 by Gavin Panella
Change some comments to TODOs.
112
# TODO: Move to maas-develop? Or maas-region. Generating documentation
113
# may even be better contained in a separate subproject.
1967 by Gavin Panella
Some more maascli/maas-cli fixes.
114
docs/api.rst: bin/maas-region-admin src/maasserver/api.py syncdb
1745.169.3 by Julian Edwards
Makefile fixes
115
	bin/maas-region-admin generate_api_doc > $@
21.1.3 by Raphael Badin
Generate static doc.
116
1929 by Gavin Panella
Change some comments to TODOs.
117
# TODO: Move to maas-develop? Or maas-region. Generating documentation
118
# may even be better contained in a separate subproject.
32.1.2 by Gavin Panella
Use distribute with buildout; fix dependencies around docs; fix clean and distclean.
119
doc: bin/sphinx docs/api.rst
1835 by Gavin Panella
maas-develop depends on sphinx.
120
	bin/sphinx docs docs/_build/html
21.1.3 by Raphael Badin
Generate static doc.
121
1929 by Gavin Panella
Change some comments to TODOs.
122
# TODO: Move to maas-develop? Or maas-region. Generating documentation
123
# may even be better contained in a separate subproject.
1745.540.1 by Raphael Badin
The 'doc-with-versions' target should depend on docs/api.rst so that the API doc is part of the generated documentation.
124
doc-with-versions: bin/sphinx docs/api.rst
1745.487.2 by Raphael Badin
Add versions Javascript file.
125
	cd docs/_build; make SPHINXOPTS="-A add_version_switcher=true" html
126
2267 by Gavin Panella
Merge trunk r2238, resolving 1 minor conflict.
127
# TODO: Move to maas-develop? Or maas-region. Generating documentation
128
# may even be better contained in a separate subproject.
1293.5.5 by Gavin Panella
Build the maas-cli.8 man page.
129
man: $(patsubst docs/man/%.rst,man/%,$(wildcard docs/man/*.rst))
130
1929 by Gavin Panella
Change some comments to TODOs.
131
# TODO: Move to maas-develop? Or maas-region. Generating documentation
132
# may even be better contained in a separate subproject.
1846 by Gavin Panella
Fix typos and add comments to top Makefile.
133
man/%: docs/man/%.rst | bin/sphinx
134
	bin/sphinx -b man docs man $^
1293.5.5 by Gavin Panella
Build the maas-cli.8 man page.
135
1929 by Gavin Panella
Change some comments to TODOs.
136
# TODO: Dynamically serve enums JavaScript to clients. This build step
137
# complicates packaging, and introduces some fragility.
1831 by Gavin Panella
Move responsibility for enums.js into the package's Makefile.
138
enums:
139
	$(MAKE) -C pkg/maas-region enums
532.1.1 by Jeroen Vermeulen
Script to generate JavaScript enums from our Python enums.
140
532.1.3 by Jeroen Vermeulen
Generate JS versions of our python enums.
141
clean:
965.1.11 by Gavin Panella
Clean the acceptance tree when clean is called.
142
	$(MAKE) -C acceptance $@
1796 by Gavin Panella
Ensure that pkg tests are run when the original tests are too.
143
	$(MAKE) -C pkg $@
532.1.3 by Jeroen Vermeulen
Generate JS versions of our python enums.
144
	find . -type f -name '*.py[co]' -print0 | xargs -r0 $(RM)
145
	find . -type f -name '*~' -print0 | xargs -r0 $(RM)
1352.2.5 by Gavin Panella
Clean more stuff in clean, rather than distclean.
146
	find . -type f -name dropin.cache -print0 | xargs -r0 $(RM)
546.2.6 by Raphael Badin
Ignore *.log.
147
	$(RM) *.log
674.1.5 by Gavin Panella
Use autosummary for enums too.
148
	$(RM) docs/api.rst
1352.2.5 by Gavin Panella
Clean more stuff in clean, rather than distclean.
149
	$(RM) -r docs/_autosummary docs/_build
1366.1.1 by Gavin Panella
Store generated man pages in the tree.
150
	$(RM) -r man/.doctrees
532.1.3 by Jeroen Vermeulen
Generate JS versions of our python enums.
151
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
152
distclean: clean stop
634.3.3 by Gavin Panella
Use virtualenv/pip to bootstrap zc.buildout, instead of buildout's buggy bootstrap.py.
153
	$(RM) -r bin include lib local
1917 by Gavin Panella
More Makefile clean-ups.
154
	$(RM) -r build dist logs/*
155
	$(RM) tags TAGS
156
	$(RM) -r *.egg *.egg-info
149.6.50 by Gavin Panella
Remove the contents of run/ on distclean.
157
	$(RM) -r run/* services/*/supervise
47.4.1 by Gavin Panella
Rename the django recipe to maas.
158
1929 by Gavin Panella
Change some comments to TODOs.
159
# TODO: Move to maas-develop? This is a development-only target.
1745.169.3 by Julian Edwards
Makefile fixes
160
harness: bin/maas-region-admin bin/database
1965 by Gavin Panella
Merge trunk, resolving many conflicts.
161
	$(dbrun) bin/maas-region-admin shell
47.4.1 by Gavin Panella
Rename the django recipe to maas.
162
1929 by Gavin Panella
Change some comments to TODOs.
163
# TODO: Move to maas-develop? This is a development-only target.
510.4.20 by Gavin Panella
New buildout target for bin/database.
164
dbharness: bin/database
510.4.63 by Gavin Panella
Default the database to maas, and use bin/database run when mutating the database.
165
	bin/database --preserve shell
510.4.13 by Gavin Panella
New dbharness target.
166
1929 by Gavin Panella
Change some comments to TODOs.
167
# TODO: Move to maas-develop? This is a development-only target.
1745.169.3 by Julian Edwards
Makefile fixes
168
syncdb: bin/maas-region-admin bin/database
169
	$(dbrun) bin/maas-region-admin syncdb --noinput
170
	$(dbrun) bin/maas-region-admin migrate maasserver --noinput
171
	$(dbrun) bin/maas-region-admin migrate metadataserver --noinput
273.1.6 by Raphael Badin
Add empy line.
172
1929 by Gavin Panella
Change some comments to TODOs.
173
# TODO: Move to maas-develop, along with dev_fixture.yaml? This is a
174
# development-only target.
1965 by Gavin Panella
Merge trunk, resolving many conflicts.
175
sampledata: bin/maas-region-admin bin/database syncdb
176
	$(dbrun) bin/maas-region-admin loaddata \
177
	    src/maasserver/fixtures/dev_fixture.yaml
1929 by Gavin Panella
Change some comments to TODOs.
178
149.6.30 by Gavin Panella
Reorganize Makefile.
179
define phony_targets
180
  build
181
  check
182
  clean
510.4.13 by Gavin Panella
New dbharness target.
183
  dbharness
149.6.30 by Gavin Panella
Reorganize Makefile.
184
  distclean
185
  doc
532.1.1 by Jeroen Vermeulen
Script to generate JavaScript enums from our Python enums.
186
  enums
1745.437.2 by jtv at canonical
Add ‘format’ target to Makefile.
187
  format
149.6.30 by Gavin Panella
Reorganize Makefile.
188
  harness
189
  lint
190
  lint-css
1745.242.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
191
  lint-doc
149.6.30 by Gavin Panella
Reorganize Makefile.
192
  lint-js
1745.437.1 by jtv at canonical
Move Python linting into its own target, lint-py.
193
  lint-py
1293.5.5 by Gavin Panella
Build the maas-cli.8 man page.
194
  man
1745.209.1 by Julian Edwards
experimental package building
195
  package
149.6.30 by Gavin Panella
Reorganize Makefile.
196
  sampledata
1745.209.4 by Julian Edwards
Really make package building work
197
  source_package
149.6.30 by Gavin Panella
Reorganize Makefile.
198
  syncdb
199
  test
200
endef
201
202
#
203
# Development services.
204
#
205
1093.4.1 by Raphael Badin
Create cluster-worker and region-worker services. Split celeryconfig into cluster and region config files.
206
service_names_region := database dns region-worker reloader txlongpoll web webapp
207
service_names_cluster := cluster-worker pserv reloader
1044.2.1 by Gavin Panella
Get the run target to run everything.
208
service_names_all := $(service_names_region) $(service_names_cluster)
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
209
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
210
# The following template is intended to be used with `call`, and it
211
# accepts a single argument: a target name. The target name must
212
# correspond to a service action (see "Pseudo-magic targets" below).
213
# A region- and cluster-specific variant of the target will be
214
# created, in addition to the target itself. These can be used to
215
# apply the service action to the region services, the cluster
216
# services, or all services, at the same time.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
217
define service_template
218
$(1)-region: $(patsubst %,services/%/@$(1),$(service_names_region))
219
$(1)-cluster: $(patsubst %,services/%/@$(1),$(service_names_cluster))
220
$(1): $(1)-region $(1)-cluster
221
phony_services_targets += $(1)-region $(1)-cluster $(1)
222
endef
223
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
224
# Expand out aggregate service targets using `service_template`.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
225
$(eval $(call service_template,pause))
226
$(eval $(call service_template,restart))
227
$(eval $(call service_template,start))
228
$(eval $(call service_template,status))
229
$(eval $(call service_template,stop))
230
$(eval $(call service_template,supervise))
231
1875 by Gavin Panella
Comment on the creation of logs directories for running services.
232
# The `run` targets do not fit into the mould of the others. Note: logs
233
# directories shouldn't be needed for `run` targets, but some config
234
# seems to still require it, so we create them. Ideally the configs used
235
# for running services should log to stdout/stderr, then we could get
236
# rid of these.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
237
run-region:
1874 by Gavin Panella
Ensure that logs directories are created when running services.
238
	@mkdir -p $(addprefix logs/,$(service_names_region))
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
239
	@services/run $(service_names_region)
240
run-cluster:
1874 by Gavin Panella
Ensure that logs directories are created when running services.
241
	@mkdir -p $(addprefix logs/,$(service_names_cluster))
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
242
	@services/run $(service_names_cluster)
1044.2.1 by Gavin Panella
Get the run target to run everything.
243
run:
1874 by Gavin Panella
Ensure that logs directories are created when running services.
244
	@mkdir -p $(addprefix logs/,$(service_names_all))
1044.2.1 by Gavin Panella
Get the run target to run everything.
245
	@services/run $(service_names_all)
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
246
247
phony_services_targets += run-region run-cluster run
149.6.45 by Gavin Panella
Add new target, run+web, to run the web service in the foreground.
248
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
249
# This one's for the rapper, yo.
149.6.51 by Gavin Panella
Fix typo.
250
run+webapp:
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
251
	@services/run $(service_names_region) +webapp
252
253
phony_services_targets += run+webapp
149.6.30 by Gavin Panella
Reorganize Makefile.
254
511.1.2 by Gavin Panella
Also check for setlock.
255
# Convenient variables and functions for service control.
149.6.32 by Gavin Panella
Add +services/%/@run target.
256
511.1.2 by Gavin Panella
Also check for setlock.
257
setlock = $(call available,setlock,daemontools)
511.1.1 by Gavin Panella
Check availability of daemontools.
258
supervise = $(call available,supervise,daemontools)
259
svc = $(call available,svc,daemontools)
260
svok = $(call available,svok,daemontools)
261
svstat = $(call available,svstat,daemontools)
262
511.1.2 by Gavin Panella
Also check for setlock.
263
service_lock = $(setlock) -n /run/lock/maas.dev.$(firstword $(1))
264
265
# Pseudo-magic targets for controlling individual services.
149.6.39 by Gavin Panella
Lock when running or supervising.
266
1875 by Gavin Panella
Comment on the creation of logs directories for running services.
267
# Note: log directories shouldn't be needed for `@run` targets, but some
268
# config seems to still require it, so we create them. Ideally the
269
# configs used for running services should log to stdout/stderr, then we
270
# could get rid of this.
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
271
services/%/@run: services/%/@stop services/%/@deps
1866 by Gavin Panella
Move static celery configs into packages.
272
	@mkdir -p logs/$*
149.6.39 by Gavin Panella
Lock when running or supervising.
273
	@$(call service_lock, $*) services/$*/run
149.6.32 by Gavin Panella
Add +services/%/@run target.
274
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
275
services/%/@start: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
276
	@$(svc) -u $(@D)
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
277
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
278
services/%/@pause: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
279
	@$(svc) -d $(@D)
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
280
149.6.34 by Gavin Panella
More reorg.
281
services/%/@status:
511.1.1 by Gavin Panella
Check availability of daemontools.
282
	@$(svstat) $(@D)
149.6.34 by Gavin Panella
More reorg.
283
149.6.35 by Gavin Panella
Add restart target.
284
services/%/@restart: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
285
	@$(svc) -du $(@D)
149.6.35 by Gavin Panella
Add restart target.
286
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
287
services/%/@stop:
511.1.1 by Gavin Panella
Check availability of daemontools.
288
	@if $(svok) $(@D); then $(svc) -dx $(@D); fi
289
	@while $(svok) $(@D); do sleep 0.1; done
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
290
149.6.34 by Gavin Panella
More reorg.
291
services/%/@supervise: services/%/@deps
292
	@mkdir -p logs/$*
293
	@touch $(@D)/down
511.1.1 by Gavin Panella
Check availability of daemontools.
294
	@if ! $(svok) $(@D); then \
674.1.1 by Gavin Panella
Should use CURDIR instead of PWD in Makefile; the latter is inherited from the shell, the former is provided by make.
295
	    logdir=$(CURDIR)/logs/$* \
511.1.1 by Gavin Panella
Check availability of daemontools.
296
	        $(call service_lock, $*) $(supervise) $(@D) & fi
297
	@while ! $(svok) $(@D); do sleep 0.1; done
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
298
149.6.32 by Gavin Panella
Add +services/%/@run target.
299
# Dependencies for individual services.
300
1876 by Gavin Panella
Move most entry points into maas-develop.
301
services/dns/@deps: bin/maas-dns-server
720.2.1 by Raphael Badin
Add dns service.
302
1882 by Gavin Panella
Update targets.
303
services/cluster-worker/@deps: bin/maas-cluster-worker
1093.4.1 by Raphael Badin
Create cluster-worker and region-worker services. Split celeryconfig into cluster and region config files.
304
1882 by Gavin Panella
Update targets.
305
services/region-worker/@deps: bin/maas-region-worker
510.4.55 by Gavin Panella
Merge trunk, resolving 2 conflicts.
306
510.4.20 by Gavin Panella
New buildout target for bin/database.
307
services/database/@deps: bin/database
510.4.5 by Gavin Panella
Start and stop the database as a service.
308
1882 by Gavin Panella
Update targets.
309
services/pserv/@deps: bin/maas-cluster-twistd
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
310
149.6.44 by Gavin Panella
The reloader doesn't depend on web and pserv.
311
services/reloader/@deps:
149.6.14 by Gavin Panella
Add the reloader service to Makefile.
312
1882 by Gavin Panella
Update targets.
313
services/txlongpoll/@deps: bin/maas-region-twistd
149.6.19 by Gavin Panella
Add txlongpoll as a service.
314
149.6.47 by Gavin Panella
Control Apache via the service mechanism, calling it 'web'. Renamed the existing 'web' service to 'webapp'.
315
services/web/@deps:
316
1745.169.3 by Julian Edwards
Makefile fixes
317
services/webapp/@deps: bin/maas-region-admin
561.2.1 by Raphael Badin
Add celeryd to the list of available services.
318
149.6.30 by Gavin Panella
Reorganize Makefile.
319
#
1745.209.1 by Julian Edwards
experimental package building
320
# Package building
321
#
1745.209.2 by Julian Edwards
Gavin's Makefile foo put to use
322
# This ought to be as simple as using bzr builddeb --export-upstream but it
1745.209.1 by Julian Edwards
experimental package building
323
# has a bug and always considers apt-source tarballs before the specified
324
# branch.  So instead, export to a local tarball which is always found.
1745.209.4 by Julian Edwards
Really make package building work
325
# Make sure debhelper and dh-apport packages are installed before using this.
326
PACKAGING := $(CURDIR)/../packaging.trunk
327
PACKAGING_BRANCH := lp:~maas-maintainers/maas/packaging
328
329
package_branch:
330
	@echo Downloading/refreshing packaging branch...
331
	@if [ ! -d $(PACKAGING) ]; then \
332
		bzr branch $(PACKAGING_BRANCH) $(PACKAGING); \
333
		else bzr pull -d $(PACKAGING); fi
1745.209.5 by Julian Edwards
review comments
334
335
# Make sure an orig tarball generated from the current branch is placed in the
336
# build area.
1745.209.4 by Julian Edwards
Really make package building work
337
package_export: VER = $(shell dpkg-parsechangelog -l$(PACKAGING)/debian/changelog | sed -rne 's,^Version: ([^-]+).*,\1,p')
338
package_export: TARBALL = maas_$(VER).orig.tar.gz
339
package_export: package_branch
340
	@$(RM) -f ../build-area/$(TARBALL)
341
	@mkdir -p ../build-area
342
	@bzr export --root=maas-$(VER).orig ../build-area/$(TARBALL) $(CURDIR)
1745.209.5 by Julian Edwards
review comments
343
1745.209.4 by Julian Edwards
Really make package building work
344
package: package_export
1745.588.1 by Julian Edwards
'make package' now puts the package files in ../build-area/ instead of the ../ directory.
345
	bzr bd --merge $(PACKAGING) --result-dir=../build-area -- -uc -us
346
	@echo Binary packages built, see ../build-area/ directory.
1745.209.5 by Julian Edwards
review comments
347
1745.209.4 by Julian Edwards
Really make package building work
348
source_package: package_export
1745.588.1 by Julian Edwards
'make package' now puts the package files in ../build-area/ instead of the ../ directory.
349
	bzr bd --merge $(PACKAGING) --result-dir=../build-area -- -S -uc -us
350
	@echo Source package built, see ../build-area/ directory.
1745.209.1 by Julian Edwards
experimental package building
351
352
#
149.6.30 by Gavin Panella
Reorganize Makefile.
353
# Phony stuff.
354
#
355
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
356
define phony
149.6.30 by Gavin Panella
Reorganize Makefile.
357
  $(phony_services_targets)
358
  $(phony_targets)
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
359
endef
360
149.6.30 by Gavin Panella
Reorganize Makefile.
361
phony := $(sort $(strip $(phony)))
362
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
363
.PHONY: $(phony)
511.1.1 by Gavin Panella
Check availability of daemontools.
364
365
#
366
# Functions.
367
#
368
369
# Check if a command is found on PATH. Raise an error if not, citing
370
# the package to install. Return the command otherwise.
371
# Usage: $(call available,<command>,<package>)
372
define available
511.1.4 by Gavin Panella
Make the error message from 'available' more explicit.
373
  $(if $(shell which $(1)),$(1),$(error $(1) not found; \
374
    install it with 'sudo apt-get install $(2)'))
511.1.1 by Gavin Panella
Check availability of daemontools.
375
endef