1
|
export PGOPTIONS = --client-min-messages=WARNING
|
2
|
|
3
|
psqlOpts = --set ON_ERROR_STOP=1 --quiet
|
4
|
asAdmin = sudo -u postgres
|
5
|
psqlAdmin = $(asAdmin) psql $(psqlOpts)
|
6
|
dbConfig = . util/vegbien_dest.sh
|
7
|
psqlDbUser = ./util/psql_vegbien $(psqlOpts)
|
8
|
|
9
|
all: install
|
10
|
|
11
|
.SUFFIXES:
|
12
|
|
13
|
FORCE:
|
14
|
.PHONY: FORCE
|
15
|
|
16
|
|
17
|
install: user db
|
18
|
|
19
|
uninstall: rm_db rm_user
|
20
|
|
21
|
reinstall: uninstall install
|
22
|
|
23
|
reinstall_db: rm_db db
|
24
|
|
25
|
empty_db:
|
26
|
$(psqlDbUser) <../mappings/schemas/vegbien_empty.sql
|
27
|
|
28
|
user: FORCE
|
29
|
@echo "At prompt \"Password:\", enter *your* password for sudo"
|
30
|
@sudo -v
|
31
|
@($(dbConfig); echo "At prompt \"Enter password for new role:\", \
|
32
|
enter $$out_password")
|
33
|
-$(user_cmd)
|
34
|
# ignore errors about existing user
|
35
|
user_cmd = ($(dbConfig); $(asAdmin) createuser --no-superuser --no-createdb \
|
36
|
--no-createrole --pwprompt "$$out_user")
|
37
|
|
38
|
rm_user: FORCE
|
39
|
echo "DROP USER bien;"|$(psqlAdmin)
|
40
|
|
41
|
db: FORCE
|
42
|
$(psqlAdmin) <../mappings/schemas/vegbien.sql
|
43
|
|
44
|
rm_db: FORCE
|
45
|
echo "DROP DATABASE vegbien;"|$(psqlAdmin)
|
46
|
|
47
|
|
48
|
test: test-map
|
49
|
|
50
|
test-%: FORCE
|
51
|
./test/$(*F)
|