Revision 245
Added by Aaron Marcuse-Kubitza about 13 years ago
Makefile | ||
---|---|---|
1 | 1 |
# Make |
2 | 2 |
SHELL = /bin/bash |
3 | 3 |
|
4 |
# OS |
|
5 |
os = $(shell uname) |
|
6 |
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1)) |
|
7 |
|
|
4 | 8 |
# Terminal |
5 | 9 |
esc = '[' |
6 | 10 |
reset = $(esc)'0m' |
7 | 11 |
emph = $(esc)'7m ' |
8 | 12 |
endEmph = ' '$(reset) |
9 |
getPassword = $(shell read -s -p "Enter your $(1) password: " REPLY; \ |
|
10 |
echo >&2; echo "$REPLY") |
|
13 |
|
|
14 |
# User interaction |
|
15 |
|
|
16 |
confirm = $(shell read -p $(emph)"$(1) (y/n)"$(endEmph) REPLY; \ |
|
17 |
test "$REPLY" = y && echo t) |
|
18 |
|
|
19 |
getPassword = $(shell read -s -p $(emph)"Enter your $(1) password:"$(endEmph) \ |
|
20 |
REPLY; echo >&2; echo -n "$REPLY") |
|
21 |
|
|
11 | 22 |
wait = read -p $(emph)'Press ENTER to continue:'$(endEmph) REPLY |
23 |
|
|
12 | 24 |
done = echo; echo $(emph)"Finished $@"$(endEmph); echo |
13 | 25 |
|
14 |
# OS |
|
15 |
os = $(shell uname) |
|
16 |
forOs = $(patsubst %,%-$(filter Linux Darwin,$(os)),$(1)) |
|
17 |
|
|
18 | 26 |
# Env |
19 | 27 |
export PGOPTIONS = --client-min-messages=WARNING |
20 | 28 |
|
... | ... | |
32 | 40 |
|
33 | 41 |
##### |
34 | 42 |
|
35 |
install: _not_file core inputs test |
|
43 |
install: _not_file core mysql inputs test
|
|
36 | 44 |
@$(done) |
37 | 45 |
|
38 |
uninstall: _not_file rm_inputs rm_core
|
|
46 |
uninstall: _not_file rm_mysql rm_core
|
|
39 | 47 |
|
40 | 48 |
reinstall: _not_file uninstall install |
41 | 49 |
|
... | ... | |
89 | 97 |
|
90 | 98 |
##### |
91 | 99 |
|
92 |
ifneq ($(filter %_with_mysql_password,$(MAKECMDGOALS)),) |
|
93 |
mysqlAdminPassword ?= $(call getPassword,MySQL) |
|
94 |
endif |
|
95 |
|
|
96 |
with_mysql_password = $(MAKE) $@_with_mysql_password |
|
97 |
|
|
98 |
##### |
|
99 |
|
|
100 |
inputs: _not_file |
|
101 |
$(with_mysql_password) |
|
102 |
# use sub-make |
|
103 |
inputs_with_mysql_password: _not_file $(call forOs,mysql) mysql_user \ |
|
104 |
$(wildcard ../../inputs/*/) |
|
100 |
mysql: _not_file $(call forOs,mysql) mysql_user |
|
105 | 101 |
@$(done) |
106 | 102 |
|
107 |
rm_inputs: _not_file |
|
108 |
$(with_mysql_password) |
|
109 |
# use sub-make |
|
110 |
rm_inputs_with_mysql_password: _not_file rm_mysql_user |
|
103 |
rm_mysql: _not_file rm_mysql_user |
|
111 | 104 |
|
112 | 105 |
mysql-Linux: _not_file |
113 | 106 |
@echo $(emph)"If asked for MySQL root password, enter $(bienPassword)"$(endEmph) |
... | ... | |
133 | 126 |
|
134 | 127 |
mysql-: _not_file # other OSes |
135 | 128 |
|
136 |
mysqlAsAdmin = mysql --user='$(USER)' --password='$(mysqlAdminPassword)'
|
|
129 |
mysqlAsRoot = mysql --user=root --password='$(bienPassword)'
|
|
137 | 130 |
|
138 | 131 |
mysql_user: _not_file |
139 | 132 |
-$($@_cmd) |
140 | 133 |
# ignore errors about user existing |
141 | 134 |
mysql_user_cmd = echo "CREATE USER 'bien'@'localhost' IDENTIFIED BY \ |
142 |
'$(bienPassword)';"|$(mysqlAsAdmin)
|
|
135 |
'$(bienPassword)';"|$(mysqlAsRoot)
|
|
143 | 136 |
|
144 | 137 |
rm_mysql_user: _not_file |
145 |
-echo "DROP USER 'bien'@'localhost';"|$(mysqlAsAdmin)
|
|
138 |
-echo "DROP USER 'bien'@'localhost';"|$(mysqlAsRoot)
|
|
146 | 139 |
# ignore errors about user not existing |
147 | 140 |
|
148 | 141 |
##### |
149 | 142 |
|
143 |
ifneq ($(filter %_with_mysql_password,$(MAKECMDGOALS)),) |
|
144 |
mysqlAdminPassword ?= $(call getPassword,MySQL $(USER) user) |
|
145 |
endif |
|
146 |
|
|
147 |
with_mysql_password = $(MAKE) $@_with_mysql_password |
|
148 |
|
|
149 |
##### |
|
150 |
|
|
151 |
mysqlAsUser = mysql --user='$(USER)' --password='$(mysqlAdminPassword)' |
|
152 |
|
|
153 |
inputs: _not_file |
|
154 |
$(with_mysql_password) |
|
155 |
# use sub-make |
|
156 |
inputs_with_mysql_password: _not_file $(wildcard ../../inputs/*/) |
|
157 |
|
|
158 |
##### |
|
159 |
|
|
150 | 160 |
test: _not_file test-map |
151 | 161 |
@$(done) |
152 | 162 |
|
Also available in: Unified diff
scripts/Makefile: Use root MySQL user for creating bien user