~schooltool-owners/schooltool/ark_2.10_packaging

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#!/usr/bin/make

PACKAGE=schooltool
LOCALES=src/schooltool/locales
TRANSLATIONS_ZCML=schooltool/common/translations.zcml

DIST=/home/ftp/pub/schooltool/ark
PYTHON=python

INSTANCE_TYPE=schooltool
BUILDOUT_FLAGS=
REDIS_PORT:=$$(grep ^port instance/redis.conf | cut -d' ' -f 2)

.PHONY: all
all: build

.PHONY: build
build: .installed.cfg

python:
	rm -rf python
	virtualenv --no-site-packages -p $(PYTHON) python

.PHONY: bootstrap
bootstrap bin/buildout: | buildout.cfg python
	python/bin/python bootstrap.py

buildout.cfg:
	cp deploy.cfg buildout.cfg

.PHONY: buildout
buildout .installed.cfg: python bin/buildout buildout.cfg base.cfg deploy.cfg setup.py
	bin/buildout $(BUILDOUT_FLAGS)

.PHONY: develop
develop bin/coverage bin/docs: buildout.cfg develop.cfg
	sed -e 's/base.cfg/develop.cfg/' -i buildout.cfg
	$(MAKE) buildout

.PHONY: update
update:
	bzr up
	$(MAKE) buildout BUILDOUT_FLAGS=-n

instance: | build
	bin/make-schooltool-instance instance instance_type=$(INSTANCE_TYPE)

instance/run/supervisord.pid:
	bin/supervisord

.PHONY: run
run: build instance instance/run/supervisord.pid
	@bin/supervisorctl start "services:*"
	@bin/supervisorctl status schooltool | grep RUNNING && bin/supervisorctl stop schooltool || exit 0
	@bin/supervisorctl status
	REDIS_PORT=$(REDIS_PORT) bin/start-schooltool-instance instance

.PHONY: start
start: build instance instance/run/supervisord.pid
	bin/supervisorctl start all
	@bin/supervisorctl status

.PHONY: start-services
start-services: build instance instance/run/supervisord.pid
	@bin/supervisorctl status | grep services[:] | grep -v RUNNING && bin/supervisorctl start "services:*" || exit 0
	@bin/supervisorctl status | grep services[:]

.PHONY: restart
restart: build instance instance/run/supervisord.pid
	@bin/supervisorctl restart "services:celery_report"
	@bin/supervisorctl start "services:*"
	bin/supervisorctl restart schooltool
	@bin/supervisorctl status

.PHONY: rerun
rerun: build instance instance/run/supervisord.pid
	@bin/supervisorctl restart "services:celery_report"
	@bin/supervisorctl start "services:*"
	@bin/supervisorctl status schooltool | grep RUNNING && bin/supervisorctl stop schooltool || exit 0
	@bin/supervisorctl status
	REDIS_PORT=$(REDIS_PORT) bin/start-schooltool-instance instance

.PHONY: stop
stop:
	@test -S instance/run/supervisord.sock && bin/supervisorctl status | grep -v STOPPED && bin/supervisorctl stop all || exit 0
	@test -S instance/run/supervisord.sock && bin/supervisorctl shutdown || echo Nothing to stop
	@rm -f instance/run/zeo.sock
	@rm -f instance/run/supervisord.sock
	@rm -f instance/run/supervisord.pid

.PHONY: status
status:
	@test -f instance/run/supervisord.pid && bin/supervisorctl status || echo All services shut down

.PHONY: tags
tags: build
	bin/ctags

.PHONY: clean
clean: stop
	rm -rf python
	rm -rf bin develop-eggs parts .installed.cfg
	rm -rf build
	rm -f ID TAGS tags
	rm -rf coverage ftest-coverage
	rm -rf docs
	rm -rf instance/var/celerybeat-schedule
	rm -rf instance/var/redis-dump.rdb
	rm -rf instance/run/zeo.sock
	rm -rf instance/run/supervisord.sock
	rm -rf instance/run/supervisord.pid
	rm -rf instance/var/Data.fs.lock
	find . -name '*.py[co]' -delete
	find . -name '*.mo' -delete
	find . -name 'LC_MESSAGES' -exec rmdir -p --ignore-fail-on-non-empty {} +

