Project

General

Profile

« Previous | Next » 

Revision 1748

root Makefile: empty_db: Confirm deletion just like for rm_db. rm_db: put $(confirmRmDb) on a separate line and move the $(error) call to the main $(confirm) macro since you always want to abort make if the user cancels (not just not run that command).

View differences:

Makefile
23 23

  
24 24
wait := read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY
25 25

  
26
confirm = $(shell read -p $(emph)"$(1) (y/n)"$(endEmph) REPLY; \
27
test "$$REPLY" = y && echo t)
26
confirm = $(if $(shell read -p $(emph)"$(1) (y/n)"$(endEmph) REPLY; \
27
test "$$REPLY" = y && echo t),,$(error Aborting))
28 28

  
29 29
# File editing
30 30
sudoAppend = echo $$'$(2)'|sudo tee -a $(1) >/dev/null
......
168 168
	$(psqlAsBien) <$<
169 169
# ignore errors if user or database exists
170 170

  
171
define rmDb
172
echo "DROP DATABASE IF EXISTS vegbien;"|$(psqlAsAdmin)
173
echo "DROP USER IF EXISTS bien;"|$(psqlAsAdmin)
174
endef
171
confirmRmDb = $(call confirm,WARNING: This will delete your VegBIEN DB!\
172
Continue?)
175 173

  
176 174
rm_db: _always
177
	$(if $(call confirm,WARNING: This will delete your VegBIEN DB! Continue?),\
178
$(rmDb),$(error Aborting))
179
# otherwise, abort in case target was reinstall_db to prevent installing
175
	@$(confirmRmDb)
176
	echo "DROP DATABASE IF EXISTS vegbien;"|$(psqlAsAdmin)
177
	echo "DROP USER IF EXISTS bien;"|$(psqlAsAdmin)
180 178

  
181 179
reinstall_db: _always rm_db db ;
182 180

  
183 181
empty_db: _always schemas/vegbien_empty.sql
182
	@$(confirmRmDb)
184 183
	$(psqlAsBien) <schemas/vegbien_empty.sql
185 184

  
186 185
##### MySQL

Also available in: Unified diff