~fabricematrat/charmworld/redirect-charm

348.4.1 by Benji York
checkpoint
1
# Makefile debugging hack: uncomment the two lines below and make will tell you
2
# more about what is happening.  The output generated is of the form
3
# "FILE:LINE [TARGET (DEPENDENCIES) (NEWER)]" where DEPENDENCIES are all the
4
# things TARGET depends on and NEWER are all the files that are newer than
5
# TARGET.  DEPENDENCIES will be colored green and NEWER will be blue.
6
#OLD_SHELL := $(SHELL)
7
#SHELL = $(warning [$@ ($^) ($?) ])$(OLD_SHELL)
8
66.1.2 by Rick Harding
Updated to get a make install/make run to work
9
WD := $(shell pwd)
84.1.12 by j.c.sackett
Put cache back to proper target, now w'ere done with monkeying.
10
CACHE := download-cache/dist
120.1.6 by Rick Harding
Garden
11
CSS_PATH := charmworld/static/css
66.1.2 by Rick Harding
Updated to get a make install/make run to work
12
PSERVE := bin/pserve
13
SYSTEM_DEPS := \
416.3.1 by Rick Harding
Update deps
14
	build-essential bzr libyaml-dev python-dev python-virtualenv\
418.1.9 by Rick Harding
Restore npm as a dep to get CI to work
15
	subversion nodejs npm
66.1.2 by Rick Harding
Updated to get a make install/make run to work
16
120.1.5 by Rick Harding
clean up makefile paths a bit for easier reading
17
66.1.2 by Rick Harding
Updated to get a make install/make run to work
18
# Default ini file to use for all scripted commands. Can be overridden by
19
# specifying  INI=development.ini
20
INI = charmworld.ini
21
22
# INI is the default ini file used for all work. By default we want to copy a
23
# sample.ini and generate a single charmworld.ini used.
115.4.1 by Abel Deuring
Use a config file default.ini file; override test specific settings in a separate file test-setup.ini; allow to override the seetings from default.ini in a file custom.ini.
24
25
ifeq ($(wildcard custom.ini), )
26
	CONFIG_DEPS = default.ini
27
else
28
	CONFIG_DEPS = default.ini custom.ini
29
endif
30
31
32
$(INI): $(CONFIG_DEPS)
33
	scripts/config $(INI) $(CONFIG_DEPS)
34
35
test.ini: default.ini test-setup.ini
36
	scripts/config test.ini default.ini test-setup.ini
66.1.2 by Rick Harding
Updated to get a make install/make run to work
37
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
38
# ###############
39
# INSTALL targets
40
# ###############
84.3.7 by Rick Harding
Pull from upstream to get new build setup working
41
348.4.2 by Benji York
Spruce up the Makefile.
42
bin/pip:
43
	virtualenv .
44
45
bin/python:
46
	virtualenv .
47
48
# We use a "canary" file to tell us if the charmworld package has been
49
# installed in "develop" mode.
50
DEVELOP_CANARY := lib/__develop_canary
384.1.1 by Brad Crittenden
Change 'bundles' in URLs to 'bundle'.
51
develop: $(DEVELOP_CANARY)
348.4.2 by Benji York
Spruce up the Makefile.
52
$(DEVELOP_CANARY): | bin/python
53
	bin/python setup.py develop
54
	touch $(DEVELOP_CANARY)
55
56
install: deps bin/python bin/pip $(INI) develop css bin/test
57
58
bin/es-update: bin/python
59
	bin/python setup.py develop
221.2.16 by Aaron Bentley
Add makefile targets to ensure ES is initialized.
60
84.1.20 by j.c.sackett
Updated rules/targets.
61
clean_venv:
348.4.1 by Benji York
checkpoint
62
	rm -rf bin include lib local
84.1.20 by j.c.sackett
Updated rules/targets.
63
64
sysdeps:
407.1.1 by Aaron Bentley
Add python-software-properties so add-apt-repository works.
65
	sudo apt-get update
407.1.2 by Aaron Bentley
Force 'yes' for apt-get install.
66
	sudo apt-get install --yes python-software-properties
124.1.1 by j.c.sackett
Makefile adds juju ppa for updated charm-tools.
67
	sudo add-apt-repository -y ppa:juju/pkgs
169.2.3 by Aaron Bentley
Implement indexing in terms of elasticsearch.
68
	sudo add-apt-repository -y ppa:ce-orange-squad/experimental
124.1.1 by j.c.sackett
Makefile adds juju ppa for updated charm-tools.
69
	sudo apt-get update
348.4.1 by Benji York
checkpoint
70
	sudo apt-get install -y $(SYSTEM_DEPS) mongodb-server \
71
	    elasticsearch-java;
126.1.1 by Rick Harding
Make sure the symlink can fail no non-quantal systems if already exists
72
	# On quantal need to provide node bin for deps to work.