.PHONY: realclean
realclean: stop
	rm -f buildout.cfg
	rm -rf eggs
	rm -rf dist
	rm -rf instance
	$(MAKE) clean

# Tests

.PHONY: test
test: build
	bin/test -u

.PHONY: ftest
ftest: build
	bin/test -f

.PHONY: testall
testall: build
	bin/test --at-level 2

# Coverage

.PHONY: coverage
coverage: build
	rm -rf coverage
	bin/test --at-level 2 -u --coverage=$(CURDIR)/coverage

.PHONY: coverage-reports-html
coverage-reports-html coverage/reports: bin/coverage build
	test -d coverage || $(MAKE) coverage
	rm -rf coverage/reports
	mkdir coverage/reports
	bin/coverage coverage coverage/reports
	ln -s $(PACKAGE).html coverage/reports/index.html

.PHONY: ftest-coverage
ftest-coverage: build
	rm -rf ftest-coverage
	bin/test --at-level 2 -f --coverage=$(CURDIR)/ftest-coverage

.PHONY: ftest-coverage-reports-html
ftest-coverage-reports-html ftest-coverage/reports: bin/coverage build
	test -d ftest-coverage || $(MAKE) ftest-coverage
	rm -rf ftest-coverage/reports
	mkdir ftest-coverage/reports
	bin/coverage ftest-coverage ftest-coverage/reports
	ln -s $(PACKAGE).html ftest-coverage/reports/index.html

# Translations

.PHONY: extract-translations
extract-translations: build
	bin/i18nextract --egg $(PACKAGE) \
	                --domain $(PACKAGE) \
	                --zcml $(TRANSLATIONS_ZCML) \
	                --output-file $(LOCALES)/$(PACKAGE).pot

.PHONY: compile-translations
compile-translations:
	set -e ;\
	for f in $(LOCALES)/*.po; do \
	    mkdir -p $${f%.po}/LC_MESSAGES; \
	    msgfmt -o $${f%.po}/LC_MESSAGES/$(PACKAGE).mo $$f;\
	done

.PHONY: update-translations
update-translations:
	set -e ;\
	for f in $(LOCALES)/*.po; do \
	    msgmerge -qUN $$f $(LOCALES)/$(PACKAGE).pot ;\
	done
	$(MAKE) compile-translations

# Docs

docs: bin/docs build
	bin/docs

# Release

.PHONY: release
release: compile-translations
	-cp buildout.cfg buildout.cfg~dev~
	cp deploy.cfg buildout.cfg
	grep -qv 'dev' version.txt.in || echo -n `cat version.txt.in`-r`bzr revno` > version.txt
	$(PYTHON) setup.py sdist
	rm -f version.txt
	-mv buildout.cfg~dev~ buildout.cfg

.PHONY: move-release
move-release: upload
	rm -v dist/$(PACKAGE)-*dev-r*.tar.gz

.PHONY: upload
upload:
	set -e ;\
	VERSION=`cat version.txt.in` ;\
	DIST=$(DIST) ;\
	grep -qv 'dev' version.txt.in || VERSION=`cat version.txt.in`-r`bzr revno` ;\
	grep -qv 'dev' version.txt.in || DIST=$(DIST)/dev ;\
	if [ -w $${DIST} ] ; then \
	    echo cp dist/$(PACKAGE)-$${VERSION}.tar.gz $${DIST} ;\
	    cp dist/$(PACKAGE)-$${VERSION}.tar.gz $${DIST} ;\
	else \
	    echo scp dist/$(PACKAGE)-$${VERSION}.tar.gz* ftp.schooltool.org:$${DIST} ;\
	    scp dist/$(PACKAGE)-$${VERSION}.tar.gz* ftp.schooltool.org:$${DIST} ;\
	fi

# Helpers

.PHONY: ubuntu-environment
ubuntu-environment:
	sudo apt-get install build-essential gettext enscript \
	    python-dev python-virtualenv \
	    ttf-ubuntu-font-family ttf-liberation \
	    libicu-dev libxslt1-dev libfreetype6-dev libjpeg-dev \
	    redis-server