]> source.dussan.org Git - rspamd.git/commitdiff
Add LOCALSTATES_PREFIX variable for setting where should be runtime files for rspamd.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 8 Aug 2011 13:20:34 +0000 (17:20 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 8 Aug 2011 13:20:34 +0000 (17:20 +0400)
Suggested by: Vasiliy G. Tolstov

CMakeLists.txt
conf/rspamd-basic.xml.in

index 3ed111e593353d2ba268b5971a3ba659a9808b14..924ee20d873a8abb28f25c34894627225c416108 100644 (file)
@@ -48,7 +48,7 @@ IF(CMAKE_INSTALL_PREFIX)
     SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 ENDIF(CMAKE_INSTALL_PREFIX)
 
-# Platform specific routines
+# Platform specific configuration
 IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DFREEBSD")
        CONFIGURE_FILE(freebsd/rspamd.sh.in freebsd/rspamd @ONLY)
@@ -63,6 +63,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
        ENDIF(NOT MAN_PREFIX)
+       IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
            SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
        ELSE(CMAKE_INSTALL_PREFIX)
        IF(NOT ETC_PREFIX)
@@ -71,6 +74,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX /usr/local/man)
        ENDIF(NOT MAN_PREFIX)
+       IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
        IF(NOT PREFIX)
                SET(PREFIX /usr/local)
        ENDIF(NOT PREFIX)
@@ -89,8 +95,15 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE -DDARWIN")
     
     IF(CMAKE_INSTALL_PREFIX)
-           SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
-           SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+       IF(NOT ETC_PREFIX)
+               SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+           ENDIF(NOT ETC_PREFIX)
+           IF(NOT MAN_PREFIX)
+               SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+               ENDIF(NOT MAN_PREFIX)
+           IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
            SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
        ELSE(CMAKE_INSTALL_PREFIX)      
        IF(NOT ETC_PREFIX)
@@ -99,6 +112,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX /usr/local/man)
        ENDIF(NOT MAN_PREFIX)
+       IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
        IF(NOT PREFIX)
                SET(PREFIX /usr/local)
        ENDIF(NOT PREFIX)
@@ -124,6 +140,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
            IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/share/man")
            ENDIF(NOT MAN_PREFIX)
+           IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
            
            SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
        ELSE(CMAKE_INSTALL_PREFIX)      
@@ -136,6 +155,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX /usr/share/man)
        ENDIF(NOT MAN_PREFIX)
+       IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
     ENDIF(CMAKE_INSTALL_PREFIX)
     
     # Workaround with architecture specific includes
@@ -157,8 +179,15 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
        SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -DSOLARIS")
        IF(CMAKE_INSTALL_PREFIX)
-           SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
-           SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+               IF(NOT ETC_PREFIX)
+               SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
+           ENDIF(NOT ETC_PREFIX)
+           IF(NOT MAN_PREFIX)
+               SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+           ENDIF(NOT MAN_PREFIX)
+           IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
            SET(PREFIX "${CMAKE_INSTALL_PREFIX}")
        ELSE(CMAKE_INSTALL_PREFIX)    
        IF(NOT ETC_PREFIX)
@@ -170,6 +199,9 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
        IF(NOT MAN_PREFIX)
                SET(MAN_PREFIX /usr/share/man)
        ENDIF(NOT MAN_PREFIX)
