Browse code

kamctl: use /tmp if $(basedir) is not set

- it is used for temporary operations at install
- without it fails to install, trying to use / for these operations

Daniel-Constantin Mierla authored on 12/02/2015 12:23:46
Showing 1 changed files
... ...
@@ -3,6 +3,12 @@ COREPATH=../..
3 3
 include $(COREPATH)/Makefile.defs
4 4
 include $(COREPATH)/config.mak
5 5
 
6
+ifeq ($(basedir),)
7
+kamctltmpdir = /tmp
8
+else
9
+kamctltmpdir = $(basedir)
10
+endif
11
+
6 12
 all:
7 13
 		@echo "No compilation needed for kamctl"
8 14
 
... ...
@@ -25,63 +31,63 @@ install-bin: $(bin_prefix)/$(bin_dir)
25 25
 		cat kamctl | \
26 26
 		sed -e "s#/usr/local/sbin#$(bin_target)#g" | \
27 27
 		sed -e "s#/usr/local/lib/kamailio#$(lib_target)#g" | \
28
-		sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(basedir)/kamctl
28
+		sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(kamctltmpdir)/kamctl
29 29
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/kamctl
30
-		$(INSTALL_BIN) $(basedir)/kamctl $(bin_prefix)/$(bin_dir)
31
-		rm -fr $(basedir)/kamctl
30
+		$(INSTALL_BIN) $(kamctltmpdir)/kamctl $(bin_prefix)/$(bin_dir)
31
+		rm -fr $(kamctltmpdir)/kamctl
32 32
 		sed -e "s#/usr/local/sbin#$(bin_target)#g" \
33
-			< kamctl.base > $(basedir)/kamctl.base
33
+			< kamctl.base > $(kamctltmpdir)/kamctl.base
34 34
 		mkdir -p $(modules_prefix)/$(lib_dir)/kamctl 
35 35
 		$(INSTALL_TOUCH) \
36 36
 			$(modules_prefix)/$(lib_dir)/kamctl
37
-		$(INSTALL_CFG) $(basedir)/kamctl.base \
37
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.base \
38 38
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.base
39
-		rm -fr $(basedir)/kamctl.base
39
+		rm -fr $(kamctltmpdir)/kamctl.base
40 40
 		sed -e "s#/usr/local#$(bin_target)#g" \
41
-			< kamctl.ctlbase > $(basedir)/kamctl.ctlbase
42
-		$(INSTALL_CFG) $(basedir)/kamctl.ctlbase \
41
+			< kamctl.ctlbase > $(kamctltmpdir)/kamctl.ctlbase
42
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.ctlbase \
43 43
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.ctlbase
44
-		rm -fr $(basedir)/kamctl.ctlbase
44
+		rm -fr $(kamctltmpdir)/kamctl.ctlbase
45 45
 		sed -e "s#/usr/local#$(bin_target)#g" \
46
-			< kamctl.fifo > $(basedir)/kamctl.fifo
47
-		$(INSTALL_CFG) $(basedir)/kamctl.fifo \
46
+			< kamctl.fifo > $(kamctltmpdir)/kamctl.fifo
47
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.fifo \
48 48
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.fifo
49
-		rm -fr $(basedir)/kamctl.fifo
49
+		rm -fr $(kamctltmpdir)/kamctl.fifo
50 50
 		sed -e "s#/usr/local#$(bin_target)#g" \
51
-			< kamctl.ser > $(basedir)/kamctl.ser
52
-		$(INSTALL_CFG) $(basedir)/kamctl.ser \
51
+			< kamctl.ser > $(kamctltmpdir)/kamctl.ser
52
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.ser \
53 53
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser
54
-		rm -fr $(basedir)/kamctl.ser
54
+		rm -fr $(kamctltmpdir)/kamctl.ser
55 55
 		sed -e "s#/usr/local#$(bin_target)#g" \
56
-			< kamctl.ser_mi > $(basedir)/kamctl.ser_mi
57
-		$(INSTALL_CFG) $(basedir)/kamctl.ser_mi \
56
+			< kamctl.ser_mi > $(kamctltmpdir)/kamctl.ser_mi
57
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.ser_mi \
58 58
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.ser_mi
59
-		rm -fr $(basedir)/kamctl.ser_mi
59
+		rm -fr $(kamctltmpdir)/kamctl.ser_mi
60 60
 		sed -e "s#/usr/local#$(bin_target)#g" \