184.1.1 by Curtis Hovey
Do not create a link if node already exists.
73
	if test ! -e /usr/bin/node; \
436.2.2 by Brad Crittenden
Use charm-tools proof for bundles.
74
	    then sudo ln -s /usr/bin/nodejs /usr/bin/node; \
184.1.1 by Curtis Hovey
Do not create a link if node already exists.
75
	fi
97.1.1 by Aaron Bentley
Tweak scripts, makefile to support charm.
76
77
deploy_sysdeps:
78
	sudo apt-get install -y $(SYSTEM_DEPS) mongodb-clients;
84.1.20 by j.c.sackett
Updated rules/targets.
79
348.4.2 by Benji York
Spruce up the Makefile.
80
# We use a "canary" file to tell us if the Python packages have been installed.
348.4.1 by Benji York
checkpoint
81
PYTHON_PACKAGE_CANARY := lib/python2.7/site-packages/___canary
82
python-deps: $(PYTHON_PACKAGE_CANARY)
348.4.2 by Benji York
Spruce up the Makefile.
83
$(PYTHON_PACKAGE_CANARY): requirements.txt | bin/pip
348.4.1 by Benji York
checkpoint
84
	if test -d download-cache; \
411.2.3 by Abel Deuring
Makefile bug fixed.
85
	    then bzr up download-cache; \
348.4.1 by Benji York
checkpoint
86
	    else bzr checkout lp:~juju-jitsu/charmworld/download-cache; \
87
	fi
348.4.2 by Benji York
Spruce up the Makefile.
88
	bin/pip install --no-index --no-dependencies --find-links \
348.4.1 by Benji York
checkpoint
89
	    file:///$(WD)/$(CACHE) -r requirements.txt
348.4.2 by Benji York
Spruce up the Makefile.
90
	touch $(PYTHON_PACKAGE_CANARY)
348.4.1 by Benji York
checkpoint
91
348.4.2 by Benji York
Spruce up the Makefile.
92
# We use a "canary" file to tell us if the Node packages have been installed.
93
NODE_CANARY := node_modules/___canary
94
node-deps: $(NODE_CANARY)
95
$(NODE_CANARY):
120.1.7 by Rick Harding
Update makefile per review
96
	npm install download-cache/npm/ycssmin.tar.gz
97
	npm install download-cache/npm/less.tar.gz
348.4.1 by Benji York
checkpoint
98
	rm -rf build
348.4.2 by Benji York
Spruce up the Makefile.
99
	rm -rf share
100
	touch $(NODE_CANARY)
101
102
deps: python-deps node-deps
348.4.1 by Benji York
checkpoint
103
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
104
105
# ###################
66.1.2 by Rick Harding
Updated to get a make install/make run to work
106
# Development helpers
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
107
# ###################
108
348.4.1 by Benji York
checkpoint
109
bin/nosetests: python-deps
110
111
bin/test: | test.ini $(INI) bin/nosetests
387.1.1 by Benji York
checkpoint
112
	ln scripts/test bin/test
348.4.1 by Benji York
checkpoint
113
387.1.1 by Benji York
checkpoint
114
test: install bin/test
348.4.2 by Benji York
Spruce up the Makefile.
115
	bin/test
348.4.1 by Benji York
checkpoint
116
387.1.1 by Benji York
checkpoint
117
testid: install bin/test
310.1.1 by Brad Crittenden
Use Charm model objects rather than dicts.
118
	# Run specific nose id tests.
119
	# To set up the index you must run `make testid` once to completion to
120
	# setup the index.  Then you can run a group of tests like:
121
	# Call with `ID="3 5" make testid`
348.4.1 by Benji York
checkpoint
122
	bin/test -v -s -x --with-id $(ID) charmworld
100.1.4 by Rick Harding
Add a make target shortcut, not sure how to handle this currently
123
348.4.1 by Benji York
checkpoint
124
testdebug: bin/test
419.1.1 by Brad Crittenden
Replace all uses of datetime.now(), which is timezone aware, with utcnow(), which is not. Also fix the 'testdebug' makefile target.
125
	bin/test --pdb --pdb-failures charmworld
88.2.5 by j.c.sackett
Added testdebug target to allow pdb introspection of failures.
126
411.1.4 by Brad Crittenden
Added lint to 'make check'.
127
check: clear_ini clean sysdeps install lint testid
72.3.1 by Rick Harding
Add sphinx docs, makefile helpers, and initial install/setup/todo pages.
128
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
129
lint: sources = setup.py charmworld
385.2.2 by Benji York
make bundle requests that include an owner work for non-promulgated bundles
130
lint: install
482.1.1 by Brad Crittenden
Turn on lint for migrations and fix
131
	@find $(sources) -name '*.py' \
