Browse code

makefile: fix modules config overwrite

A config file provided by a module was installed even if a
previous version was already installed, overwriting the old
version. Now if a file with the same name already exists, the
module config file will be installed with a .sample extension
added (so only .sample will be overwritten, never an active .cfg).

Reported-by: Klaus Darilion klaus.mailinglists pernau at
Closes FlySpray#38 .

Andrei Pelinescu-Onciul authored on 04/03/2010 12:16:06
Showing 1 changed files
... ...
@@ -16,6 +16,8 @@
16 16
 #              inside modules or libs) (andrei)
17 17
 #  2009-10-01  added support for automatically installing extra utils,
18 18
 #               scripts and cfg files (andrei)
19
+#  2010-03-04  don't overwrite already installed .cfgs, save the .cfg as
20
+#              .sample in this case (andrei)
19 21
 #
20 22
 
21 23
 #
... ...
@@ -209,10 +211,17 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
209 209
 	@for r in $(MOD_INSTALL_CFGS) ; do \
210 210
 		if [ -n "$$r" ]; then \
211 211
 			if [ -f "$$r" ]; then \
212
+				n=`basename "$$r"` ; \
212 213
 				$(call try_err, $(INSTALL_TOUCH) \
213
-					$(cfg_prefix)/$(cfg_dir)/`basename "$$r"` ); \
214
+					"$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
214 215
 				$(call try_err,\
215
-					$(INSTALL_CFG)  "$$r"  $(cfg_prefix)/$(cfg_dir) ); \
216
+					$(INSTALL_CFG)  "$$r"  \
217
+						"$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
218
+				if [ -z "${skip_cfg_install}" -a \
219
+						! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
220
+					mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
221
+						$(cfg_prefix)/$(cfg_dir)$$n; \
222
+				fi ; \
216 223
 			else \
217 224
 				echo "ERROR: $$r not found" ; \
218 225
 				if [ ${err_fail} = 1 ] ; then \