~launchpad-pqm/launchpad/devel

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
# arch-tag: 6773f9cf-f527-48bb-8521-7a103f106633
# (c) 2004  Canonical Software Ltd
# David Allouche: okay, that's quite possibly crack, feel free to remove


default:
	@ echo "Usage: $(MAKE) TARGET"
	@ echo
	@ echo "  launchpad   create and populate the launchpad database"
	@ echo "  launchpad_test  create and populate the test database"

+postgres:
	@ if ! which postgresql ; then \
	echo "* install postgres" ; \
	echo "sudo apt-get install postgresql" ; \
	sudo apt-get install postgresql ; fi
	touch $@

+pguser: +postgres
	@ echo '* make sure your user has write access' \
	'to a database called "launchpad"'
	 # pass through root to sudo to postgres
	sudo sudo -u postgres createuser -A -d $$(id -un)
	id -un > $@

+launchpad-db +launchpad_test-db: +%-db: +pguser
	@ echo '* create the $* database'
	createdb $*
	touch $@

launchpad launchpad_test: %: +%-db
	@ echo '* create the $* database tables'
	psql --file launchpad.sql $*
	@ echo '* populate database $* with the schema information'
	psql --file schemas.sql $*

dropdb-launchpad dropdb-launchpad_test: dropdb-%: +%-db
	@ echo '* remove the $* database'
	dropdb $*
	rm $<


.PHONY: default launchpad launchpad_test
.PHONY: dropdb-launchpad dropdb-launchpad_test