forked from djaodjin/djaodjin-saas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (48 loc) · 2.35 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
# -*- Makefile -*-
-include $(buildTop)/share/dws/prefix.mk
srcDir ?= .
installTop ?= $(VIRTUAL_ENV)
binDir ?= $(installTop)/bin
CONFIG_DIR ?= $(srcDir)
# XXX CONFIG_DIR should really be $(installTop)/etc/testsite
LOCALSTATEDIR ?= $(installTop)/var
PYTHON := TESTSITE_SETTINGS_LOCATION=$(CONFIG_DIR) $(binDir)/python
installDirs ?= install -d
# Django 1.7,1.8 sync tables without migrations by default while Django 1.9
# requires a --run-syncdb argument.
# Implementation Note: We have to wait for the config files to be installed
# before running the manage.py command (else missing SECRECT_KEY).
RUNSYNCDB = $(if $(findstring --run-syncdb,$(shell cd $(srcDir) && $(PYTHON) manage.py migrate --help 2>/dev/null)),--run-syncdb,)
install::
cd $(srcDir) && $(PYTHON) ./setup.py --quiet \
build -b $(CURDIR)/build install
install-conf:: $(DESTDIR)$(CONFIG_DIR)/credentials \
$(DESTDIR)$(CONFIG_DIR)/gunicorn.conf
install -d $(DESTDIR)$(LOCALSTATEDIR)/db
install -d $(DESTDIR)$(LOCALSTATEDIR)/run
install -d $(DESTDIR)$(LOCALSTATEDIR)/log/gunicorn
$(DESTDIR)$(CONFIG_DIR)/credentials: $(srcDir)/testsite/etc/credentials
install -d $(dir $@)
@if [ ! -f $@ ] ; then \
SECRET_KEY=`$(PYTHON) -c 'import sys ; from random import choice ; sys.stdout.write("".join([choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^*-_=+") for i in range(50)]))'` && sed \
-e "s,\%(SECRET_KEY)s,$${SECRET_KEY}," \
-e "s,STRIPE_PUB_KEY = \"\",STRIPE_PUB_KEY = \"$(STRIPE_PUB_KEY)\"," \
-e "s,STRIPE_PRIV_KEY = \"\",STRIPE_PRIV_KEY = \"$(STRIPE_PRIV_KEY)\","\
-e "s,STRIPE_CLIENT_ID = \"\",STRIPE_CLIENT_ID = \"$(STRIPE_CLIENT_ID)\","\
$< > $@ ; \
else \
echo "warning: We are keeping $@ intact but $< contains updates that might affect behavior of the testsite." ; \
fi
$(DESTDIR)$(CONFIG_DIR)/gunicorn.conf: $(srcDir)/testsite/etc/gunicorn.conf
install -d $(dir $@)
[ -f $@ ] || sed \
-e 's,%(LOCALSTATEDIR)s,$(LOCALSTATEDIR),' $< > $@
initdb-with-dummydata: initdb
cd $(srcDir) && $(PYTHON) ./manage.py load_test_transactions
initdb: install-conf
-rm -f $(srcDir)/db.sqlite $(srcDir)/testsite-app.log
cd $(srcDir) && $(PYTHON) ./manage.py migrate $(RUNSYNCDB) --noinput
cd $(srcDir) && $(PYTHON) ./manage.py loaddata testsite/fixtures/test_data.json
doc:
$(installDirs) docs
cd $(srcDir) && sphinx-build -b html ./docs $(PWD)/docs