+       IF(NOT LOCALSTATES_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(NOT LOCALSTATES_PREFIX)
     ENDIF(CMAKE_INSTALL_PREFIX)
     
        LIST(APPEND CMAKE_REQUIRED_LIBRARIES rt)
@@ -179,16 +211,33 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
        MESSAGE(STATUS "Configuring for Solaris")
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
+# Check prefixes
 IF(NOT ETC_PREFIX)
        IF(CMAKE_INSTALL_PREFIX)
                MESSAGE(WARNING "Your system is unknown for rspamd, assume defining ETC_PREFIX and MAN_PREFIX by -D option, now ETC_PREFIX and MAN_PREFIX are relative to ${CMAKE_INSTALL_PREFIX}")
                SET(ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc")
-               SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
        ELSE(CMAKE_INSTALL_PREFIX)
                MESSAGE(FATAL_ERROR "Your system is unknown for rspamd and no CMAKE_INSTALL_PREFIX specified, assume defining CMAKE_INSTALL_PREFIX")
        ENDIF(CMAKE_INSTALL_PREFIX) 
        MESSAGE(STATUS "Configuring for ${CMAKE_SYSTEM_NAME}")
 ENDIF(NOT ETC_PREFIX)
+IF(NOT MAN_PREFIX)
+       IF(CMAKE_INSTALL_PREFIX)
+               SET(MAN_PREFIX "${CMAKE_INSTALL_PREFIX}/man")
+       ENDIF(CMAKE_INSTALL_PREFIX) 
+ENDIF(NOT MAN_PREFIX)
+IF(NOT LOCALSTATES_PREFIX)
+       IF(CMAKE_INSTALL_PREFIX)
+               SET(LOCALSTATES_PREFIX "/var/run/rspamd")
+       ENDIF(CMAKE_INSTALL_PREFIX) 
+ENDIF(NOT LOCALSTATES_PREFIX)
+
+# Now CMAKE_INSTALL_PREFIX is a base prefix for everything
+# ETC_PREFIX - for configuration
+# MAN_PREFIX - for manual pages
+# LOCALSTATES_PREFIX - for runtime files
+
+# Now find libraries and headers
 
 INCLUDE(FindLua51)
 # Check for luajit
@@ -354,12 +403,16 @@ IF(ENABLE_PROFILING MATCHES "ON")
        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
 ENDIF(ENABLE_PROFILING MATCHES "ON")
 
+# Static build
+
 IF(ENABLE_STATIC MATCHES "ON")
        SET(BUILD_STATIC 1)
        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
        MESSAGE(STATUS "Static build of rspamd, no custom plugins support")
 ENDIF(ENABLE_STATIC MATCHES "ON")
 
+# Google performance tools
+
 IF(ENABLE_GPERF_TOOLS MATCHES "ON")
        FIND_PATH(GPERF_INCLUDE google/profiler.h PATHS /opt/include
                                                                                                        /usr/include
@@ -380,7 +433,7 @@ IF(ENABLE_GPERF_TOOLS MATCHES "ON")
        SET(WITH_GPERF_TOOLS 1)
 ENDIF(ENABLE_GPERF_TOOLS MATCHES "ON")
 
-
+# Find util library
 
 FIND_LIBRARY(LIBUTIL_LIBRARY NAMES util PATHS  /lib
                                                        /opt/lib
@@ -397,6 +450,8 @@ IF(LIBUTIL_LIBRARY)
                                DOC "Path to libutil header")
 ENDIF(LIBUTIL_LIBRARY)
 
+
+# Check platform specific includes
 CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
 CHECK_INCLUDE_FILES(sys/time.h  HAVE_SYS_TIME_H)
 CHECK_INCLUDE_FILES(sys/uio.h   HAVE_SYS_UIO_H)
@@ -439,6 +494,7 @@ CHECK_INCLUDE_FILES(glob.h HAVE_GLOB_H)
 CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H)
 CHECK_INCLUDE_FILES(sys/sendfile.h HAVE_SYS_SENDFILE_H)
 
+# Some dependencies
 IF(HAVE_SYS_WAIT_H)
        LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/wait.h)
 ENDIF(HAVE_SYS_WAIT_H)
@@ -449,6 +505,7 @@ IF(HAVE_SYS_TIME_H)
        LIST(APPEND CMAKE_REQUIRED_INCLUDES sys/time.h)
 ENDIF(HAVE_SYS_TIME_H)
 
+# Check platform API
 CHECK_FUNCTION_EXISTS(setproctitle HAVE_SETPROCTITLE)
 CHECK_FUNCTION_EXISTS(getpagesize HAVE_GETPAGESIZE)
 CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP)
@@ -462,6 +519,7 @@ CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
 CHECK_FUNCTION_EXISTS(setitimer HAVE_SETITIMER)
 CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
 
+# Check macros
 CHECK_SYMBOL_EXISTS(PATH_MAX limits.h HAVE_PATH_MAX)
 CHECK_SYMBOL_EXISTS(MAXPATHLEN sys/param.h HAVE_MAXPATHLEN)
 CHECK_SYMBOL_EXISTS(MAP_SHARED sys/mman.h HAVE_MMAP_SHARED)
@@ -477,12 +535,14 @@ ELSE(HAVE_CLOCK_GETTIME)
        CHECK_INCLUDE_FILES(sys/timeb.h HAVE_SYS_TIMEB_H)
 ENDIF(HAVE_CLOCK_GETTIME)
 
+# Check asm pause instruction
 CHECK_C_SOURCE_COMPILES ("#include <sys/types.h>
                           int main (int argc, char **argv) {
                                                        __asm __volatile(\"pause\");
                                                        return 0;
                                                  }" HAVE_ASM_PAUSE)
 
+# Check queue.h compatibility
 IF(NOT HAVE_COMPATIBLE_QUEUE_H)
        INCLUDE_DIRECTORIES(compat)
 ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H)
@@ -490,6 +550,7 @@ ENDIF(NOT HAVE_COMPATIBLE_QUEUE_H)
 
 SET(CONTRIBSRC "")
 
+# Optimization flags
 IF(ENABLE_OPTIMIZATION MATCHES "ON")
        SET(CMAKE_C_OPT_FLAGS "-O3")
 ELSE(ENABLE_OPTIMIZATION MATCHES "ON")
@@ -725,13 +786,13 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT)
        IF(ENABLE_REDIRECTOR MATCHES "ON")
                INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/freebsd/redirector DESTINATION ${ETC_PREFIX}/rc.d)
        ENDIF(ENABLE_REDIRECTOR MATCHES "ON")
-       INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/var/run/rspamd)")
-       INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/var/run/rspamd/)")
+       INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
+       INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND NOT BUILD_PORT)
 IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
        INSTALL(PROGRAMS "linux/${LINUX_START_SCRIPT}" DESTINATION ${ETC_PREFIX}/init.d RENAME rspamd)
