forked from jakevdp/shim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
222 lines (184 loc) · 9.28 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
ifeq ($(SCIDB),)
X := $(shell which scidb 2>/dev/null)
ifneq ($(X),)
X := $(shell dirname ${X})
SCIDB := $(shell dirname ${X})
endif
endif
SCIDB_VERSION := $(shell $(SCIDB)/bin/scidb --version |head -1|awk '{print $$3}'|awk -F. '{print $$1 "." $$2}')
# default: empty DESTDIR implicitly installs to /
DESTDIR=
.PHONY: shim
shim:
$(MAKE) -C src shim
@cp src/shim .
client:
$(MAKE) -C src client
help:
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
@echo "make shim (compile and link)"
@echo
@echo "The remaining options may require setting the SCIDB environment"
@echo "variable to the path of the target SciDB installation. For example,"
@echo "make SCIDB=$(SCIDB) install"
@echo
@echo "make install (install program and files)"
@echo "make uninstall (remove program and files)"
@echo "make service (install a Debian or RHEL shim service)"
@echo "make unservice (terminate and remove installed service)"
@echo "make deb-pkg (create a binary Ubuntu/Debian package, requires fpm)"
@echo "make rpm-pkg (create a binary RHEL package, requires fpm)"
@echo "make test<n> (build and run test number n)"
@echo "make test (build and run all but multiuser tests)"
@echo
@echo "Other tests are available. Read the contents of Makefile for details."
install: shim stop-service
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
@mkdir -p "$(DESTDIR)$(SCIDB)/bin"
cp shim "$(DESTDIR)$(SCIDB)/bin"
mkdir -p "$(DESTDIR)/var/lib/shim"
chmod -R 755 "$(DESTDIR)/var/lib/shim"
cp -aR wwwroot "$(DESTDIR)/var/lib/shim/"
init.d/setup-conf.sh
@if test -d $(DESTDIR)/usr/local/share/man/man1;then cp man/shim.1 $(DESTDIR)/usr/local/share/man/man1/;fi
uninstall: stop-service
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
rm -f "$(SCIDB)/bin/shim"
rm -rf /var/lib/shim
rm -f /usr/local/share/man/man1/shim.1
stop-service:
- @if test -n "$$(which systemctl 2>/dev/null)"; then systemctl stop shimsvc 2>/dev/null||true; fi
- @if test -n "$$(which update-rc.d 2>/dev/null)"; then service shimsvc stop 2>/dev/null||true; fi
- @if test -n "$$(which chkconfig 2>/dev/null)"; then service shimsvc stop 2>/dev/null||true; fi
service: install
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
# systemctl
- @if test -n "$$(which systemctl 2>/dev/null)"; then systemctl disable shimsvc 2>/dev/null||true; fi
- @if test -n "$$(which systemctl 2>/dev/null)"; then sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.service > /lib/systemd/system/shimsvc.service; fi
- @if test -n "$$(which systemctl 2>/dev/null)"; then systemctl daemon-reload; systemctl enable shimsvc; systemctl start shimsvc; fi
# update-rc
- @if test -n "$$(which update-rc.d 2>/dev/null)"; then update-rc.d -f shimsvc remove 2>/dev/null||true; fi
- @if test -n "$$(which update-rc.d 2>/dev/null)"; then sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.initd > /etc/init.d/shimsvc; fi
- @if test -n "$$(which update-rc.d 2>/dev/null)"; then chmod 0755 /etc/init.d/shimsvc; update-rc.d shimsvc defaults; service shimsvc start; fi
# init.d
- @if test -n "$$(which chkconfig 2>/dev/null)"; then chkconfig --del shimsvc 2>/dev/null||true; fi
- @if test -n "$$(which chkconfig 2>/dev/null)"; then sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.initd > /etc/init.d/shimsvc; fi
- @if test -n "$$(which chkconfig 2>/dev/null)"; then chmod 0755 /etc/init.d/shimsvc; chkconfig --add shimsvc; service shimsvc start; fi
unservice: stop-service
- @if test -n "$$(which systemctl 2>/dev/null)"; then systemctl disable shimsvc 2>/dev/null||true; rm -f /lib/systemd/system/shimsvc.service; systemctl daemon-reload; fi
- @if test -n "$$(which update-rc.d 2>/dev/null)"; then update-rc.d -f shimsvc remove 2>/dev/null||true; rm -f /etc/init.d/shimsvc; fi
- @if test -n "$$(which chkconfig 2>/dev/null)"; then chkconfig --del shimsvc 2>/dev/null||true; rm -f /etc/init.d/shimsvc; fi
$(MAKE) uninstall
deb-pkg: shim
@if test -z "$$(which fpm 2>/dev/null)"; then echo "Error: Package building requires fpm, try running gem install fpm."; exit 1;fi
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
rm -rf pkgroot *.deb
mkdir -p pkgroot/$(SCIDB)/bin
cp shim "pkgroot/$(SCIDB)/bin"
mkdir -p pkgroot/$(SCIDB)/shim
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/after-install.sh > pkgroot/$(SCIDB)/shim/after-install.sh
cp init.d/before-remove.sh pkgroot/$(SCIDB)/shim
cp init.d/setup-conf.sh pkgroot/$(SCIDB)/shim
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.service > pkgroot/$(SCIDB)/shim/shimsvc.service
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.initd > pkgroot/$(SCIDB)/shim/shimsvc.initd
mkdir -p pkgroot/var/lib/shim
cp -aR wwwroot pkgroot/var/lib/shim/
chmod -R 755 pkgroot/var/lib/shim
mkdir -p pkgroot/usr/local/share/man/man1
@if test -d /usr/local/share/man/man1;then cp man/shim.1 pkgroot/usr/local/share/man/man1/;fi
fpm -s dir -t deb -n shim -d libssl-dev --vendor Paradigm4 --license AGPLv3 -m "<[email protected]>" --url "https://github.com/Paradigm4/shim" --description "Unofficial SciDB HTTP service" --provides "shim" -v $$(basename $(SCIDB)) --after-install pkgroot/$(SCIDB)/shim/after-install.sh --before-remove init.d/before-remove.sh -C pkgroot opt usr var
rpm-pkg: shim
@if test -z "$$(which fpm 2>/dev/null)"; then echo "Error: Package building requires fpm, try running gem install fpm."; exit 1;fi
@if test ! -d "$(SCIDB)"; then echo "Can't find the scidb executable. Try explicitly setting the SCIDB variable, for example: 'make SCIDB=/opt/scidb/19.11 $@'"; exit 1; fi
rm -rf pkgroot *.rpm
mkdir -p pkgroot/$(SCIDB)/bin
cp shim "pkgroot/$(SCIDB)/bin"
mkdir -p pkgroot/$(SCIDB)/shim
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/after-install.sh > pkgroot/$(SCIDB)/shim/after-install.sh
cp init.d/before-remove.sh pkgroot/$(SCIDB)/shim
cp init.d/setup-conf.sh pkgroot/$(SCIDB)/shim
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.service > pkgroot/$(SCIDB)/shim/shimsvc.service
sed "s!XXX_SCIDB_VER_XXX!$(SCIDB_VERSION)!g" init.d/shimsvc.initd > pkgroot/$(SCIDB)/shim/shimsvc.initd
mkdir -p pkgroot/var/lib/shim
cp -aR wwwroot pkgroot/var/lib/shim/
chmod -R 755 pkgroot/var/lib/shim
mkdir -p pkgroot/usr/local/share/man/man1
@if test -d /usr/local/share/man/man1;then cp man/shim.1 pkgroot/usr/local/share/man/man1/;fi
fpm -s dir -t rpm -n shim -d openssl-devel --vendor Paradigm4 --license AGPLv3 -m "<[email protected]>" --url "https://github.com/Paradigm4/shim" --description "Unofficial SciDB HTTP service" --provides "shim" -v $$(basename $(SCIDB)) --after-install pkgroot/$(SCIDB)/shim/after-install.sh --before-remove init.d/before-remove.sh -C pkgroot opt usr var
clean:
$(MAKE) -C src clean
rm -fr *.o *.so shim pkgroot *.rpm *.deb
test0:
@echo "ALL TESTS REQUIRE A SCIDB SERVER ON 127.0.0.1:1239 WITH security=trust"
test1: shim
@echo "-- - Non-authenticated test"
./tests/noauth.sh
test2: shim
@echo "-- - Basic digest authentication"
./tests/digest_auth.sh
test3: shim
@echo "-- - TLS without authentication"
./tests/tls.sh
test4: shim
@echo "-- - TLS with digest authentication"
./tests/tls_digest.sh
test5: shim
@echo "-- - TLS with SciDB authentication"
./tests/tls_scidbauth.sh
test6: shim
@echo "-- - cancel test"
./tests/cancel.sh
# test7: shim
# @echo "-- - multiuser streaming test"
# ./tests/multiple_users_stream.sh
# test8: shim
# @echo "-- - repeated multiuser streaming test"
# ./tests/more_multiple_users_stream.sh
test9: shim
@echo "-- - read_bytes test"
./tests/read_bytes.sh
# test10: shim
# @echo "-- - file upload test"
# ./tests/upload_file.sh
# test11: shim0
# @echo "-- - valgrind test"
# ./tests/valgrind.sh
# @echo "-- - Now carefully inspect the report in /tmp/valgrind.out"
test12: shim
@echo "-- - post upload test"
./tests/upload.sh
test13: shim
@echo "-- - post upload test session"
./tests/upload_session.sh
test14: shim
@echo "-- - get_log test"
./tests/get_log.sh
test15: shim
@echo "-- - status code test"
./tests/status_code.sh
test16: shim
@echo "-- - read test"
./tests/read.sh
test17: shim
@echo "-- - crash test"
./tests/crash.sh
test18: shim
@echo "-- - auth test"
./tests/auth.sh
test19: shim
@echo "-- - admin test"
./tests/admin.sh
test20: shim
@echo "-- - atts_only test"
./tests/atts_only.sh
test21: shim
@echo "-- - session reap"
./tests/session_reap.sh
test_basic: export LD_LIBRARY_PATH = $(SCIDB)/lib:$(SCIDB)/3rdparty/boost/lib
test_basic: test0 test1 test2 test3 test4 test5 test9 test12 test13 test14 test15 test16 test17 test19
test: export LD_LIBRARY_PATH = $(SCIDB)/lib:$(SCIDB)/3rdparty/boost/lib
test: test_basic test6 test20 test21
grinder: shim0 test_init
@echo "multiuser valgrind test"
./tests/grinder.sh
@echo "Now carefully inspect the report in /tmp/grinder.out"