forked from daq-tools/kotori
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
269 lines (196 loc) · 8.67 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
# -*- coding: utf-8 -*-
# (c) 2014-2019 Andreas Motl, Elmyra UG <andreas.motl@elmyra.de>
# ============
# Main targets
# ============
# -------------
# Configuration
# -------------
$(eval venvpath := .venv_util)
$(eval pip := $(venvpath)/bin/pip)
$(eval python := $(venvpath)/bin/python)
$(eval pytest := $(venvpath)/bin/pytest)
$(eval bumpversion := $(venvpath)/bin/bumpversion)
$(eval twine := $(venvpath)/bin/twine)
$(eval sphinx := $(venvpath)/bin/sphinx-build)
# Setup Python virtualenv
setup-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=python2 --no-site-packages $(venvpath)
# =======
# Release
# =======
#
# Release this piece of software
# Uses the fine ``bumpversion`` utility.
#
# Synopsis::
#
# make release bump={patch,minor,major}
#
release: bumpversion push sdist pypi-upload
publish-sdist: sdist
# publish Python Eggs to eggserver
# TODO: use localshop or one of its sisters
rsync -auv --progress ./dist/kotori-*.tar.gz workbench@packages.elmyra.de:/srv/packages/organizations/elmyra/foss/htdocs/python/kotori/
# ==========================================
# packaging
# ==========================================
# Build and publish debian package with flavor
# Hint: Should be run on an appropriate build slave matching the deployment platform
# Synopsis::
#
# # amd64
# make debian-package flavor=full dist=buster arch=amd64 version=0.22.0
#
# # armhf
# make debian-package flavor=standard dist=buster arch=armhf version=0.22.0
#
debian-package: check-flavor-options deb-build-$(flavor) publish-debian
deb-build-minimal:
$(MAKE) deb-build name=kotori-minimal features=daq
deb-build-standard:
$(MAKE) deb-build name=kotori-standard features=daq,export
deb-build-standard-binary:
$(MAKE) deb-build name=kotori-standard-binary features=daq,export,daq_binary
deb-build-full:
$(MAKE) deb-build name=kotori features=daq,daq_geospatial,export,plotting,firmware,scientific
deb-build: check-build-options
@# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
@# https://en.wikipedia.org/wiki/ANSI_escape_code
$(eval RED := "\033[0;31m")
$(eval YELLOW := \033[0;33m\033[1m)
$(eval NC := \033[0m)
@echo "Building package $(YELLOW)$(name)$(NC) version $(YELLOW)$(version)$(NC) with features $(YELLOW)$(features)$(NC)"
# Build Python virtualenv and Linux distribution package
@#docker build --tag daq-tools/kotori-build-arm32v7:$(version) --build-arg VERSION=$(version) --build-arg NAME=$(name) --build-arg FEATURES=$(features) --file packaging/dockerfiles/Dockerfile.kotori.arm32v7 .
@#docker build --tag daq-tools/kotori-build-arm32v7:$(version) --build-arg BASE_IMAGE=hiveeyes/arm32v7-baseline --build-arg VERSION=$(version) --build-arg NAME=$(name) --build-arg FEATURES=$(features) --file packaging/dockerfiles/Dockerfile.kotori.arm32v7 .
docker build --tag daq-tools/kotori-build-$(arch):$(version) --build-arg BASE_IMAGE=daq-tools/$(dist)-$(arch)-baseline:latest --build-arg DISTRIBUTION=$(dist) --build-arg VERSION=$(version) --build-arg NAME=$(name) --build-arg FEATURES=$(features) --file packaging/dockerfiles/Dockerfile.all.kotori .
# Extract Debian package
docker container rm -f finalize; true
docker container create --name finalize daq-tools/kotori-build-$(arch):$(version)
docker container cp finalize:/dist/$(name)_$(version)-1~$(dist)_$(arch).deb ./dist/
docker container rm -f finalize
publish-debian:
# Publish all Debian packages
rsync -auv --progress ./dist/kotori*$(version)*.deb workbench@packages.elmyra.de:/srv/packages/organizations/elmyra/foss/aptly/public/incoming/
build-debian-stretch-amd64-baseline:
docker build --tag daq-tools/stretch-amd64-baseline:0.7.0 --build-arg BASE_IMAGE=balenalib/amd64-debian:stretch-build - < packaging/dockerfiles/Dockerfile.debian.baseline
docker tag daq-tools/stretch-amd64-baseline:0.7.0 daq-tools/stretch-amd64-baseline:latest
build-debian-stretch-armhf-baseline:
docker build --tag daq-tools/stretch-armhf-baseline:0.7.0 --build-arg BASE_IMAGE=balenalib/armv7hf-debian:stretch-build - < packaging/dockerfiles/Dockerfile.debian.baseline
docker tag daq-tools/stretch-armhf-baseline:0.7.0 daq-tools/stretch-armhf-baseline:latest
build-debian-buster-amd64-baseline:
docker build --tag daq-tools/buster-amd64-baseline:0.7.0 --build-arg BASE_IMAGE=balenalib/amd64-debian:buster-build - < packaging/dockerfiles/Dockerfile.debian.baseline
docker tag daq-tools/buster-amd64-baseline:0.7.0 daq-tools/buster-amd64-baseline:latest
build-debian-buster-armhf-baseline:
docker build --tag daq-tools/buster-armhf-baseline:0.7.0 --build-arg BASE_IMAGE=balenalib/armv7hf-debian:buster-build - < packaging/dockerfiles/Dockerfile.debian.baseline
docker tag daq-tools/buster-armhf-baseline:0.7.0 daq-tools/buster-armhf-baseline:latest
check-flavor-options:
@if test "$(flavor)" = ""; then \
echo "ERROR: 'flavor' not set, try 'make debian-package flavor={minimal,standard,full}'"; \
exit 1; \
fi
check-build-options:
@if test "$(dist)" = ""; then \
echo "ERROR: 'dist' not set"; \
exit 1; \
fi
@if test "$(arch)" = ""; then \
echo "ERROR: 'arch' not set"; \
exit 1; \
fi
@if test "$(name)" = ""; then \
echo "ERROR: 'name' not set"; \
exit 1; \
fi
@if test "$(features)" = ""; then \
echo "ERROR: 'features' not set"; \
exit 1; \
fi
@if test "$(version)" = ""; then \
echo "ERROR: 'version' not set"; \
exit 1; \
fi
# =============
# Docker images
# =============
check-dockerbuild:
@if test "$(version)" = ""; then \
echo "ERROR: 'version' not set"; \
exit 1; \
fi
build-dockerhub-image: check-dockerbuild
docker build --tag daqzilla/kotori:$(version) --build-arg version=$(version) - < packaging/dockerfiles/Dockerfile.hub.kotori
docker tag daqzilla/kotori:$(version) daqzilla/kotori:latest
# ===============
# Utility targets
# ===============
bumpversion: install-releasetools check-bump-options
$(bumpversion) $(bump)
push:
git push && git push --tags
sdist:
$(python) setup.py sdist
pypi-upload: install-releasetools
twine upload --skip-existing --verbose dist/*.tar.gz
install-releasetools: setup-virtualenv
@$(pip) install --quiet --requirement requirements-release.txt --upgrade
check-bump-options:
@if test "$(bump)" = ""; then \
echo "ERROR: 'bump' not set, try 'make release bump={patch,minor,major}'"; \
exit 1; \
fi
# ==========================================
# environment
# ==========================================
#
# Miscellaneous tools:
# Software tests, Documentation builder, Virtual environment builder
#
test: dev-virtualenv
@# https://nose.readthedocs.org/en/latest/plugins/doctests.html
@# https://nose.readthedocs.org/en/latest/plugins/cover.html
@#export NOSE_IGNORE_FILES="c\.py";
nosetests --with-doctest --doctest-tests --doctest-extension=rst --verbose \
kotori/*.py kotori/daq/{application,graphing,services,storage} kotori/daq/intercom/{mqtt/paho.py,strategies.py,udp.py,wamp.py} kotori/firmware kotori/io kotori/vendor/hiveeyes
test-coverage: dev-virtualenv
nosetests \
--with-doctest --doctest-tests --doctest-extension=rst \
--with-coverage --cover-package=kotori --cover-tests \
--cover-html --cover-html-dir=coverage/html --cover-xml --cover-xml-file=coverage/coverage.xml
docs-html: docs-virtualenv
touch doc/source/index.rst
export SPHINXBUILD="`pwd`/$(sphinx)"; cd doc; make html
docs-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=`command -v python` --no-site-packages $(venvpath)
@$(pip) install --requirement requirements-docs.txt
dev-virtualenv:
@test -e $(python) || `command -v virtualenv` --python=`command -v python` --no-site-packages --no-wheel $(venvpath)
@$(pip) install --requirement requirements-dev.txt
# ==========================================
# ptrace.getkotori.org
# ==========================================
# Don't commit media assets (screenshots, etc.) to the repository.
# Instead, upload them to https://ptrace.getkotori.org/
ptrace_target := root@ptrace.getkotori.org:/srv/www/organizations/daq-tools/ptrace.getkotori.org/htdocs/
ptrace_http := https://ptrace.getkotori.org/
ptrace: check-ptrace-options
$(eval prefix := $(shell gdate --iso-8601))
$(eval name := $(shell basename $(source)))
$(eval id := $(prefix)_$(name))
@# debugging
@#echo "name: $(name)"
@#echo "id: $(id)"
@scp '$(source)' '$(ptrace_target)$(id)'
$(eval url := $(ptrace_http)$(id))
@echo "Access URL: $(url)"
check-ptrace-options:
@if test "$(source)" = ""; then \
echo "ERROR: 'source' not set"; \
exit 1; \
fi
# ==========================================
# infrastructure
# ==========================================
mongodb-start:
mongod --dbpath=./var/lib/mongodb/ --smallfiles