makefile: fix modules config overwrite
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 4 Mar 2010 12:16:06 +0000 (13:16 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 4 Mar 2010 12:16:06 +0000 (13:16 +0100)
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 .

Makefile.modules

index 1f226ba..27cd0cd 100644 (file)
@@ -16,6 +16,8 @@
 #              inside modules or libs) (andrei)
 #  2009-10-01  added support for automatically installing extra utils,
 #               scripts and cfg files (andrei)
+#  2010-03-04  don't overwrite already installed .cfgs, save the .cfg as
+#              .sample in this case (andrei)
 #
 
 #
@@ -209,10 +211,17 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
        @for r in $(MOD_INSTALL_CFGS) ; do \
                if [ -n "$$r" ]; then \
                        if [ -f "$$r" ]; then \
+                               n=`basename "$$r"` ; \
                                $(call try_err, $(INSTALL_TOUCH) \
-                                       $(cfg_prefix)/$(cfg_dir)/`basename "$$r"` ); \
+                                       "$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
                                $(call try_err,\
-                                       $(INSTALL_CFG)  "$$r"  $(cfg_prefix)/$(cfg_dir) ); \
+                                       $(INSTALL_CFG)  "$$r"  \
+                                               "$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
+                               if [ -z "${skip_cfg_install}" -a \
+                                               ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
+                                       mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
+                                               $(cfg_prefix)/$(cfg_dir)$$n; \
+                               fi ; \
                        else \
                                echo "ERROR: $$r not found" ; \
                                if [ ${err_fail} = 1 ] ; then \