61
-			< kamctl.unixsock > $(basedir)/kamctl.unixsock
62
-		$(INSTALL_CFG) $(basedir)/kamctl.unixsock \
61
+			< kamctl.unixsock > $(kamctltmpdir)/kamctl.unixsock
62
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.unixsock \
63 63
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.unixsock
64
-		rm -fr $(basedir)/kamctl.unixsock
64
+		rm -fr $(kamctltmpdir)/kamctl.unixsock
65 65
 		sed -e "s#/usr/local#$(bin_target)#g" \
66
-			< kamctl.sqlbase > $(basedir)/kamctl.sqlbase
67
-		$(INSTALL_CFG) $(basedir)/kamctl.sqlbase \
66
+			< kamctl.sqlbase > $(kamctltmpdir)/kamctl.sqlbase
67
+		$(INSTALL_CFG) $(kamctltmpdir)/kamctl.sqlbase \
68 68
 			$(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlbase
69
-		rm -fr $(basedir)/kamctl.sqlbase
69
+		rm -fr $(kamctltmpdir)/kamctl.sqlbase
70 70
 		# install db setup base script
71 71
 		sed -e "s#/usr/local/sbin#$(bin_target)#g" \
72 72
 			-e "s#/usr/local/etc/kamailio#$(cfg_target)#g" \
73 73
 			-e "s#/usr/local/share/kamailio#$(data_target)#g" \
74
-			< kamdbctl.base > $(basedir)/kamdbctl.base
75
-		$(INSTALL_CFG) $(basedir)/kamdbctl.base \
74
+			< kamdbctl.base > $(kamctltmpdir)/kamdbctl.base
75
+		$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.base \
76 76
 			$(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.base
77
-		rm -fr $(basedir)/kamdbctl.base
77
+		rm -fr $(kamctltmpdir)/kamdbctl.base
78 78
 		cat kamdbctl | \
79 79
 		sed -e "s#/usr/local/sbin#$(bin_target)#g" | \
80 80
 		sed -e "s#/usr/local/lib/kamailio#$(lib_target)#g" | \
81
-		sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(basedir)/kamdbctl
81
+		sed -e "s#/usr/local/etc/kamailio#$(cfg_target)#g"  >$(kamctltmpdir)/kamdbctl
82 82
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/kamdbctl
83
-		$(INSTALL_BIN) $(basedir)/kamdbctl $(bin_prefix)/$(bin_dir)
84
-		rm -fr $(basedir)/kamdbctl
83
+		$(INSTALL_BIN) $(kamctltmpdir)/kamdbctl $(bin_prefix)/$(bin_dir)
84
+		rm -fr $(kamctltmpdir)/kamdbctl
85 85
 
86 86
 install-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
87 87
 		sed -e "s#/etc/$(NAME)/$(NAME)\.cfg#$(cfg_target)$(NAME).cfg#g" \
... ...
@@ -105,15 +111,15 @@ install-modules: $(bin_prefix)/$(bin_dir)
105 105
 		if [ "$(MYSQLON)" = "yes" ]; then \
106 106
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
107 107
 			sed -e "s#/usr/local/sbin#$(bin_target)#g" \
108
-				< kamctl.mysql > $(basedir)/kamctl.mysql ; \
109
-			$(INSTALL_CFG) $(basedir)/kamctl.mysql \
108
+				< kamctl.mysql > $(kamctltmpdir)/kamctl.mysql ; \
109
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.mysql \
110 110
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.mysql ; \
111
-			rm -fr $(basedir)/kamctl.mysql ; \
111
+			rm -fr $(kamctltmpdir)/kamctl.mysql ; \
112 112
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
113
-			< kamdbctl.mysql > $(basedir)/kamdbctl.mysql ; \
113
+			< kamdbctl.mysql > $(kamctltmpdir)/kamdbctl.mysql ; \
114 114
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.mysql ; \
115
-			$(INSTALL_CFG) $(basedir)/kamdbctl.mysql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
116
-			rm -fr $(basedir)/kamdbctl.mysql ; \
115
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.mysql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
116
+			rm -fr $(kamctltmpdir)/kamdbctl.mysql ; \
117 117
 			mkdir -p $(data_prefix)/$(data_dir)/mysql ; \
118 118
 			for FILE in $(wildcard mysql/*) ; do \
119 119
 				if [ -f $$FILE ] ; then \
... ...
@@ -128,15 +134,15 @@ install-modules: $(bin_prefix)/$(bin_dir)
128 128
 		if [ "$(PGSQLON)" = "yes" ]; then \
129 129
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
130 130
 			sed -e "s#/usr/local/sbin#$(bin_target)#g" \
131
-				< kamctl.pgsql > $(basedir)/kamctl.pgsql ; \
132
-			$(INSTALL_CFG) $(basedir)/kamctl.pgsql \
131
+				< kamctl.pgsql > $(kamctltmpdir)/kamctl.pgsql ; \
132
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.pgsql \
133 133
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.pgsql ; \
134
-			rm -fr $(basedir)/kamctl.pgsql ; \
134
+			rm -fr $(kamctltmpdir)/kamctl.pgsql ; \
135 135
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
136
-				< kamdbctl.pgsql > $(basedir)/kamdbctl.pgsql ; \
136
+				< kamdbctl.pgsql > $(kamctltmpdir)/kamdbctl.pgsql ; \
137 137
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.pgsql ; \
138
-			$(INSTALL_CFG) $(basedir)/kamdbctl.pgsql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
139
-			rm -fr $(basedir)/kamdbctl.pgsql ; \
138
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.pgsql $(modules_prefix)/$(lib_dir)/kamctl/ ; \
139
+			rm -fr $(kamctltmpdir)/kamdbctl.pgsql ; \
140 140
 			mkdir -p $(data_prefix)/$(data_dir)/postgres ; \
141 141
 			for FILE in $(wildcard postgres/*) ; do \
142 142
 				if [ -f $$FILE ] ; then \
... ...
@@ -151,20 +157,20 @@ install-modules: $(bin_prefix)/$(bin_dir)
151 151
 		if [ "$(ORACLEON)" = "yes" ]; then \
152 152
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
153 153
 			sed -e "s#/usr/local/sbin#$(bin_target)#g" \
154
-				< kamctl.oracle > $(basedir)/kamctl.oracle ; \
155
-			$(INSTALL_CFG) $(basedir)/kamctl.oracle \
154
+				< kamctl.oracle > $(kamctltmpdir)/kamctl.oracle ; \
155
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.oracle \
156 156
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.oracle ; \
157
-			rm -fr $(basedir)/kamctl.oracle ; \
157
+			rm -fr $(kamctltmpdir)/kamctl.oracle ; \
158 158
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
159
-			< kamdbctl.oracle > $(basedir)/kamdbctl.oracle ; \
159
+			< kamdbctl.oracle > $(kamctltmpdir)/kamdbctl.oracle ; \
160 160
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.oracle ; \
161
-			$(INSTALL_CFG) $(basedir)/kamdbctl.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
162
-			rm -fr $(basedir)/kamdbctl.oracle ; \
161
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
162
+			rm -fr $(kamctltmpdir)/kamdbctl.oracle ; \
163 163
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
164
-			< kamdbfunc.oracle > $(basedir)/kamdbfunc.oracle ; \
164
+			< kamdbfunc.oracle > $(kamctltmpdir)/kamdbfunc.oracle ; \
165 165
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbfunc.oracle ; \
166
-			$(INSTALL_CFG) $(basedir)/kamdbfunc.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
167
-			rm -fr $(basedir)/kamdbfunc.oracle ; \
166
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbfunc.oracle $(modules_prefix)/$(lib_dir)/kamctl/ ; \
167
+			rm -fr $(kamctltmpdir)/kamdbfunc.oracle ; \
168 168
 			mkdir -p $(data_prefix)/$(data_dir)/oracle ; \
169 169
 			for FILE in $(wildcard oracle/*) ; do \
170 170
 				if [ -f $$FILE ] ; then \
... ...
@@ -199,15 +205,15 @@ install-modules: $(bin_prefix)/$(bin_dir)
199 199
 		if [ "$(BERKELEYDBON)" = "yes" ]; then \
200 200
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
201 201
 			sed -e "s#/usr/local/share/kamailio/#$(data_target)#g" \
202
-				< kamctl.db_berkeley > $(basedir)/kamctl.db_berkeley ; \
203
-			$(INSTALL_CFG) $(basedir)/kamctl.db_berkeley \
202
+				< kamctl.db_berkeley > $(kamctltmpdir)/kamctl.db_berkeley ; \
203
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.db_berkeley \
204 204
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.db_berkeley ; \
205
-			rm -fr $(basedir)/kamctl.db_berkeley ; \
205
+			rm -fr $(kamctltmpdir)/kamctl.db_berkeley ; \
206 206
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
207
-				< kamdbctl.db_berkeley > $(basedir)/kamdbctl.db_berkeley ; \
207
+				< kamdbctl.db_berkeley > $(kamctltmpdir)/kamdbctl.db_berkeley ; \
208 208
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.db_berkeley ; \
209
-			$(INSTALL_CFG) $(basedir)/kamdbctl.db_berkeley $(modules_prefix)/$(lib_dir)/kamctl/ ; \
210
-			rm -fr $(basedir)/kamdbctl.db_berkeley ; \
209
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.db_berkeley $(modules_prefix)/$(lib_dir)/kamctl/ ; \
210
+			rm -fr $(kamctltmpdir)/kamdbctl.db_berkeley ; \
211 211
 			mkdir -p $(data_prefix)/$(data_dir)/db_berkeley/kamailio ; \
212 212
 			for FILE in $(wildcard db_berkeley/kamailio/*) ; do \
213 213
 				if [ -f $$FILE ] ; then \
... ...
@@ -224,15 +230,15 @@ install-modules: $(bin_prefix)/$(bin_dir)
224 224
 		if [ "$(DBTEXTON)" = "yes" ]; then \
225 225
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
226 226
 			sed -e "s#/usr/local/share/kamailio/#$(data_target)#g" \
227
-				< kamctl.dbtext > $(basedir)/kamctl.dbtext ; \
228
-			$(INSTALL_CFG) $(basedir)/kamctl.dbtext \
227
+				< kamctl.dbtext > $(kamctltmpdir)/kamctl.dbtext ; \
228
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.dbtext \
229 229
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.dbtext ; \
230
-			rm -fr $(basedir)/kamctl.dbtext ; \
230
+			rm -fr $(kamctltmpdir)/kamctl.dbtext ; \
231 231
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
232
-				< kamdbctl.dbtext > $(basedir)/kamdbctl.dbtext ; \
232
+				< kamdbctl.dbtext > $(kamctltmpdir)/kamdbctl.dbtext ; \
233 233
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.dbtext ; \
234
-			$(INSTALL_CFG) $(basedir)/kamdbctl.dbtext $(modules_prefix)/$(lib_dir)/kamctl/ ; \
235
-			rm -fr $(basedir)/kamdbctl.dbtext ; \
234
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.dbtext $(modules_prefix)/$(lib_dir)/kamctl/ ; \
235
+			rm -fr $(kamctltmpdir)/kamdbctl.dbtext ; \
236 236
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb ; \
237 237
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb/dbtextdb.py ; \
238 238
 			$(INSTALL_BIN) dbtextdb/dbtextdb.py $(modules_prefix)/$(lib_dir)/kamctl/dbtextdb/ ; \
... ...
@@ -250,15 +256,15 @@ install-modules: $(bin_prefix)/$(bin_dir)
250 250
 		if [ "$(SQLITEON)" = "yes" ]; then \
251 251
 			mkdir -p $(modules_prefix)/$(lib_dir)/kamctl ; \
252 252
 			sed -e "s#/usr/local/sbin#$(bin_target)#g" \
253
-				< kamctl.sqlite > $(basedir)/kamctl.sqlite ; \
254
-			$(INSTALL_CFG) $(basedir)/kamctl.sqlite \
253
+				< kamctl.sqlite > $(kamctltmpdir)/kamctl.sqlite ; \
254
+			$(INSTALL_CFG) $(kamctltmpdir)/kamctl.sqlite \
255 255
 				$(modules_prefix)/$(lib_dir)/kamctl/kamctl.sqlite ; \
256
-			rm -fr $(basedir)/kamctl.sqlite ; \
256
+			rm -fr $(kamctltmpdir)/kamctl.sqlite ; \
257 257
 			sed -e "s#/usr/local/share/kamailio#$(data_target)#g" \
258
-				< kamdbctl.sqlite > $(basedir)/kamdbctl.sqlite ; \
258
+				< kamdbctl.sqlite > $(kamctltmpdir)/kamdbctl.sqlite ; \
259 259
 			$(INSTALL_TOUCH) $(modules_prefix)/$(lib_dir)/kamctl/kamdbctl.sqlite ; \
260
-			$(INSTALL_CFG) $(basedir)/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
261
-			rm -fr $(basedir)/kamdbctl.sqlite ; \
260
+			$(INSTALL_CFG) $(kamctltmpdir)/kamdbctl.sqlite $(modules_prefix)/$(lib_dir)/kamctl/ ; \
261
+			rm -fr $(kamctltmpdir)/kamdbctl.sqlite ; \
262 262
 			mkdir -p $(data_prefix)/$(data_dir)/db_sqlite ; \
263 263
 			for FILE in $(wildcard db_sqlite/*) ; do \
264 264
 				if [ -f $$FILE ] ; then \