-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
293 lines (244 loc) · 8.62 KB
/
Makefile
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Makefile for janitoo
#
# You can set these variables from the command line.
ARCHBASE = archive
BUILDDIR = build
DISTDIR = dists
NOSE = $(shell which nosetests)
NOSEOPTS = --verbosity=2
PYLINT = $(shell which pylint)
PYLINTOPTS = --max-line-length=140 --max-args=9 --extension-pkg-whitelist=zmq --ignored-classes=zmq --min-public-methods=0
ifndef PYTHON_EXEC
PYTHON_EXEC=python
endif
ifndef message
message="Auto-commit"
endif
ifdef VIRTUAL_ENV
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell ${VIRTUAL_ENV}/bin/${PYTHON_EXEC} --version 2>&1)))
else
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell ${PYTHON_EXEC} --version 2>&1)))
endif
janitoo_version := $(shell ${PYTHON_EXEC} _version.py 2>/dev/null)
python_version_major = $(word 1,${python_version_full})
python_version_minor = $(word 2,${python_version_full})
python_version_patch = $(word 3,${python_version_full})
PIP_EXEC=pip
ifeq (${python_version_major},3)
PIP_EXEC=pip3
endif
MODULENAME = $(shell basename `pwd`)
DOCKERNAME = $(shell echo ${MODULENAME}|sed -e "s|janitoo_||g")
DOCKERVOLS =
DOCKERPORT = 8883
NOSEMODULES = janitoo,janitoo_factory,janitoo_db
MOREMODULES = janitoo_factory_ext
DEBIANDEPS := $(shell [ -f debian.deps ] && cat debian.deps)
BASHDEPS := $(shell [ -f bash.deps ] && echo "bash.deps")
JANITOODEPS := $(shell [ -f janitoo.deps ] && echo janitoo.deps)
BOWERDEPS := $(shell [ -f bower.deps ] && cat bower.deps)
TAGGED := $(shell git tag | grep -c v${janitoo_version} )
-include Makefile.local
NOSECOVER = --cover-package=${MODULENAME} --with-coverage --cover-inclusive --cover-html --cover-html-dir=${BUILDDIR}/docs/html/tools/coverage --with-html --html-file=${BUILDDIR}/docs/html/tools/nosetests/index.html
NOSEDOCKER = --cover-package=${NOSEMODULES},${MODULENAME},${MOREMODULES} --with-coverage --cover-inclusive --with-xunit --xunit-testsuite-name=${MODULENAME}
.PHONY: help check-tag clean all build develop install uninstall clean-doc doc certification tests pylint deps docker-tests
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " build : build the module"
@echo " develop : install for developpers"
@echo " install : install for users"
@echo " uninstall : uninstall the module"
@echo " deps : install dependencies for users"
@echo " doc : make documentation"
@echo " tests : launch tests"
@echo " clean : clean the development directory"
clean-dist:
-rm -rf $(DISTDIR)
clean: clean-doc
-rm -rf $(ARCHBASE)
-rm -rf $(BUILDDIR)
-rm -f .coverage
-@find . -name \*.pyc -delete
uninstall:
-yes | ${PIP_EXEC} uninstall ${MODULENAME}
-${PYTHON_EXEC} setup.py develop --uninstall
#~ -@find . -name \*.egg-info -type d -exec rm -rf "{}" \;
deps:
ifneq ('${BASHDEPS}','')
bash ${BASHDEPS}
endif
ifneq ('${DEBIANDEPS}','')
sudo apt-get install -y ${DEBIANDEPS}
endif
@echo
@echo "Dependencies for ${MODULENAME} finished."
clean-doc:
-rm -Rf ${BUILDDIR}/docs
-rm -Rf ${BUILDDIR}/janidoc
-rm -f objects.inv
-rm -f generated_doc
-rm -f janidoc
janidoc:
-ln -s /opt/janitoo/src/janitoo_sphinx janidoc
apidoc:
-rm -rf ${BUILDDIR}/janidoc/source/api
-mkdir -p ${BUILDDIR}/janidoc/source/api
cp -Rf janidoc/* ${BUILDDIR}/janidoc/
cd ${BUILDDIR}/janidoc/source/api && sphinx-apidoc --force --no-toc -o . ../../../../src/
cd ${BUILDDIR}/janidoc/source/api && mv ${MODULENAME}.rst index.rst
doc: janidoc apidoc
- [ -f transitions_graph.py ] && python transitions_graph.py
-cp -Rf rst/* ${BUILDDIR}/janidoc/source
sed -i -e "s/MODULE_NAME/${MODULENAME}/g" ${BUILDDIR}/janidoc/source/tools/index.rst
make -C ${BUILDDIR}/janidoc html
cp ${BUILDDIR}/janidoc/source/README.rst README.rst
-ln -s $(BUILDDIR)/docs/html generated_doc
@echo
@echo "Documentation finished."
github.io:
git checkout --orphan gh-pages
git rm -rf .
touch .nojekyll
git add .nojekyll
git commit -m "Initial import" -a
git push origin gh-pages
git checkout master
@echo
@echo "github.io branch initialised."
doc-full: tests pylint doc-commit
doc-commit: doc
git checkout gh-pages
cp -Rf build/docs/html/* .
git add *.html
git add *.js
git add tools/
git add api/
-git add _images/
-git add _modules/
-git add _sources/
-git add _static/
git commit -m "Auto-commit documentation" -a
git push origin gh-pages
git checkout master
@echo
@echo "Documentation published to github.io."
pylint:
-mkdir -p ${BUILDDIR}/docs/html/tools/pylint
$(PYLINT) --output-format=html $(PYLINTOPTS) src/${MODULENAME} >${BUILDDIR}/docs/html/tools/pylint/index.html
install:
${PYTHON_EXEC} setup.py install
@echo
@echo "Installation of ${MODULENAME} finished."
develop:
${PYTHON_EXEC} setup.py develop
@echo
@echo "Installation for developpers of ${MODULENAME} finished."
docker-deps:
-cp -rf docker/config/* /opt/janitoo/etc/
-cp -rf docker/supervisor.conf.d/* /etc/supervisor/janitoo.conf.d/
-cp -rf docker/supervisor-tests.conf.d/* /etc/supervisor/janitoo-tests.conf.d/
-cp -rf docker/nginx/* /etc/nginx/conf.d/
true
@echo
@echo "Docker dependencies for ${MODULENAME} installed."
appliance-deps:
-cp -rf docker/appliance/* /opt/janitoo/etc/
-cp -rf docker/supervisor.conf.d/* /etc/supervisor/janitoo.conf.d/
-cp -rf docker/nginx/* /etc/nginx/conf.d/
@echo
@echo "Appliance dependencies for ${MODULENAME} installed."
directories:
-sudo mkdir /opt/janitoo
-sudo chown -Rf ${USER}:${USER} /opt/janitoo
-for dir in cache cache/janitoo_manager home log run etc init; do mkdir /opt/janitoo/$$dir; done
travis-deps:
sudo apt-get install -y python-pip
git clone https://github.com/bibi21000/janitoo_mosquitto.git
make -C janitoo_mosquitto deps
make -C janitoo_mosquitto develop
pip install git+git://github.com/bibi21000/janitoo_nosetests@master
pip install git+git://github.com/bibi21000/janitoo_nosetests_flask@master
pip install coveralls
@echo
@echo "Travis dependencies for ${MODULENAME} installed."
docker-tests:
@echo
@echo "Docker tests for ${MODULENAME} start."
[ -f tests/test_docker.py ] && $(NOSE) $(NOSEOPTS) $(NOSEDOCKER) tests/test_docker.py
@echo
@echo "Docker tests for ${MODULENAME} finished."
docker-local-pull:
@echo
@echo "Pull local docker for ${MODULENAME}."
docker pull bibi21000/${MODULENAME}
@echo
@echo "Docker local for ${MODULENAME} pulled."
docker-local-store: docker-local-pull
@echo
@echo "Create docker local store for ${MODULENAME}."
docker create -v /root/.ssh/ -v /opt/janitoo/etc/ ${DOCKERVOLS} --name ${DOCKERNAME}_store bibi21000/${MODULENAME} /bin/true
@echo
@echo "Docker local store for ${MODULENAME} created."
docker-local-running: docker-local-pull
@echo
@echo "Update local docker for ${MODULENAME}."
-docker stop ${DOCKERNAME}_running
-docker rm ${DOCKERNAME}_running
docker create --volumes-from ${DOCKERNAME}_store -p ${DOCKERPORT}:22 --name ${DOCKERNAME}_running bibi21000/${MODULENAME}
docker ps -a|grep ${DOCKERNAME}_running
docker start ${DOCKERNAME}_running
docker ps|grep ${DOCKERNAME}_running
@echo
@echo "Docker local for ${MODULENAME} updated."
tests:
-mkdir -p ${BUILDDIR}/docs/html/tools/coverage
-mkdir -p ${BUILDDIR}/docs/html/tools/nosetests
#~ export NOSESKIP=False && $(NOSE) $(NOSEOPTS) $(NOSECOVER) tests ; unset NOSESKIP
$(NOSE) $(NOSEOPTS) $(NOSECOVER) tests
@echo
@echo "Tests for ${MODULENAME} finished."
certification:
$(NOSE) --verbosity=2 --with-xunit --xunit-file=certification/result.xml certification
@echo
@echo "Certification for ${MODULENAME} finished."
build:
${PYTHON_EXEC} setup.py build --build-base $(BUILDDIR)
egg:
-mkdir -p $(BUILDDIR)
-mkdir -p $(DISTDIR)
${PYTHON_EXEC} setup.py bdist_egg --bdist-dir $(BUILDDIR) --dist-dir $(DISTDIR)
tar:
-mkdir -p $(DISTDIR)
tar cvjf $(DISTDIR)/${MODULENAME}-${janitoo_version}.tar.bz2 -h --exclude=\*.pyc --exclude=\*.egg-info --exclude=janidoc --exclude=.git* --exclude=$(BUILDDIR) --exclude=$(DISTDIR) --exclude=$(ARCHBASE) .
@echo
@echo "Archive for ${MODULENAME} version ${janitoo_version} created"
commit:
-git add rst/
-cp rst/README.rst .
-git add README.rst
git commit -m "$(message)" -a && git push
@echo
@echo "Commits for branch master pushed on github."
pull:
git pull
@echo
@echo "Commits from branch master pulled from github."
status:
git status
tag: check-tag commit
git tag v${janitoo_version}
git push origin v${janitoo_version}
@echo
@echo "Tag pushed on github."
check-tag:
ifneq ('${TAGGED}','0')
echo "Already tagged with version ${janitoo_version}"
@/bin/false
endif
new-version: tag clean tar
@echo
@echo "New version ${janitoo_version} created and published"
debch:
dch --newversion ${janitoo_version} --maintmaint "Automatic release from upstream"
deb:
dpkg-buildpackage