-       INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/var/run/rspamd)")
-       INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/var/run/rspamd/)")
+       INSTALL(CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
+       INSTALL(CODE "EXECUTE_PROCESS(COMMAND chown ${RSPAMD_USER}:${RSPAMD_GROUP} \$ENV{DESTDIR}/${LOCALSTATES_PREFIX})")
 ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 
 # CPack section
index 7115199fab59d87d09fb909362cf83c1de147338..af68f52851b290562181bbbed2dd2addd9857c71 100644 (file)
@@ -8,7 +8,7 @@
   <!-- Temporary directory -->
   <tempdir>/tmp</tempdir>
   <!-- Path to pid file -->
-  <pidfile>/var/run/rspamd/rspamd.pid</pidfile>
+  <pidfile>@LOCALSTATES_PREFIX@/rspamd.pid</pidfile>
   <!-- Turned on C filters -->
   <filters>regexp,surbl,chartable,fuzzy_check,spf</filters>
   <!-- Maximum size of statistics mapped in memory -->
@@ -24,7 +24,7 @@
   <!-- DNS retransmits count -->
   <dns_retransmits>5</dns_retransmits>
   <!-- File for saving settings of symbols cache -->
-  <cache_file>/var/run/rspamd/symbols.cache</cache_file>
+  <cache_file>@LOCALSTATES_PREFIX@/symbols.cache</cache_file>
 </options>
 <!-- End of options section -->
 
   <count>1</count>
   <maxfiles>2048</maxfiles>
 <!-- Other params -->
-    <hashfile>/var/run/rspamd/fuzzy.db</hashfile>
+    <hashfile>@LOCALSTATES_PREFIX@/fuzzy.db</hashfile>
     <use_judy>yes</use_judy>
 </worker>
 <worker>
 <!-- 
 <module name="trie">
   <rule>TRIE1:bad pattern</rule>
-  <rule>TRIE2:file:///var/run/rspamd/bad_patterns.list</rule>
+  <rule>TRIE2:file://@LOCALSTATES_PREFIX@/bad_patterns.list</rule>
 </module>
 -->
 
  <statfile>
   <symbol>WINNOW_HAM</symbol>
   <size>100M</size>
-  <path>/var/run/rspamd/data.ham</path>
+  <path>@LOCALSTATES_PREFIX@/data.ham</path>
  </statfile>
  <statfile>
   <symbol>WINNOW_SPAM</symbol>
   <size>100M</size>
-  <path>/var/run/rspamd/data.spam</path>
+  <path>@LOCALSTATES_PREFIX@/data.spam</path>
  </statfile>
 </classifier>
 -->
  <statfile>
   <symbol>BAYES_HAM</symbol>
   <size>10M</size>
-  <path>/var/run/rspamd/bayes_slave.ham</path>
+  <path>@LOCALSTATES_PREFIX@/bayes_slave.ham</path>
   <binlog_master>localhost:11334</binlog_master>
   <binlog>slave</binlog>
  </statfile>
  <statfile>
   <symbol>BAYES_SPAM</symbol>
   <size>10M</size>
-  <path>/var/run/rspamd/bayes_slave.spam</path>
+  <path>@LOCALSTATES_PREFIX@/bayes_slave.spam</path>
   <binlog>slave</binlog>
   <binlog_master>localhost:11334</binlog_master>
  </statfile>
  <statfile>
   <symbol>BAYES_HAM_RU</symbol>
   <size>50M</size>
-  <path>/var/run/rspamd/bayes_ru.ham</path>
+  <path>@LOCALSTATES_PREFIX@/bayes_ru.ham</path>
   <param name="language">ru</param>
  </statfile>
  <statfile>
   <symbol>BAYES_SPAM_RU</symbol>
   <size>50M</size>
-  <path>/var/run/rspamd/bayes_ru.spam</path>
+  <path>@LOCALSTATES_PREFIX@/bayes_ru.spam</path>
   <param name="language">ru</param>
  </statfile>
  <statfile>
   <symbol>BAYES_HAM</symbol>
   <size>50M</size>
-  <path>/var/run/rspamd/bayes.ham</path>
+  <path>@LOCALSTATES_PREFIX@/bayes.ham</path>
  </statfile>
  <statfile>
   <symbol>BAYES_SPAM</symbol>
   <size>50M</size>
-  <path>/var/run/rspamd/bayes.spam</path>
+  <path>@LOCALSTATES_PREFIX@/bayes.spam</path>
  </statfile>
 </classifier>
 -->
  <statfile>
   <symbol>BAYES_HAM</symbol>
   <size>10M</size>
-  <path>/var/run/rspamd/bayes.ham</path>
+  <path>@LOCALSTATES_PREFIX@/bayes.ham</path>
  </statfile>
  <statfile>
   <symbol>BAYES_SPAM</symbol>
   <size>10M</size>
-  <path>/var/run/rspamd/bayes.spam</path>
+  <path>@LOCALSTATES_PREFIX@/bayes.spam</path>
  </statfile>
 </classifier>