Project

General

Profile

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
psqlDbUser = ./util/psql_vegbien $(psqlOpts)
7

    
8

    
9
all: FORCE install
10

    
11
.SUFFIXES:
12

    
13
FORCE:
14
.PHONY: FORCE
15

    
16

    
17
install: FORCE user db
18

    
19
uninstall: FORCE rm_db rm_user
20

    
21
reinstall: FORCE uninstall install
22

    
23
reinstall_db: FORCE rm_db db
24

    
25
empty_db: FORCE
26
	$(psqlDbUser) <../mappings/schemas/vegbien_empty.sql
27

    
28
user: FORCE
29
	$(MAKE) _$@
30

    
31
ifeq ($(MAKECMDGOALS),_user)
32
include util/vegbien_dest
33
endif
34

    
35
_user: FORCE
36
	@echo "At sudo password prompt, enter *your* password"
37
	@sudo -v
38
	@echo "At prompt \"Enter password for new role:\", enter $(out_password)"
39
	-$(_user_cmd)
40
# ignore errors about existing user
41
_user_cmd = $(asAdmin) createuser --no-superuser --no-createdb --no-createrole \
42
--pwprompt "$(out_user)"
43

    
44
rm_user: FORCE
45
	echo "DROP USER bien;"|$(psqlAdmin)
46

    
47
db: FORCE
48
	$(psqlAdmin) <../mappings/schemas/vegbien.sql
49

    
50
rm_db: FORCE
51
	echo "DROP DATABASE vegbien;"|$(psqlAdmin)
52

    
53

    
54
test: test-map
55

    
56
test-%: FORCE
57
	./test/$(*F)
(1-1/3)