153.1.24 by Aaron Bentley
Update lint.
132
	    -! -path 'charmworld/teams.py' ! -print0 | xargs -r0 \
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
133
		bin/flake8 --ignore=E125,E127
134
135
# Generate ctags for the code in the project.
136
tags:
71.1.4 by Rick Harding
Garden bzrignore to have trailing /
137
	ctags --tag-relative --python-kinds=-iv -Rf tags --sort=yes --exclude=.bzr --languages=python
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
138
87.2.2 by Rick Harding
Update docs to render, upload to people. and update doc-open to load live docs
139
doc: bin/sphinx-build
140
	bin/sphinx-build docs docs/_build/html
72.3.1 by Rick Harding
Add sphinx docs, makefile helpers, and initial install/setup/todo pages.
141
142
doc-open: doc
87.2.3 by Rick Harding
Update docs, some place holders
143
	xdg-open docs/_build/html/index.html
87.2.2 by Rick Harding
Update docs to render, upload to people. and update doc-open to load live docs
144
145
doc-upload: doc
87.2.4 by Rick Harding
Fix the upload, was uploading the wrong directory.
146
	scp -r docs/_build/html/* people.canonical.com:/home/rharding/public_html/charmworld
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
147
386.1.2 by Brad Crittenden
Fixes to Huw's branch
148
run: $(INI) bin/es-update
348.4.2 by Benji York
Spruce up the Makefile.
149
	bin/es-update
89.1.2 by Rick Harding
Add the start of the form, with edit/load support
150
	$(PSERVE) --reload --monitor-restart $(INI)
66.1.2 by Rick Harding
Updated to get a make install/make run to work
151
153.2.2 by j.c.sackett
Supervisord and daemonizing.
152
start_supervisor:
153
	bin/supervisord -c charmworld/jobs/supervisord.conf
154
310.1.1 by Brad Crittenden
Use Charm model objects rather than dicts.
155
stop_supervisor:
153.2.8 by j.c.sackett
Stop supervisor checks for pid
156
	if test -f ./supervisord.pid; \
157
		then  cat ./supervisord.pid | xargs kill -HUP; \
158
		else echo "No pidfile for supervisor; is the process running?"; \
159
	fi
153.2.2 by j.c.sackett
Supervisord and daemonizing.
160
310.1.1 by Brad Crittenden
Use Charm model objects rather than dicts.
161
start_worker:
153.2.2 by j.c.sackett
Supervisord and daemonizing.
162
	bin/supervisorctl -c charmworld/jobs/supervisord.conf start ingest
163
164
stop_worker:
165
	bin/supervisorctl -c charmworld/jobs/supervisord.conf stop ingest
166
153.2.7 by j.c.sackett
Worker starts automatically on supervisord start. Status helper.
167
worker_status:
168
	bin/supervisorctl -c charmworld/jobs/supervisord.conf status ingest
169
66.1.2 by Rick Harding
Updated to get a make install/make run to work
170
clean:
348.4.2 by Benji York
Spruce up the Makefile.
171
	find . -type f -name '*.py[co]' -print0 | xargs -r0 rm -rf
172
	find . -type f -name '*~' -print0 | xargs -r0 rm -rf
173
	rm -rf node_modules
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
174
76.2.14 by Rick Harding
make sure we clear the ini on make check
175
clear_ini:
348.4.1 by Benji York
checkpoint
176
	rm -f charmworld.ini
76.2.14 by Rick Harding
make sure we clear the ini on make check
177
84.1.7 by j.c.sackett
Removed buildout from Makefile.
178
distclean: clean clean_venv
348.4.2 by Benji York
Spruce up the Makefile.
179
	rm -rf tags TAGS .installed.cfg lib
180
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
181
182
183
#
184
# Phony stuff.
185
#
348.4.4 by Benji York
remove unnecessary indirection
186
define phony
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
187
  check
115.1.1 by Rick Harding
Add in the bootstrap and updated css files
188
  css
84.1.3 by j.c.sackett
Assorted updates that evidently got lost in Friday's bzr trauma.
189
  clean_venv
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
190
  clean
191
  deps
348.4.2 by Benji York
Spruce up the Makefile.
192
  develop
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
193
  distclean
72.3.1 by Rick Harding
Add sphinx docs, makefile helpers, and initial install/setup/todo pages.
194
  doc
195
  doc-open
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
196
  install
197
  lint
198
  run
199
  tags
200
  test
201
  testid
153.2.2 by j.c.sackett
Supervisord and daemonizing.
202
  start_worker
203
  stop_worker
153.2.8 by j.c.sackett
Stop supervisor checks for pid
204
  worker_status
71.1.1 by Rick Harding
Apply changes to add buildout support to charmworld
205
endef
206
207
phony := $(sort $(strip $(phony)))
208
209
.PHONY: $(phony)
348.4.1 by Benji York
checkpoint
210
211
.DEFAULT_GOAL := install