~maas-committers/maas/trunk

4489.5.7 by Gavin Panella
Reduce churn in Makefile.
1
python := python3.5
2
4337.1.2 by Gavin Panella
Silence annoying pkg_resources warnings about iterating over version numbers.
3
# pkg_resources makes some incredible noise about version numbers. They
4
# are not indications of bugs in MAAS so we silence them everywhere.
5
export PYTHONWARNINGS = \
6
  ignore:You have iterated over the result:RuntimeWarning:pkg_resources:
7
1062.1.1 by Gavin Panella
Really really tell buildout to stay off the network.
8
# Network activity can be suppressed by setting offline=true (or any
9
# non-empty string) at the command-line.
10
ifeq ($(offline),)
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
11
buildout := bin/buildout
1062.1.1 by Gavin Panella
Really really tell buildout to stay off the network.
12
else
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
13
buildout := bin/buildout buildout:offline=true
1062.1.1 by Gavin Panella
Really really tell buildout to stay off the network.
14
endif
544.1.1 by Gavin Panella
Simplify convert-enums by working with files only, not trying to do module jiggery pokery.
15
1170.1.2 by Gavin Panella
Set bogus proxies to try and thwart more network activity.
16
# If offline has been selected, attempt to further block HTTP/HTTPS
17
# activity by setting bogus proxies in the environment.
18
ifneq ($(offline),)
19
export http_proxy := broken
20
export https_proxy := broken
21
endif
22
544.1.1 by Gavin Panella
Simplify convert-enums by working with files only, not trying to do module jiggery pokery.
23
# Python enum modules.
24
py_enums := $(wildcard src/*/enum.py)
25
# JavaScript enum module (not modules).
26
js_enums := src/maasserver/static/js/enums.js
4596.1.12 by Mike Pontillo
Makefile cleanup. Fix minor bugs in template data creation script.
27
templates := $(shell find etc/maas/templates -type f)
28
3326.3.16 by Gavin Panella
Fix Makefile so that dependency checks are done for CSS builds.
29
# MAAS SASS stylesheets. The first input file (maas-styles.css) imports
30
# the others, so is treated specially in the target definitions.
5719.1.1 by Richard McCartney
Removing all SCSS files and setting maas framework v1.2.0 as a NPM dependancy
31
scss_theme := include/nodejs/node_modules/maas-gui-vanilla-theme
5683.4.2 by Gavin Panella
Fix building of styles to not clobber stuff.
32
scss_input := src/maasserver/static/scss/build.scss
33
scss_deps := $(wildcard src/maasserver/static/scss/_*.scss)
5112.2.1 by Richard McCartney
Adding all assets and new theme files
34
scss_output := src/maasserver/static/css/build.css
3429.2.2 by Blake Rouse
Add make rule for generation of scss to css. Add watcher for modified scss in the reloader to ease development.
35
576.2.2 by Gavin Panella
New global dbrun.
36
# Prefix commands with this when they need access to the database.
37
# Remember to add a dependency on bin/database from the targets in
38
# which those commands appear.
39
dbrun := bin/database --preserve run --
40
4821.1.1 by Blake Rouse
Disable test.e2e. Speed up npm install.
41
# Disable progress when running npm and warning log levels.
42
npm_install := NODE_ENV=production NPM_CONFIG_PROGRESS="false" npm install \
43
	--loglevel error --cache-min 600
44
510.4.63 by Gavin Panella
Default the database to maas, and use bin/database run when mutating the database.
45
# For things that care, postgresfixture for example, we always want to
46
# use the "maas" databases.
47
export PGDATABASE := maas
48
3074.1.15 by Gavin Panella
Always export MAAS_ROOT=./run in Makefile.
49
# For anything we start, we want to hint as to its root directory.
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
50
export MAAS_ROOT := $(CURDIR)/.run
3074.1.15 by Gavin Panella
Always export MAAS_ROOT=./run in Makefile.
51
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
52
build: \
5372.1.1 by Mike Pontillo
Remove ntp.conf from run/; copy it before tests run.
53
  bin/buildout \
54
  bin/database \
55
  bin/maas \
56
  bin/maas-rack \
57
  bin/maas-region \
58
  bin/twistd.rack \
59
  bin/twistd.region \
60
  bin/test.cli \
61
  bin/test.rack \
62
  bin/test.region \
5159.3.14 by Gavin Panella
Merge trunk, resolving conflicts.
63
  bin/test.region.legacy \
5372.1.1 by Mike Pontillo
Remove ntp.conf from run/; copy it before tests run.
64
  bin/test.testing \
65
  bin/test.js \
66
  bin/test.e2e \
5637.2.5 by Gavin Panella
Plumb the parallel testing script into a bin/test.parallel script.
67
  bin/test.parallel \
5372.1.1 by Mike Pontillo
Remove ntp.conf from run/; copy it before tests run.
68
  bin/py bin/ipy \
69
  $(js_enums)
47.4.12 by Gavin Panella
Don't always build docs.
70
71
all: build doc
9.1.5 by Gavin Panella
Clean up Makefile dependencies.
72
794.1.2 by Gavin Panella
Move install_dependencies towards to the top of the Makefile, make it display the full command line when executing, rename it install-dependencies to match a couple of existing targets, and mark it as phony.
73
# Install all packages required for MAAS development & operation on
74
# the system. This may prompt for a password.
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
75
install-dependencies: release := $(shell lsb_release -c -s)
794.1.2 by Gavin Panella
Move install_dependencies towards to the top of the Makefile, make it display the full command line when executing, rename it install-dependencies to match a couple of existing targets, and mark it as phony.
76
install-dependencies:
952.1.1 by Robie Basak
Only install hard dependencies in make install-dependencies
77
	sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
1562.1.6 by Gavin Panella
Keep track of doc package dependencies separately.
78
	    --no-install-recommends install $(shell sort -u \
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
79
	        $(addprefix required-packages/,base build dev doc $(release)) | sed '/^\#/d')
2153.2.1 by Gavin Panella
Purge forbidden dependencies, like python-librabbitmq which causes segfaults.
80
	sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
81
	    purge $(shell sort -u required-packages/forbidden | sed '/^\#/d')
794.1.2 by Gavin Panella
Move install_dependencies towards to the top of the Makefile, make it display the full command line when executing, rename it install-dependencies to match a couple of existing targets, and mark it as phony.
82
4678.2.2 by Gavin Panella
Update imports and other references to formerly bundled code.
83
.bzrignore: FORCE
84
	LC_ALL=C.UTF-8 sort -f $@ --output $@
85
3660.1.2 by Mike Pontillo
Changes based on Gavin's review
86
.gitignore: .bzrignore
87
	sed 's:^[.]/:/:' $^ > $@
88
3917.1.1 by Mike Pontillo
Automatically configure buildout cache
89
configure-buildout:
3926.1.1 by Mike Pontillo
Fix Makefile dependencies
90
	utilities/configure-buildout
3917.1.1 by Mike Pontillo
Automatically configure buildout cache
91
5349.4.16 by Mike Pontillo
Drive-by addition of 'make sudoers' target, to make it easy to re-add any necessary sudoers entries for MAAS development.
92
sudoers:
93
	utilities/grant-nmap-permissions
94
	utilities/install-arp-observer
5408.6.5 by Mike Pontillo
Add helper script to install DHCP observer. Clean up observe-dhcp output.
95
	utilities/install-dhcp-observer
5349.4.16 by Mike Pontillo
Drive-by addition of 'make sudoers' target, to make it easy to re-add any necessary sudoers entries for MAAS development.
96
4489.5.7 by Gavin Panella
Reduce churn in Makefile.
97
bin/buildout: bootstrap-buildout.py
98
	@utilities/configure-buildout --quiet
99
	$(python) bootstrap-buildout.py --allow-site-packages
100
	@touch --no-create $@  # Ensure it's newer than its dependencies.
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
101
5848.1.1 by Gavin Panella
buildout.cfg refers to .run and .run-e2e, so model that dependency.
102
# buildout.cfg refers to .run and .run-e2e.
103
buildout.cfg: .run .run-e2e
104
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
105
bin/database: bin/buildout buildout.cfg versions.cfg setup.py
634.3.1 by Gavin Panella
Try to get everything able to build offline.
106
	$(buildout) install database
510.4.20 by Gavin Panella
New buildout target for bin/database.
107
	@touch --no-create $@
108
5637.2.5 by Gavin Panella
Plumb the parallel testing script into a bin/test.parallel script.
109
bin/test.parallel: \
110
  bin/buildout buildout.cfg versions.cfg setup.py
111
	$(buildout) install parallel-test
112
	@touch --no-create $@
113
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
114
bin/maas-region bin/twistd.region: \
5112.3.4 by Gavin Panella
Get the Makefile building with cloud-vanilla-theme.
115
    bin/buildout buildout.cfg versions.cfg setup.py \
5848.1.3 by Gavin Panella
Remove dependencies on .run and .run-e2e by individual scripts.
116
    $(js_enums) $(scss_output)
3326.3.6 by Gavin Panella
Rename more buildout tasks.
117
	$(buildout) install region
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
118
	@touch --no-create $@
119
4489.5.7 by Gavin Panella
Reduce churn in Makefile.
120
bin/test.region: \
5112.3.7 by Richard McCartney
Merging trunk and resolving conflicts
121
  bin/buildout buildout.cfg versions.cfg setup.py $(js_enums) \
122
  bin/maas-region bin/maas-rack
3326.3.6 by Gavin Panella
Rename more buildout tasks.
123
	$(buildout) install region-test
125.1.1 by Gavin Panella
Switch away from djangorecipe, splitting the mass stuff into stuff required for production and stuff for testing.
124
	@touch --no-create $@
125
5159.3.10 by Gavin Panella
New script bin/test.region.legacy to run legacy tests; bin/test.region only runs resource-using tests.
126
bin/test.region.legacy: \
127
    bin/buildout buildout.cfg versions.cfg setup.py $(js_enums)
128
	$(buildout) install region-test-legacy
129
	@touch --no-create $@
130
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
131
bin/maas: bin/buildout buildout.cfg versions.cfg setup.py
3326.3.4 by Gavin Panella
Rename a couple more test scripts.
132
	$(buildout) install cli
987.1.1 by Gavin Panella
Introduce commandant into a new maascli package.
133
	@touch --no-create $@
134
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
135
bin/test.cli: bin/buildout buildout.cfg versions.cfg setup.py bin/maas
3326.3.4 by Gavin Panella
Rename a couple more test scripts.
136
	$(buildout) install cli-test
987.1.1 by Gavin Panella
Introduce commandant into a new maascli package.
137
	@touch --no-create $@
138
4489.5.7 by Gavin Panella
Reduce churn in Makefile.
139
bin/test.js: bin/karma bin/buildout buildout.cfg versions.cfg setup.py
3434.4.2 by Blake Rouse
Merge initial-angular.
140
	$(buildout) install js-test
141
	@touch --no-create $@
142
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
143
bin/test.e2e: \
5848.1.3 by Gavin Panella
Remove dependencies on .run and .run-e2e by individual scripts.
144
    bin/protractor bin/buildout buildout.cfg versions.cfg setup.py
3434.11.1 by Blake Rouse
Enable protractor for complete end-to-end testing of the MAAS web UI.
145
	$(buildout) install e2e-test
146
	@touch --no-create $@
147
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
148
# bin/maas-region is needed for South migration tests. bin/flake8 is
4537.2.1 by Blake Rouse
Re-enable bin/test.js. Upgrade to newer versions of karma, protractor, and sass.
149
# needed for checking lint and bin/sass is needed for checking css.
4489.5.162 by Gavin Panella
Do not build test.e2e and test.js by default, depend on setuptools 18.7.
150
bin/test.testing: \
5733.2.1 by Gavin Panella
Declare secondary targets to avoid some unnecessary work.
151
  bin/maas-region bin/flake8 bin/sass $(scss_theme) bin/buildout \
5372.1.1 by Mike Pontillo
Remove ntp.conf from run/; copy it before tests run.
152
  buildout.cfg versions.cfg setup.py
3326.3.4 by Gavin Panella
Rename a couple more test scripts.
153
	$(buildout) install testing-test
573.3.1 by Raphael Badin
Separate tests from maastesting.
154
	@touch --no-create $@
155
4873.4.1 by Blake Rouse
Reconnect the DHCP probe. Clean up old code.
156
bin/maas-rack bin/twistd.rack: \
5848.1.3 by Gavin Panella
Remove dependencies on .run and .run-e2e by individual scripts.
157
  bin/buildout buildout.cfg versions.cfg setup.py
4633.3.1 by Gavin Panella
More renames from cluster to rack.
158
	$(buildout) install rack
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
159
	@touch --no-create $@
38.2.1 by Gavin Panella
Break up the big bin/buildout rule.
160
4633.3.1 by Gavin Panella
More renames from cluster to rack.
161
bin/test.rack: \
5881.1.1 by Gavin Panella
The rack tests now need bin/py.
162
  bin/buildout buildout.cfg versions.cfg setup.py bin/maas-rack bin/py
4633.3.1 by Gavin Panella
More renames from cluster to rack.
163
	$(buildout) install rack-test
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
164
	@touch --no-create $@
51.1.1 by Gavin Panella
Get tests working for provisioningserver.
165
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
166
bin/flake8: bin/buildout buildout.cfg versions.cfg setup.py
634.3.1 by Gavin Panella
Try to get everything able to build offline.
167
	$(buildout) install flake8
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
168
	@touch --no-create $@
38.2.1 by Gavin Panella
Break up the big bin/buildout rule.
169
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
170
bin/sphinx bin/sphinx-build: bin/buildout buildout.cfg versions.cfg setup.py
634.3.1 by Gavin Panella
Try to get everything able to build offline.
171
	$(buildout) install sphinx
66.1.1 by Gavin Panella
Create bin/twistd.pserv, and always update targets when calling buildout (because it doesn't).
172
	@touch --no-create $@
1 by Raphael Badin
Initial commit.
173
4489.5.6 by Gavin Panella
Begin migration to Python 3.5.
174
bin/py bin/ipy: bin/buildout buildout.cfg versions.cfg setup.py
634.3.1 by Gavin Panella
Try to get everything able to build offline.
175
	$(buildout) install repl
125.1.2 by Gavin Panella
Touch both py and ipy when rebuilding them.
176
	@touch --no-create bin/py bin/ipy
47.4.5 by Gavin Panella
Rename test.pserv to pserv-test, add a repl part, and update versions.
177
5041.1.1 by Gavin Panella
Use coverage 4.1, which seems to work a little better than the version in Xenial.
178
bin/coverage: bin/buildout buildout.cfg versions.cfg setup.py
179
	$(buildout) install coverage
180
	@touch --no-create bin/coverage
181
3434.6.1 by Gavin Panella
Fix building of bin/karma.
182
define karma-deps
4537.2.1 by Blake Rouse
Re-enable bin/test.js. Upgrade to newer versions of karma, protractor, and sass.
183
  jasmine-core@2.4.1
4577.3.14 by LaMont Jones
Fix karma deps so that tests pass again and karma builds. Thanks Blake!
184
  karma@0.13.19
4537.2.1 by Blake Rouse
Re-enable bin/test.js. Upgrade to newer versions of karma, protractor, and sass.
185
  karma-chrome-launcher@0.2.2
186
  karma-firefox-launcher@0.1.7
187
  karma-jasmine@0.3.6
188
  karma-opera-launcher@0.3.0
4577.3.14 by LaMont Jones
Fix karma deps so that tests pass again and karma builds. Thanks Blake!
189
  karma-phantomjs-launcher@0.2.3
3891.1.1 by Mike Pontillo
Fix issues with mismatched node-sass verions
190
  karma-failed-reporter@0.0.3
4944.1.1 by Mike Pontillo
Update phantomjs version (in order to try to prevent npm errors during build).
191
  phantomjs@2.1.7
3434.6.1 by Gavin Panella
Fix building of bin/karma.
192
endef
193
194
bin/karma: deps = $(strip $(karma-deps))
195
bin/karma: prefix = include/nodejs
3434.4.1 by Blake Rouse
Setup Karma to run unit tests for AngularJS.
196
bin/karma:
3434.6.1 by Gavin Panella
Fix building of bin/karma.
197
	@mkdir -p $(@D) $(prefix)
4821.1.1 by Blake Rouse
Disable test.e2e. Speed up npm install.
198
	$(npm_install) --prefix $(prefix) $(deps)
3434.6.1 by Gavin Panella
Fix building of bin/karma.
199
	@ln -srf $(prefix)/node_modules/karma/bin/karma $@
3434.4.1 by Blake Rouse
Setup Karma to run unit tests for AngularJS.
200
3434.11.1 by Blake Rouse
Enable protractor for complete end-to-end testing of the MAAS web UI.
201
bin/protractor: prefix = include/nodejs
202
bin/protractor:
203
	@mkdir -p $(@D) $(prefix)
4821.1.1 by Blake Rouse
Disable test.e2e. Speed up npm install.
204
	$(npm_install) --prefix $(prefix) protractor@3.0.0
3434.11.1 by Blake Rouse
Enable protractor for complete end-to-end testing of the MAAS web UI.
205
	@ln -srf $(prefix)/node_modules/protractor/bin/protractor $@
206
5112.3.2 by Richard McCartney
Adding cloud vanilla version
207
bin/sass: prefix = include/nodejs
3582.2.1 by Blake Rouse
Remove the need for python-pyscss. Use node-sass to compile scss to css. Commit maas-styles.css in tree.
208
bin/sass:
209
	@mkdir -p $(@D) $(prefix)
4821.1.1 by Blake Rouse
Disable test.e2e. Speed up npm install.
210
	$(npm_install) --prefix $(prefix) node-sass@3.4.2
3582.2.1 by Blake Rouse
Remove the need for python-pyscss. Use node-sass to compile scss to css. Commit maas-styles.css in tree.
211
	@ln -srf $(prefix)/node_modules/node-sass/bin/node-sass $@
212
4489.5.162 by Gavin Panella
Do not build test.e2e and test.js by default, depend on setuptools 18.7.
213
define test-scripts
5112.2.76 by Richard McCartney
resolving js lint issues
214
  bin/test.cli
5188.1.2 by Andres Rodriguez
fix incorrect removal of Makefile code
215
  bin/test.rack
216
  bin/test.region
5159.3.10 by Gavin Panella
New script bin/test.region.legacy to run legacy tests; bin/test.region only runs resource-using tests.
217
  bin/test.region.legacy
5188.1.2 by Andres Rodriguez
fix incorrect removal of Makefile code
218
  bin/test.testing
219
  bin/test.js
4489.5.162 by Gavin Panella
Do not build test.e2e and test.js by default, depend on setuptools 18.7.
220
endef
221
4942.1.12 by Mike Pontillo
Add make target to test with an LXD conainer.
222
lxd:
223
	utilities/configure-lxd-profile
224
	utilities/create-lxd-xenial-image
225
4942.1.13 by Mike Pontillo
Build test scripts on the host before launching on the container.
226
test+lxd: lxd $(strip $(test-scripts))
4942.1.12 by Mike Pontillo
Add make target to test with an LXD conainer.
227
	utilities/isolated-make-test
228
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
229
test: bin/test.parallel bin/coverage
230
	@$(RM) .coverage .coverage.*
5668.3.7 by Gavin Panella
When landing code, always run with one testing process per CPU core.
231
	@bin/test.parallel --subprocess-per-core
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
232
	@bin/coverage combine
5684.3.2 by Gavin Panella
Make the default test target do parallel testing.
233
234
test-serial: $(strip $(test-scripts))
4824.3.4 by Lee Trager
Just run the check in make test so it doesn't fail
235
	@bin/maas-region makemigrations --dry-run --exit && exit 1 ||:
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
236
	@$(RM) .coverage .coverage.* .failed
5240.4.2 by Brendan Donegan
Another attempt at xunit output which makes sure xml files are not overwritten
237
	$(foreach test,$^,$(test-template);)
238
	@test ! -f .failed
239
5266.1.3 by LaMont Jones
Incorporate review feedback.
240
test-failed: $(strip $(test-scripts))
241
	@bin/maas-region makemigrations --dry-run --exit && exit 1 ||:
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
242
	@$(RM) .coverage .coverage.* .failed
5266.1.3 by LaMont Jones
Incorporate review feedback.
243
	$(foreach test,$^,$(test-template-failed);)
244
	@test ! -f .failed
245
246
clean-failed:
247
	$(RM) .noseids
248
5159.3.31 by Gavin Panella
Add initial test data to speed things up.
249
src/maasserver/testing/initial.maas_test.sql: bin/database syncdb
5632.1.1 by Gavin Panella
Don't put ownership or privilege information into the initial test data dump.
250
	bin/database --preserve run -- \
251
	    pg_dump maas --no-owner --no-privileges \
252
	        --format=plain > $@
5159.3.31 by Gavin Panella
Add initial test data to speed things up.
253
254
test-initial-data: src/maasserver/testing/initial.maas_test.sql
255
5240.4.2 by Brendan Donegan
Another attempt at xunit output which makes sure xml files are not overwritten
256
define test-template
257
$(test) --with-xunit --xunit-file=xunit.$(notdir $(test)).xml || touch .failed
258
endef
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
259
5266.1.2 by LaMont Jones
rebase my change to current trunk.
260
define test-template-failed
261
  $(test) --with-xunit --xunit-file=xunit.$(notdir $(test)).xml --failed || \
262
  $(test) --with-xunit --xunit-file=xunit.$(notdir $(test)).xml --failed || \
263
  touch .failed
264
endef
265
5272.1.1 by Gavin Panella
New smoke target for gated landings.
266
smoke: lint bin/maas-region bin/test.rack
267
	@bin/maas-region makemigrations --dry-run --exit && exit 1 ||:
268
	@bin/test.rack --stop
269
5684.3.2 by Gavin Panella
Make the default test target do parallel testing.
270
test-serial+coverage: export NOSE_WITH_COVERAGE = 1
271
test-serial+coverage: test-serial
3819.2.2 by Mike Pontillo
Move stack trace code to provisioningserver.utils. Also, add test+coverage target.
272
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
273
coverage-report: coverage/index.html
274
	sensible-browser $< > /dev/null 2>&1 &
275
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
276
coverage.xml: bin/coverage .coverage
277
	bin/coverage xml -o $@
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
278
5041.1.4 by Gavin Panella
Omit tests and testing resources from HTML coverage report, and include the Bazaar revision number in the title.
279
coverage/index.html: revno = $(or $(shell bzr revno 2>/dev/null),???)
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
280
coverage/index.html: bin/coverage .coverage
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
281
	@$(RM) -r $(@D)
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
282
	bin/coverage html \
283
	    --title "Coverage for MAAS r$(revno)" \
284
	    --directory $(@D)
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
285
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
286
.coverage:
287
	@$(error Use `$(MAKE) test` to generate coverage)
1 by Raphael Badin
Initial commit.
288
5682.1.1 by Gavin Panella
Check for .moved files.
289
lint: \
290
    lint-py lint-py-complexity lint-py-imports \
291
    lint-js lint-junk lint-doc lint-rst
1 by Raphael Badin
Initial commit.
292
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
293
pocketlint = $(call available,pocketlint,python-pocket-lint)
294
2009.1.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
295
# 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.
296
lint-css: sources = src/maasserver/static/css
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
297
lint-css:
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
298
	@find $(sources) -type f \
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
299
	    -print0 | xargs -r0 $(pocketlint) --max-length=120
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
300
5457.1.3 by Gavin Panella
Check McCabe complexity.
301
# Python lint checks are time-intensive, but flake8 now knows how to run
302
# parallel jobs, and does so by default.
5484.3.1 by Gavin Panella
Check for early imports, i.e. where imports occur before __all__.
303
lint-py: sources = setup.py src templates twisted
2177.3.1 by jtv at canonical
Move Python linting into its own target, lint-py.
304
lint-py: bin/flake8
4489.5.132 by Gavin Panella
Don't check src/p/twisted for lint.
305
	@find $(sources) -name '*.py' \
5457.1.3 by Gavin Panella
Check McCabe complexity.
306
	  ! -path '*/migrations/*' ! -path '*/south_migrations/*' -print0 \
5639.3.1 by Gavin Panella
Upgrade lots of test dependencies.
307
	    | xargs -r0 bin/flake8 --ignore=E123,E305,E402,E731 --isolated
5457.1.3 by Gavin Panella
Check McCabe complexity.
308
309
# Ignore tests when checking complexity. The maximum complexity ought to
310
# be close to 10 but MAAS has many functions that are over that so we
311
# start with a much higher number. Over time we can ratchet it down.
312
lint-py-complexity: maximum=26
5484.3.1 by Gavin Panella
Check for early imports, i.e. where imports occur before __all__.
313
lint-py-complexity: sources = setup.py src templates twisted
5457.1.3 by Gavin Panella
Check McCabe complexity.
314
lint-py-complexity: bin/flake8
315
	@find $(sources) -name '*.py' \
4489.5.132 by Gavin Panella
Don't check src/p/twisted for lint.
316
	  ! -path '*/migrations/*' ! -path '*/south_migrations/*' \
5457.1.3 by Gavin Panella
Check McCabe complexity.
317
	  ! -path '*/tests/*' ! -path '*/testing/*' ! -name 'testing.py' \
5639.3.1 by Gavin Panella
Upgrade lots of test dependencies.
318
	  -print0 | xargs -r0 bin/flake8 --ignore=E123,E305,E402,E731 \
5457.1.3 by Gavin Panella
Check McCabe complexity.
319
	              --isolated --max-complexity=$(maximum)
2177.3.1 by jtv at canonical
Move Python linting into its own target, lint-py.
320
4670.1.3 by Gavin Panella
Hook check-imports into Makefile.
321
# Statically check imports against policy.
5484.3.1 by Gavin Panella
Check for early imports, i.e. where imports occur before __all__.
322
lint-py-imports: sources = setup.py src templates twisted
4670.1.3 by Gavin Panella
Hook check-imports into Makefile.
323
lint-py-imports:
324
	@utilities/check-imports
5484.3.1 by Gavin Panella
Check for early imports, i.e. where imports occur before __all__.
325
	@find $(sources) -name '*.py' \
326
	  ! -path '*/migrations/*' ! -path '*/south_migrations/*' \
327
	  -print0 | xargs -r0 utilities/find-early-imports
4670.1.3 by Gavin Panella
Hook check-imports into Makefile.
328
2009.1.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
329
lint-doc:
3686.1.1 by Gavin Panella
Lint-check standalone reST docs.
330
	@utilities/doc-lint
331
3790.2.5 by Gavin Panella
A few more tweaks.
332
# JavaScript lint is checked in parallel for speed.  The -n20 -P4 setting
3147.1.1 by jtv at canonical
Run lint checks in parallel. Not ideal, but the checks were getting really annoyingly slow.
333
# worked well on a multicore SSD machine with the files cached, roughly
334
# doubling the speed, but it may need tuning for slower systems or cold caches.
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
335
lint-js: sources = src/maasserver/static/js
511.1.3 by Gavin Panella
Use the available function for pocketlint too.
336
lint-js:
4489.5.162 by Gavin Panella
Do not build test.e2e and test.js by default, depend on setuptools 18.7.
337
	@find $(sources) -type f ! -path '*/angular/3rdparty/*' \
338
	    '(' -name '*.html' -o -name '*.js' ')' -print0 \
3942.2.2 by Blake Rouse
Skip lint on 3rdparty modules in angular.
339
		| xargs -r0 -n20 -P4 $(pocketlint)
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
340
5682.1.1 by Gavin Panella
Check for .moved files.
341
# Sometimes junk gets added to MAAS, like .moved files.
342
lint-junk:
343
	@if bzr ls --recursive --versioned | egrep '[.]moved$$'; then \
344
	    echo "^ Junk found. Please remove it from the tree." >&2 ; fi
345
2177.3.2 by jtv at canonical
Add ‘format’ target to Makefile.
346
# Apply automated formatting to all Python files.
347
format: sources = $(wildcard *.py contrib/*.py) src templates twisted utilities etc
348
format:
3686.1.1 by Gavin Panella
Lint-check standalone reST docs.
349
	@find $(sources) -name '*.py' -print0 | xargs -r0 utilities/format-imports
2177.3.2 by jtv at canonical
Add ‘format’ target to Makefile.
350
4000.2.1 by Gavin Panella
Convenient Makefile target to update copyright headers.
351
# Update copyright dates from version history. Try to avoid updating
352
# 3rd-party code by checking for "Canonical" or "MAAS" on the same line
353
# as the copyright header.
354
copyright:
355
	@bzr ls --versioned --recursive --kind=file --null | \
356
	    xargs -r0 egrep -iI 'copyright.*(canonical|maas)' -lZ | \
357
	    xargs -r0 bzr update-copyright --quiet --force-range
358
620.1.2 by Gavin Panella
Fix dependencies in Makefile.
359
check: clean test
1 by Raphael Badin
Initial commit.
360
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
361
docs/api.rst: bin/maas-region src/maasserver/api/doc_handler.py syncdb
362
	bin/maas-region generate_api_doc > $@
21.1.3 by Raphael Badin
Generate static doc.
363
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
364
sampledata: bin/maas-region bin/database syncdb
365
	$(dbrun) bin/maas-region generate_sample_data
32.5.2 by Raphael Badin
Add doc.
366
32.1.2 by Gavin Panella
Use distribute with buildout; fix dependencies around docs; fix clean and distclean.
367
doc: bin/sphinx docs/api.rst
31.1.1 by Raphael Badin
Use sphinx's recipe.
368
	bin/sphinx
21.1.3 by Raphael Badin
Generate static doc.
369
4257.1.2 by Mike Pontillo
Add networking.rst to docs. Drive-by Makefile change to build and open docs, and support-dump script to output interface types and IDs
370
docs/_build/html/index.html: doc
371
372
doc-browse: docs/_build/html/index.html
373
	sensible-browser $< > /dev/null 2>&1 &
374
2285.1.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.
375
doc-with-versions: bin/sphinx docs/api.rst
3790.2.5 by Gavin Panella
A few more tweaks.
376
	$(MAKE) -C docs/_build SPHINXOPTS="-A add_version_switcher=true" html
2231.1.2 by Raphael Badin
Add versions Javascript file.
377
1293.5.5 by Gavin Panella
Build the maas-cli.8 man page.
378
man: $(patsubst docs/man/%.rst,man/%,$(wildcard docs/man/*.rst))
379
380
man/%: docs/man/%.rst | bin/sphinx-build
381
	bin/sphinx-build -b man docs man $^
382
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
383
.run .run-e2e: run-skel
5848.1.1 by Gavin Panella
buildout.cfg refers to .run and .run-e2e, so model that dependency.
384
	@cp --archive --verbose $^ $@
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
385
544.1.1 by Gavin Panella
Simplify convert-enums by working with files only, not trying to do module jiggery pokery.
386
enums: $(js_enums)
387
686.1.1 by Gavin Panella
Fix Makefile.
388
$(js_enums): bin/py src/maasserver/utils/jsenums.py $(py_enums)
4489.5.113 by Gavin Panella
Fix building of jsenums.
389
	bin/py -m maasserver.utils.jsenums $(py_enums) > $@
532.1.1 by Jeroen Vermeulen
Script to generate JavaScript enums from our Python enums.
390
5112.3.6 by Richard McCartney
Updating the makefile
391
styles: clean-styles $(scss_output)
5112.3.4 by Gavin Panella
Get the Makefile building with cloud-vanilla-theme.
392
5683.4.2 by Gavin Panella
Fix building of styles to not clobber stuff.
393
$(scss_output): bin/sass $(scss_theme) $(scss_input) $(scss_deps)
5112.3.4 by Gavin Panella
Get the Makefile building with cloud-vanilla-theme.
394
	bin/sass --include-path=src/maasserver/static/scss \
5683.4.2 by Gavin Panella
Fix building of styles to not clobber stuff.
395
	    --output-style compressed $(scss_input) -o $(dir $@)
5112.3.4 by Gavin Panella
Get the Makefile building with cloud-vanilla-theme.
396
397
$(scss_theme): prefix = include/nodejs
398
$(scss_theme):
5819.6.1 by Richard McCartney
Applying fix for mobile navigation
399
	$(npm_install) --prefix $(prefix) maas-gui-vanilla-theme@1.2.7
3429.2.2 by Blake Rouse
Add make rule for generation of scss to css. Add watcher for modified scss in the reloader to ease development.
400
5112.3.6 by Richard McCartney
Updating the makefile
401
clean-styles:
402
	$(RM) $(scss_output)
403
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
404
clean: stop clean-failed
532.1.3 by Jeroen Vermeulen
Generate JS versions of our python enums.
405
	find . -type f -name '*.py[co]' -print0 | xargs -r0 $(RM)
4489.5.33 by Gavin Panella
Also clean __pycache__ directories.
406
	find . -type d -name '__pycache__' -print0 | xargs -r0 $(RM) -r
532.1.3 by Jeroen Vermeulen
Generate JS versions of our python enums.
407
	find . -type f -name '*~' -print0 | xargs -r0 $(RM)
1352.2.5 by Gavin Panella
Clean more stuff in clean, rather than distclean.
408
	find . -type f -name dropin.cache -print0 | xargs -r0 $(RM)
5654.1.17 by Gavin Panella
Misc. tidy-ups.
409
	$(RM) -r media/demo/* media/development media/development.*
4489.5.86 by Gavin Panella
Don't leave js_enums half built.
410
	$(RM) $(js_enums) $(js_enums).tmp
4596.1.19 by Mike Pontillo
Merge trunk.
411
	$(RM) src/maasserver/data/templates.py
546.2.6 by Raphael Badin
Ignore *.log.
412
	$(RM) *.log
674.1.5 by Gavin Panella
Use autosummary for enums too.
413
	$(RM) docs/api.rst
1352.2.5 by Gavin Panella
Clean more stuff in clean, rather than distclean.
414
	$(RM) -r docs/_autosummary docs/_build
1366.1.1 by Gavin Panella
Store generated man pages in the tree.
415
	$(RM) -r man/.doctrees
5843.3.1 by Gavin Panella
Collect coverage data when running tests in parallel.
416
	$(RM) .coverage .coverage.* coverage.xml
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
417
	$(RM) -r coverage
3790.2.1 by Gavin Panella
Fix some little Makefile things.
418
	$(RM) -r .hypothesis
634.3.3 by Gavin Panella
Use virtualenv/pip to bootstrap zc.buildout, instead of buildout's buggy bootstrap.py.
419
	$(RM) -r bin include lib local
9.1.2 by Gavin Panella
Update clean and distclean targets.
420
	$(RM) -r eggs develop-eggs
634.3.3 by Gavin Panella
Use virtualenv/pip to bootstrap zc.buildout, instead of buildout's buggy bootstrap.py.
421
	$(RM) -r build dist logs/* parts
9.1.2 by Gavin Panella
Update clean and distclean targets.
422
	$(RM) tags TAGS .installed.cfg
38.2.4 by Gavin Panella
Ignore ./dist and remove src/*.egg-info.
423
	$(RM) -r *.egg *.egg-info src/*.egg-info
3608.6.50 by Gavin Panella
Be selective about what to remove from run and run-e2e.
424
	$(RM) -r services/*/supervise
5669.2.1 by Gavin Panella
Get rid of run and run-e2e. Instead, create each as needed from run-skel.
425
	$(RM) -r .run .run-e2e
5240.5.1 by Gavin Panella
Ignore XUnit files and .failed, and clean them too.
426
	$(RM) xunit.*.xml
427
	$(RM) .failed
3608.6.50 by Gavin Panella
Be selective about what to remove from run and run-e2e.
428
3892.1.2 by Mike Pontillo
Address review comments
429
clean+db: clean
4620.2.4 by Gavin Panella
Keep trying to terminate the database.
430
	while fuser db --kill -TERM; do sleep 1; done
3739.1.1 by Mike Pontillo
Add distclean+db convenience target
431
	$(RM) -r db
3790.2.1 by Gavin Panella
Fix some little Makefile things.
432
	$(RM) .db.lock
3739.1.1 by Mike Pontillo
Add distclean+db convenience target
433
3892.1.3 by Mike Pontillo
distclean should depend on clean
434
distclean: clean
3892.1.2 by Mike Pontillo
Address review comments
435
	$(warning 'distclean' is deprecated; use 'clean')
436
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
437
harness: bin/maas-region bin/database
5550.2.1 by Gavin Panella
Try to remove src/maas.
438
	$(dbrun) bin/maas-region shell \
439
	  --settings=maasserver.djangosettings.demo
47.4.1 by Gavin Panella
Rename the django recipe to maas.
440
510.4.20 by Gavin Panella
New buildout target for bin/database.
441
dbharness: bin/database
510.4.63 by Gavin Panella
Default the database to maas, and use bin/database run when mutating the database.
442
	bin/database --preserve shell
510.4.13 by Gavin Panella
New dbharness target.
443
4736.1.2 by Andres Rodriguez
Change references of maas-region-admin to maas-region
444
syncdb: bin/maas-region bin/database
445
	$(dbrun) bin/maas-region dbupgrade
2920.8.1 by jtv at canonical
Add schema caching. Makes tests start up faster.
446
149.6.30 by Gavin Panella
Reorganize Makefile.
447
define phony_targets
448
  build
449
  check
450
  clean
4000.2.1 by Gavin Panella
Convenient Makefile target to update copyright headers.
451
  clean+db
5266.1.1 by LaMont Jones
Add clean-failed and test-failed targets.
452
  clean-failed
5112.3.6 by Richard McCartney
Updating the makefile
453
  clean-styles
3917.1.1 by Mike Pontillo
Automatically configure buildout cache
454
  configure-buildout
4000.2.1 by Gavin Panella
Convenient Makefile target to update copyright headers.
455
  copyright
3572.2.3 by Mike Pontillo
Add Gavin's changes to support code-coverage
456
  coverage-report
510.4.13 by Gavin Panella
New dbharness target.
457
  dbharness
3892.1.4 by Mike Pontillo
Add distclean back to phony
458
  distclean
149.6.30 by Gavin Panella
Reorganize Makefile.
459
  doc
4257.1.2 by Mike Pontillo
Add networking.rst to docs. Drive-by Makefile change to build and open docs, and support-dump script to output interface types and IDs
460
  doc-browse
532.1.1 by Jeroen Vermeulen
Script to generate JavaScript enums from our Python enums.
461
  enums
2177.3.2 by jtv at canonical
Add ‘format’ target to Makefile.
462
  format
149.6.30 by Gavin Panella
Reorganize Makefile.
463
  harness
794.1.2 by Gavin Panella
Move install_dependencies towards to the top of the Makefile, make it display the full command line when executing, rename it install-dependencies to match a couple of existing targets, and mark it as phony.
464
  install-dependencies
149.6.30 by Gavin Panella
Reorganize Makefile.
465
  lint
466
  lint-css
2009.1.1 by jtv at canonical
Add lint check for trailing spaces in documentation. Make JS and documentation lint checks part of “make lint”.
467
  lint-doc
149.6.30 by Gavin Panella
Reorganize Makefile.
468
  lint-js
5682.1.1 by Gavin Panella
Check for .moved files.
469
  lint-junk
2177.3.1 by jtv at canonical
Move Python linting into its own target, lint-py.
470
  lint-py
5457.1.3 by Gavin Panella
Check McCabe complexity.
471
  lint-py-complexity
4670.1.3 by Gavin Panella
Hook check-imports into Makefile.
472
  lint-py-imports
3926.1.1 by Mike Pontillo
Fix Makefile dependencies
473
  lint-rst
4942.1.12 by Mike Pontillo
Add make target to test with an LXD conainer.
474
  lxd
1293.5.5 by Gavin Panella
Build the maas-cli.8 man page.
475
  man
4596.1.12 by Mike Pontillo
Makefile cleanup. Fix minor bugs in template data creation script.
476
  print-%
149.6.30 by Gavin Panella
Reorganize Makefile.
477
  sampledata
5272.1.1 by Gavin Panella
New smoke target for gated landings.
478
  smoke
3429.2.2 by Blake Rouse
Add make rule for generation of scss to css. Add watcher for modified scss in the reloader to ease development.
479
  styles
5349.4.16 by Mike Pontillo
Drive-by addition of 'make sudoers' target, to make it easy to re-add any necessary sudoers entries for MAAS development.
480
  sudoers
149.6.30 by Gavin Panella
Reorganize Makefile.
481
  syncdb
482
  test
5272.1.1 by Gavin Panella
New smoke target for gated landings.
483
  test+lxd
5266.1.1 by LaMont Jones
Add clean-failed and test-failed targets.
484
  test-failed
5159.3.31 by Gavin Panella
Add initial test data to speed things up.
485
  test-initial-data
5684.3.2 by Gavin Panella
Make the default test target do parallel testing.
486
  test-serial
487
  test-serial+coverage
149.6.30 by Gavin Panella
Reorganize Makefile.
488
endef
489
490
#
491
# Development services.
492
#
493
3523.1.1 by Blake Rouse
Remove apache2 from the developer environment and redirect / to /MAAS/.
494
service_names_region := database dns regiond regiond2 reloader
4633.3.1 by Gavin Panella
More renames from cluster to rack.
495
service_names_rack := rackd reloader
496
service_names_all := $(service_names_region) $(service_names_rack)
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
497
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
498
# The following template is intended to be used with `call`, and it
499
# accepts a single argument: a target name. The target name must
4633.3.1 by Gavin Panella
More renames from cluster to rack.
500
# correspond to a service action (see "Pseudo-magic targets" below). A
501
# region- and rack-specific variant of the target will be created, in
502
# addition to the target itself. These can be used to apply the service
503
# action to the region services, the rack services, or all services, at
504
# the same time.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
505
define service_template
506
$(1)-region: $(patsubst %,services/%/@$(1),$(service_names_region))
4633.3.1 by Gavin Panella
More renames from cluster to rack.
507
$(1)-rack: $(patsubst %,services/%/@$(1),$(service_names_rack))
508
$(1): $(1)-region $(1)-rack
509
phony_services_targets += $(1)-region $(1)-rack $(1)
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
510
endef
511
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
512
# Expand out aggregate service targets using `service_template`.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
513
$(eval $(call service_template,pause))
514
$(eval $(call service_template,restart))
515
$(eval $(call service_template,start))
516
$(eval $(call service_template,status))
517
$(eval $(call service_template,stop))
518
$(eval $(call service_template,supervise))
519
979.3.2 by Gavin Panella
Document the weird new Makefile stuff.
520
# The `run` targets do not fit into the mould of the others.
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
521
run-region:
3074.1.15 by Gavin Panella
Always export MAAS_ROOT=./run in Makefile.
522
	@services/run $(service_names_region)
4633.3.1 by Gavin Panella
More renames from cluster to rack.
523
run-rack:
524
	@services/run $(service_names_rack)
1044.2.1 by Gavin Panella
Get the run target to run everything.
525
run:
3074.1.15 by Gavin Panella
Always export MAAS_ROOT=./run in Makefile.
526
	@services/run $(service_names_all)
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
527
4633.3.1 by Gavin Panella
More renames from cluster to rack.
528
phony_services_targets += run-region run-rack run
149.6.45 by Gavin Panella
Add new target, run+web, to run the web service in the foreground.
529
3326.4.59 by Gavin Panella
Add regiond2 service for load-balancing.
530
# This one's for the rapper, yo. Don't run the load-balancing regiond2.
3326.4.17 by Gavin Panella
Rename webapp to regiond and pserv to clusterd.
531
run+regiond:
3326.4.59 by Gavin Panella
Add regiond2 service for load-balancing.
532
	@services/run $(filter-out regiond2,$(service_names_region)) +regiond
979.3.1 by Gavin Panella
Add <action>-region and <action>-cluster targets.
533
3326.4.17 by Gavin Panella
Rename webapp to regiond and pserv to clusterd.
534
phony_services_targets += run+regiond
149.6.30 by Gavin Panella
Reorganize Makefile.
535
511.1.2 by Gavin Panella
Also check for setlock.
536
# Convenient variables and functions for service control.
149.6.32 by Gavin Panella
Add +services/%/@run target.
537
511.1.2 by Gavin Panella
Also check for setlock.
538
setlock = $(call available,setlock,daemontools)
511.1.1 by Gavin Panella
Check availability of daemontools.
539
supervise = $(call available,supervise,daemontools)
540
svc = $(call available,svc,daemontools)
541
svok = $(call available,svok,daemontools)
542
svstat = $(call available,svstat,daemontools)
543
511.1.2 by Gavin Panella
Also check for setlock.
544
service_lock = $(setlock) -n /run/lock/maas.dev.$(firstword $(1))
545
546
# Pseudo-magic targets for controlling individual services.
149.6.39 by Gavin Panella
Lock when running or supervising.
547
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
548
services/%/@run: services/%/@stop services/%/@deps
149.6.39 by Gavin Panella
Lock when running or supervising.
549
	@$(call service_lock, $*) services/$*/run
149.6.32 by Gavin Panella
Add +services/%/@run target.
550
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
551
services/%/@start: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
552
	@$(svc) -u $(@D)
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
553
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
554
services/%/@pause: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
555
	@$(svc) -d $(@D)
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
556
149.6.34 by Gavin Panella
More reorg.
557
services/%/@status:
511.1.1 by Gavin Panella
Check availability of daemontools.
558
	@$(svstat) $(@D)
149.6.34 by Gavin Panella
More reorg.
559
149.6.35 by Gavin Panella
Add restart target.
560
services/%/@restart: services/%/@supervise
511.1.1 by Gavin Panella
Check availability of daemontools.
561
	@$(svc) -du $(@D)
149.6.35 by Gavin Panella
Add restart target.
562
499.1.1 by Gavin Panella
Rename stop to pause, shutdown to stop.
563
services/%/@stop:
511.1.1 by Gavin Panella
Check availability of daemontools.
564
	@if $(svok) $(@D); then $(svc) -dx $(@D); fi
565
	@while $(svok) $(@D); do sleep 0.1; done
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
566
149.6.34 by Gavin Panella
More reorg.
567
services/%/@supervise: services/%/@deps
568
	@mkdir -p logs/$*
569
	@touch $(@D)/down
511.1.1 by Gavin Panella
Check availability of daemontools.
570
	@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.
571
	    logdir=$(CURDIR)/logs/$* \
511.1.1 by Gavin Panella
Check availability of daemontools.
572
	        $(call service_lock, $*) $(supervise) $(@D) & fi
573
	@while ! $(svok) $(@D); do sleep 0.1; done
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
574
149.6.32 by Gavin Panella
Add +services/%/@run target.
575
# Dependencies for individual services.
576
720.2.11 by Raphael Badin
Fixes as per review.
577
services/dns/@deps: bin/py
720.2.1 by Raphael Badin
Add dns service.
578
510.4.20 by Gavin Panella
New buildout target for bin/database.
579
services/database/@deps: bin/database
510.4.5 by Gavin Panella
Start and stop the database as a service.
580
5669.4.2 by Gavin Panella
Both regiond and rackd services depend on bin/maas-rack.
581
services/rackd/@deps: bin/twistd.rack bin/maas-rack
149.6.5 by Gavin Panella
Reliable start/stop control for development daemons.
582
149.6.44 by Gavin Panella
The reloader doesn't depend on web and pserv.
583
services/reloader/@deps:
149.6.14 by Gavin Panella
Add the reloader service to Makefile.
584
5669.4.2 by Gavin Panella
Both regiond and rackd services depend on bin/maas-rack.
585
services/regiond/@deps: bin/maas-region bin/maas-rack
561.2.1 by Raphael Badin
Add celeryd to the list of available services.
586
5669.4.2 by Gavin Panella
Both regiond and rackd services depend on bin/maas-rack.
587
services/regiond2/@deps: bin/maas-region bin/maas-rack
3326.4.59 by Gavin Panella
Add regiond2 service for load-balancing.
588
149.6.30 by Gavin Panella
Reorganize Makefile.
589
#
1970.2.1 by Julian Edwards
experimental package building
590
# Package building
591
#
3790.2.1 by Gavin Panella
Fix some little Makefile things.
592
1970.2.2 by Julian Edwards
Gavin's Makefile foo put to use
593
# This ought to be as simple as using bzr builddeb --export-upstream but it
1970.2.1 by Julian Edwards
experimental package building
594
# has a bug and always considers apt-source tarballs before the specified
3790.2.1 by Gavin Panella
Fix some little Makefile things.
595
# branch. Instead, export to a local tarball which is always found. Make sure
596
# the packages listed in `required-packages/build` are installed before using
597
# this.
598
599
# Old names.
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
600
PACKAGING := $(abspath ../packaging.trunk)
1970.2.4 by Julian Edwards
Really make package building work
601
PACKAGING_BRANCH := lp:~maas-maintainers/maas/packaging
602
3790.2.1 by Gavin Panella
Fix some little Makefile things.
603
packaging-tree = $(PACKAGING)
604
packaging-branch = $(PACKAGING_BRANCH)
605
606
packaging-build-area := $(abspath ../build-area)
607
packaging-version = $(shell \
3790.2.4 by Gavin Panella
One more use of PACKAGING.
608
   dpkg-parsechangelog -l$(packaging-tree)/debian/changelog \
3790.2.1 by Gavin Panella
Fix some little Makefile things.
609
       | sed -rne 's,^Version: ([^-]+).*,\1,p')
610
611
$(packaging-build-area):
612
	mkdir -p $(packaging-build-area)
613
614
-packaging-fetch:
615
	bzr branch $(packaging-branch) $(packaging-tree)
616
617
-packaging-pull:
5070.3.18 by Lee Trager
Merge trunk
618
	bzr pull -d $(packaging-tree)
3790.2.1 by Gavin Panella
Fix some little Makefile things.
619
620
-packaging-refresh: -packaging-$(shell \
621
    test -d $(packaging-tree) && echo "pull" || echo "fetch")
622
623
-packaging-export-orig: $(packaging-build-area)
624
	bzr export $(packaging-export-extra) --root=maas-$(packaging-version).orig \
625
	    $(packaging-build-area)/maas_$(packaging-version).orig.tar.gz
626
627
# To build binary packages from uncommitted changes:
628
#     make package-export-extra=--uncommitted package
629
package: -packaging-refresh -packaging-export-orig
630
	bzr bd --merge $(packaging-tree) --result-dir=$(packaging-build-area) -- -uc -us
631
	@echo Binary packages built, see $(packaging-build-area).
632
633
# ... or use the `package-dev` target.
634
package-dev: packaging-export-extra = --uncommitted
3768.1.3 by Mike Pontillo
Rename dev_package target to package-dev (per review comments)
635
package-dev: package
3768.1.1 by Mike Pontillo
Add a make target to create a dev package (one that contains uncommitted code as well as committed.)
636
3790.2.1 by Gavin Panella
Fix some little Makefile things.
637
# To build a source package from uncommitted changes:
638
#     make package-export-extra=--uncommitted source-package
639
source-package: -packaging-refresh -packaging-export-orig
640
	bzr bd --merge $(packaging-tree) --result-dir=$(packaging-build-area) -- -S -uc -us
641
	@echo Source package built, see $(packaging-build-area).
642
643
# ... or use the `source-package-dev` target.
644
source-package-dev: packaging-export-extra = --uncommitted
645
source-package-dev: source-package
646
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
647
# To rebuild packages (i.e. from a clean slate):
648
package-rebuild: package-clean package
649
650
package-dev-rebuild: package-clean package-dev
651
652
source-package-rebuild: source-package-clean source-package
653
654
source-package-dev-rebuild: source-package-clean source-package-dev
655
656
# To clean built packages away:
5234.2.1 by Gavin Panella
Clean generated udebs from build-area too.
657
package-clean: patterns := *.deb *.udeb *.dsc *.build *.changes
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
658
package-clean: patterns += *.debian.tar.xz *.orig.tar.gz
659
package-clean:
660
	@$(RM) -v $(addprefix $(packaging-build-area)/,$(patterns))
661
662
source-package-clean: patterns := *.dsc *.build *.changes
663
source-package-clean: patterns += *.debian.tar.xz *.orig.tar.gz
664
source-package-clean:
665
	@$(RM) -v $(addprefix $(packaging-build-area)/,$(patterns))
666
5484.9.5 by Blake Rouse
Add snap targets to Makefile. Generate version in snapcraft.yaml on the fly. Fix snap-ctl to change the mode, auto select the best IP address for the maas_url on install.
667
4596.1.12 by Mike Pontillo
Makefile cleanup. Fix minor bugs in template data creation script.
668
# Debugging target. Allows printing of any variable.
669
# As an example, try:
670
#     make print-js_enums
671
print-%:
672
	@echo $* = $($*)
673
3790.2.1 by Gavin Panella
Fix some little Makefile things.
674
define phony_package_targets
675
  -packaging-export-orig
676
  -packaging-fetch
677
  -packaging-pull
678
  -packaging-refresh
679
  package
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
680
  package-clean
3790.2.1 by Gavin Panella
Fix some little Makefile things.
681
  package-dev
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
682
  package-dev-rebuild
683
  package-rebuild
3790.2.1 by Gavin Panella
Fix some little Makefile things.
684
  source-package
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
685
  source-package-clean
3790.2.1 by Gavin Panella
Fix some little Makefile things.
686
  source-package-dev
3790.2.3 by Gavin Panella
Package rebuild and clean targets, originally by Mike Pontillo.
687
  source-package-dev-rebuild
688
  source-package-rebuild
3790.2.1 by Gavin Panella
Fix some little Makefile things.
689
endef
1970.2.1 by Julian Edwards
experimental package building
690
691
#
5484.9.5 by Blake Rouse
Add snap targets to Makefile. Generate version in snapcraft.yaml on the fly. Fix snap-ctl to change the mode, auto select the best IP address for the maas_url on install.
692
# Snap building
693
#
694
695
snap-clean:
696
	snapcraft clean
5937.1.1 by Blake Rouse
Append the version of the snap using a plugin instead of the Makefile. This allows launchpad to build the snap with the version append.
697
698
snap:
5484.9.5 by Blake Rouse
Add snap targets to Makefile. Generate version in snapcraft.yaml on the fly. Fix snap-ctl to change the mode, auto select the best IP address for the maas_url on install.
699
	snapcraft
700
5937.1.1 by Blake Rouse
Append the version of the snap using a plugin instead of the Makefile. This allows launchpad to build the snap with the version append.
701
snap-cleanbuild:
5484.9.5 by Blake Rouse
Add snap targets to Makefile. Generate version in snapcraft.yaml on the fly. Fix snap-ctl to change the mode, auto select the best IP address for the maas_url on install.
702
	snapcraft cleanbuild
703
704
define phony_snap_targets
705
	snap
706
	snap-clean
707
	snap-cleanbuild
708
endef
709
710
#
149.6.30 by Gavin Panella
Reorganize Makefile.
711
# Phony stuff.
712
#
713
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
714
define phony
3790.2.1 by Gavin Panella
Fix some little Makefile things.
715
  $(phony_package_targets)
5484.9.9 by Blake Rouse
Fix Makefile.
716
  $(phony_services_targets)
5484.9.5 by Blake Rouse
Add snap targets to Makefile. Generate version in snapcraft.yaml on the fly. Fix snap-ctl to change the mode, auto select the best IP address for the maas_url on install.
717
  $(phony_snap_targets)
149.6.30 by Gavin Panella
Reorganize Makefile.
718
  $(phony_targets)
473.2.5 by Gavin Panella
Add lint-js and lint-css targets to Makefile.
719
endef
720
149.6.30 by Gavin Panella
Reorganize Makefile.
721
phony := $(sort $(strip $(phony)))
722
4678.2.2 by Gavin Panella
Update imports and other references to formerly bundled code.
723
.PHONY: $(phony) FORCE
511.1.1 by Gavin Panella
Check availability of daemontools.
724
725
#
5733.2.1 by Gavin Panella
Declare secondary targets to avoid some unnecessary work.
726
# Secondary stuff.
727
#
728
# These are intermediate files that we want to keep around in the event
729
# that they get built. By declaring them here we're also telling Make
730
# that their absense is okay if a rule target is newer than the rule's
731
# other prerequisites; i.e. don't build them.
732
#
733
# For example, converting foo.scss to foo.css might require bin/sass. If
734
# foo.css is newer than foo.scss we know that we don't need to perform
735
# that conversion, and hence don't need bin/sass. We declare bin/sass as
736
# secondary so that Make knows this too.
737
#
738
739
define secondary
740
  bin/py bin/buildout
741
  bin/sass $(scss_theme)
742
  bin/sphinx bin/sphinx-build
743
endef
744
745
.SECONDARY: $(sort $(strip $(secondary)))
746
747
#
511.1.1 by Gavin Panella
Check availability of daemontools.
748
# Functions.
749
#
750
751
# Check if a command is found on PATH. Raise an error if not, citing
752
# the package to install. Return the command otherwise.
753
# Usage: $(call available,<command>,<package>)
754
define available
511.1.4 by Gavin Panella
Make the error message from 'available' more explicit.
755
  $(if $(shell which $(1)),$(1),$(error $(1) not found; \
756
    install it with 'sudo apt-get install $(2)'))
511.1.1 by Gavin Panella
Check availability of daemontools.
757
endef