forked from djaodjin/djaodjin-deployutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (42 loc) · 2.09 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
# -*- 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 := $(binDir)/python
# We generate the SECRET_KEY this way so it can be overriden
# in test environments.
SECRET_KEY ?= $(shell $(PYTHON) -c 'import sys ; from random import choice ; sys.stdout.write("".join([choice("abcdefghijklmnopqrstuvwxyz0123456789!@\#$%^*-_=+") for i in range(50)]))' )
DJAODJIN_SECRET_KEY ?= $(shell $(PYTHON) -c 'import sys ; from random import choice ; sys.stdout.write("".join([choice("abcdefghijklmnopqrstuvwxyz0123456789!@\#$%^*-_=+") for i in range(50)]))' )
# 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
[ -f $@ ] || \
sed -e "s,\%(SECRET_KEY)s,$(SECRET_KEY)," \
-e "s,\%(DJAODJIN_SECRET_KEY)s,$(DJAODJIN_SECRET_KEY)," \
$< > $@
$(DESTDIR)$(CONFIG_DIR)/gunicorn.conf: $(srcDir)/testsite/etc/gunicorn.conf
install -d $(dir $@)
[ -f $@ ] || sed \
-e 's,%(LOCALSTATEDIR)s,$(LOCALSTATEDIR),' $< > $@
initdb: install-conf
-rm -f $(srcDir)/db.sqlite
cd $(srcDir) && $(PYTHON) ./manage.py migrate $(RUNSYNCDB) --noinput
doc:
$(installDirs) docs
cd $(srcDir) && sphinx-build -b html ./docs $(PWD)/docs
-include $(buildTop)/share/dws/suffix.mk