1 |
235
|
aaronmk
|
esc = $$'\x1B['
|
2 |
|
|
reset = $(esc)'0m'
|
3 |
|
|
highlight = $(esc)'7m'
|
4 |
|
|
|
5 |
|
|
os = $(shell uname)
|
6 |
|
|
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1))
|
7 |
|
|
|
8 |
225
|
aaronmk
|
export PGOPTIONS = --client-min-messages=WARNING
|
9 |
|
|
|
10 |
|
|
psqlOpts = --set ON_ERROR_STOP=1 --quiet
|
11 |
227
|
aaronmk
|
asAdmin = sudo -u postgres
|
12 |
|
|
psqlAdmin = $(asAdmin) psql $(psqlOpts)
|
13 |
225
|
aaronmk
|
psqlDbUser = ./util/psql_vegbien $(psqlOpts)
|
14 |
|
|
|
15 |
149
|
aaronmk
|
|
16 |
235
|
aaronmk
|
all: _not_file install
|
17 |
228
|
aaronmk
|
|
18 |
225
|
aaronmk
|
.SUFFIXES:
|
19 |
|
|
|
20 |
235
|
aaronmk
|
_not_file:
|
21 |
|
|
.PHONY: _not_file
|
22 |
202
|
aaronmk
|
|
23 |
|
|
|
24 |
235
|
aaronmk
|
install: _not_file deps user db
|
25 |
202
|
aaronmk
|
|
26 |
235
|
aaronmk
|
uninstall: _not_file rm_db rm_user
|
27 |
202
|
aaronmk
|
|
28 |
235
|
aaronmk
|
reinstall: _not_file uninstall install
|
29 |
225
|
aaronmk
|
|
30 |
202
|
aaronmk
|
|
31 |
235
|
aaronmk
|
deps: _not_file $(call forOs,postgres mysql)
|
32 |
|
|
|
33 |
|
|
postgres-Linux: _not_file
|
34 |
|
|
sudo apt-get install python-dev python-pip libpq-dev
|
35 |
|
|
sudo pip install psycopg2
|
36 |
|
|
|
37 |
|
|
postgres-Darwin: _not_file
|
38 |
|
|
|
39 |
|
|
mysql-Linux: _not_file
|
40 |
|
|
sudo apt-get install mysql-server mysql-client python-mysqldb
|
41 |
|
|
|
42 |
|
|
mysql-Darwin: _not_file
|
43 |
|
|
@echo $(highlight)'Installing MySQLdb Python driver on Mac OS X 10.7 (may work on other versions):'$(reset)
|
44 |
|
|
@echo 'Download it using "latest version" link at http://sourceforge.net/projects/mysql-python/files/'
|
45 |
|
|
@echo 'Extract the archive'
|
46 |
|
|
@echo '(From http://www.rustyrazorblade.com/2011/11/installing-mysqldb-on-macos-lion/:)'
|
47 |
|
|
@echo 'Run sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib'
|
48 |
|
|
@echo 'Run sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql'
|
49 |
|
|
@echo '(From http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found:)'
|
50 |
|
|
@echo 'Edit site.cfg and change the line like "mysql_config = " to "mysql_config = /usr/local/mysql/bin/mysql_config"'
|
51 |
|
|
@echo '(From http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/:)'
|
52 |
|
|
@echo 'Change to the directory of the extracted files'
|
53 |
|
|
@echo 'Run sudo python setup.py clean'
|
54 |
|
|
@echo 'Run sudo python setup.py build'
|
55 |
|
|
@echo 'Run sudo python setup.py install'
|
56 |
|
|
@echo "Run python -c 'import MySQLdb'"
|
57 |
|
|
@read -p $(highlight)'Press ENTER to continue:'$(reset)
|
58 |
|
|
|
59 |
|
|
# Catch-alls for other OSes
|
60 |
|
|
mysql-:
|
61 |
|
|
postgres-:
|
62 |
|
|
|
63 |
|
|
reinstall_db: _not_file rm_db db
|
64 |
|
|
|
65 |
|
|
empty_db: _not_file
|
66 |
225
|
aaronmk
|
$(psqlDbUser) <../mappings/schemas/vegbien_empty.sql
|
67 |
202
|
aaronmk
|
|
68 |
235
|
aaronmk
|
user: _not_file
|
69 |
228
|
aaronmk
|
$(MAKE) _$@
|
70 |
|
|
|
71 |
|
|
ifeq ($(MAKECMDGOALS),_user)
|
72 |
230
|
aaronmk
|
include util/vegbien_dest
|
73 |
228
|
aaronmk
|
endif
|
74 |
|
|
|
75 |
235
|
aaronmk
|
_user: _not_file
|
76 |
|
|
@echo $(highlight)"At sudo password prompt, enter *your* password"$(reset)
|
77 |
227
|
aaronmk
|
@sudo -v
|
78 |
235
|
aaronmk
|
@echo $(highlight)"At prompt \"Enter password for new role:\", enter $(out_password)"$(reset)
|
79 |
228
|
aaronmk
|
-$(_user_cmd)
|
80 |
202
|
aaronmk
|
# ignore errors about existing user
|
81 |
228
|
aaronmk
|
_user_cmd = $(asAdmin) createuser --no-superuser --no-createdb --no-createrole \
|
82 |
|
|
--pwprompt "$(out_user)"
|
83 |
202
|
aaronmk
|
|
84 |
235
|
aaronmk
|
rm_user: _not_file
|
85 |
225
|
aaronmk
|
echo "DROP USER bien;"|$(psqlAdmin)
|
86 |
202
|
aaronmk
|
|
87 |
235
|
aaronmk
|
db: _not_file
|
88 |
225
|
aaronmk
|
$(psqlAdmin) <../mappings/schemas/vegbien.sql
|
89 |
202
|
aaronmk
|
|
90 |
235
|
aaronmk
|
rm_db: _not_file
|
91 |
225
|
aaronmk
|
echo "DROP DATABASE vegbien;"|$(psqlAdmin)
|
92 |
202
|
aaronmk
|
|
93 |
|
|
|
94 |
176
|
aaronmk
|
test: test-map
|
95 |
149
|
aaronmk
|
|
96 |
235
|
aaronmk
|
test-%: _not_file
|
97 |
176
|
aaronmk
|
./test/$(*F)
|