aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-02 14:19:25 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2013-12-02 14:19:25 +0000
commit4d58641eb7449ac88b423345e7d1b197c2ee6b4d (patch)
tree995ec143f961f11ce8cdc6a37ea7bed562fbbaf9 /CMakeLists.txt
parent8d0e298836fb8b7cbc4f7d8dd7204fd702c6ddde (diff)
downloadrspamd-4d58641eb7449ac88b423345e7d1b197c2ee6b4d.tar.gz
rspamd-4d58641eb7449ac88b423345e7d1b197c2ee6b4d.zip
Do not overwrite config files.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt43
1 files changed, 37 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a065291f4..2980e49bb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -235,6 +235,32 @@ MACRO(FindLua _major _minor)
ENDIF(ENABLE_LUAJIT MATCHES "ON")
ENDMACRO(FindLua _major _minor)
+FUNCTION(INSTALL_IF_NOT_EXISTS src dest)
+ IF(NOT IS_ABSOLUTE "${src}")
+ SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
+ ENDIF()
+ GET_FILENAME_COMPONENT(src_name "${src}" NAME)
+ IF(NOT IS_ABSOLUTE "${dest}")
+ SET(dest "${CMAKE_INSTALL_PREFIX}/${dest}")
+ ENDIF()
+ INSTALL(CODE "
+ IF(NOT EXISTS \"\$ENV{DESTDIR}${dest}/${src_name}\")
+ #FILE(INSTALL \"${src}\" DESTINATION \"${dest}\")
+ MESSAGE(STATUS \"Installing: \$ENV{DESTDIR}${dest}/${src_name}\")
+ EXECUTE_PROCESS(COMMAND \${CMAKE_COMMAND} -E copy \"${src}\"
+ \"\$ENV{DESTDIR}${dest}/${src_name}\"
+ RESULT_VARIABLE copy_result
+ ERROR_VARIABLE error_output)
+ IF(copy_result)
+ MESSAGE(FATAL_ERROR \${error_output})
+ ENDIF()
+ ELSE()
+ MESSAGE(STATUS \"Skipping : \$ENV{DESTDIR}${dest}/${src_name}\")
+ ENDIF()
+ ")
+ENDFUNCTION(INSTALL_IF_NOT_EXISTS)
+
+
############################# CONFIG SECTION #############################################
# Initial set
@@ -1006,7 +1032,9 @@ SET(CONFFILES
conf/options.conf
conf/rspamd.conf
conf/statistic.conf
- conf/workers.conf)
+ conf/workers.conf
+ conf/2tld.inc
+ conf/surbl-whitelist.inc)
######################### LINK SECTION ###############################
@@ -1085,11 +1113,14 @@ INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${CONFDIR})")
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${EXAMPLESDIR})")
INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${PLUGINSDIR}/lua)")
-INSTALL(FILES conf/2tld.inc RENAME 2tld.inc DESTINATION ${CONFDIR})
-
-INSTALL(FILES conf/surbl-whitelist.inc RENAME surbl-whitelist.inc DESTINATION ${CONFDIR})
-
-INSTALL(FILES ${CONFFILES} DESTINATION ${CONFDIR})
+# Install configs only if they are unchanged
+LIST(LENGTH CONFFILES CONFLIST_COUNT)
+MATH(EXPR CONFLIST_MAX ${CONFLIST_COUNT}-1)
+
+FOREACH(CONF_IDX RANGE ${CONFLIST_MAX})
+ LIST(GET CONFFILES ${CONF_IDX} CONF_FILE)
+ INSTALL_IF_NOT_EXISTS(${CONF_FILE} ${CONFDIR})
+ENDFOREACH(CONF_IDX RANGE ${CONFLIST_MAX})
# Lua plugins