Parcourir la source

Unified build for debian, ubuntu, redhat (centos).

klirichek il y a 8 ans
Parent
commit
bab96cc07f

+ 14 - 43
CMakeLists.txt

@@ -501,14 +501,6 @@ if ( WIN32 )
 	endif ()
 endif ()
 
-set ( SPHINX_PACKAGE_SUFFIX "" )
-FOREACH ( SUFFIX ${PKGSUFFIXES} )
-	set ( SPHINX_PACKAGE_SUFFIX "${SPHINX_PACKAGE_SUFFIX}-${SUFFIX}" )
-endforeach ()
-
-add_subdirectory ( src )
-add_subdirectory ( test )
-
 # a bit of installation stuff
 if ( WIN32 )
 	install ( DIRECTORY api doc contrib DESTINATION share/doc COMPONENT doc )
@@ -519,7 +511,7 @@ if ( WIN32 )
 	install ( DIRECTORY DESTINATION data COMPONENT config )
 endif ()
 
-configure_file ( "COPYING" "${MANTICORE_BINARY_DIR}/COPYING.txt" @ONLY )
+configure_file ( "COPYING" "${MANTICORE_BINARY_DIR}/COPYING.txt" COPYONLY )
 
 set ( CPACK_SOURCE_IGNORE_FILES "/\\\\.idea/" "/\\\\.git/"
 		"/\\\\.svn/" "/autom4te\\\\.cache/" "/bin/" "/junk/" "/win/"
@@ -530,7 +522,6 @@ set ( CPACK_PACKAGE_CONTACT "${PACKAGE_NAME} package builds <build@manticoresear
 set ( CPACK_PACKAGE_NAME "${PACKAGE_NAME}" )
 set ( CPACK_PACKAGE_VENDOR "${COMPANY_NAME}" )
 set ( CPACK_RESOURCE_FILE_LICENSE "${MANTICORE_BINARY_DIR}/COPYING.txt" )
-
 set ( CPACK_COMPONENT_APPLICATIONS_GROUP "bin" )
 set ( CPACK_COMPONENT_GROUP_BIN_DISPLAY_NAME "Runtime" )
 set ( CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "${PACKAGE_NAME} applications" )
@@ -542,20 +533,12 @@ set ( CPACK_COMPONENT_DBGSYMBOLS_GROUP "dbg" )
 set ( CPACK_COMPONENT_GROUP_DBG_DISPLAY_NAME "Development" )
 set ( CPACK_COMPONENT_DBGSYMBOLS_DISPLAY_NAME "Debug symbols" )
 set ( CPACK_COMPONENT_DBGSYMBOLS_DEPENDS applications )
-set ( CPACK_DEB_COMPONENT_INSTALL 1 )
+
 set ( CPACK_RPM_COMPONENT_INSTALL 1 )
-SET ( CPACK_RPM_PACKAGE_LICENSE "GNU General Public License v. 2 (GPL2)" )
+set ( CPACK_DEB_COMPONENT_INSTALL 1 )
 set ( CPACK_ARCHIVE_COMPONENT_INSTALL 1 )
 
 
-IF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
-	SET ( CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64 )
-	SET ( CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64" )
-ELSEIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686" )
-	SET ( CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 )
-	SET ( CPACK_RPM_PACKAGE_ARCHITECTURE "i386" )
-ENDIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
-
 if ( WIN32 )
 	set ( SUGGEST_GENERATOR "ZIP" )
 elseif ( APPLE )
@@ -568,30 +551,18 @@ if ( NOT CPACK_GENERATOR )
 	set ( CPACK_GENERATOR "${SUGGEST_GENERATOR}" )
 endif ()
 
-set ( CPACK_PROJECT_CONFIG_FILE "${MANTICORE_BINARY_DIR}/config/CPackOptions.cmake" )
 
-IF ( NOT DISTR_TYPE )
-	SET ( DISTR_TYPE Redhat7 CACHE STRING "Choose the distr." FORCE )
-	set_property ( CACHE DISTR_TYPE PROPERTY STRINGS "Redhat5" "Redhat6"
-			"Redhat7" )
-ENDIF ()
+include ( SetBuildType )
+
+
+set ( SPHINX_PACKAGE_SUFFIX "" )
+FOREACH ( SUFFIX ${PKGSUFFIXES} )
+	set ( SPHINX_PACKAGE_SUFFIX "${SPHINX_PACKAGE_SUFFIX}-${SUFFIX}" )
+endforeach ()
+
+set ( CPACK_PROJECT_CONFIG_FILE "${MANTICORE_BINARY_DIR}/config/CPackOptions.cmake" )
 
-if ( DISTR_TYPE MATCHES "Redhat7" )
-	message (STATUS "Will create RPM for RedHat/Centos 7")
-	set ( CPACK_GENERATOR "RPM" )
-	set ( CONFDIR "/var" )
-	configure_file ( "sphinx-min.conf.in" "${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist" @ONLY )
-	configure_file ( "sphinx.conf.in" "${MANTICORE_BINARY_DIR}/sphinx.conf.dist" @ONLY )
-	install ( FILES ${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist
-	${MANTICORE_BINARY_DIR}/sphinx.conf.dist
-			DESTINATION share/doc/${PACKAGE_NAME} COMPONENT doc )
-	install ( FILES doc/indexer.1 doc/indextool.1 doc/searchd.1 doc/spelldump.1
-			DESTINATION share/man/man1 COMPONENT doc )
-	install ( DIRECTORY api DESTINATION share/${PACKAGE_NAME} COMPONENT doc )
-	install ( FILES COPYING doc/sphinx.html doc/sphinx.txt example.sql
-			DESTINATION share/doc/${PACKAGE_NAME} COMPONENT doc )
-	set ( CPACK_RPM_bin_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/manticore.spec.in" )
-	set ( CPACK_RPM_dbg_USER_BINARY_SPECFILE "" )
-endif()
+add_subdirectory ( src )
+add_subdirectory ( test )
 
 include ( CPack )

+ 22 - 6
CPackOptions.cmake.in

@@ -1,11 +1,18 @@
-set ( CPACK_PACKAGE_VERSION "@GIT_TIMESTAMP_ID@-@SPH_GIT_COMMIT_ID@" )
-set ( CPACK_RPM_PACKAGE_VERSION "@GIT_TIMESTAMP_ID@.@SPH_GIT_COMMIT_ID@" )
+# configured imports, add more here; avoid to add anything apart this block
+SET ( GIT_TIMESTAMP_ID "@GIT_TIMESTAMP_ID@" )
+SET ( GIT_COMMIT_ID "@SPH_GIT_COMMIT_ID@" )
 set ( CPACK_PACKAGE_NAME "@PACKAGE_NAME@" )
 set ( SUFFIX "@CPACK_SUFFIX@")
 set ( TAG "@SPHINX_TAG@" )
 set ( SOURCE_DIR "@SOURCE_DIR@" )
+set ( BINARY_DIR "@BINARY_DIR@" )
+SET ( VERNUMBERS "@VERNUMBERS@" )
+SET ( DISTR_SUFFIX "@DISTR_SUFFIX@" )
+
+set ( CPACK_PACKAGE_VERSION "${VERNUMBERS}-${GIT_TIMESTAMP_ID}-${GIT_COMMIT_ID}" )
 
 set ( FULL_VERSION "${CPACK_PACKAGE_VERSION}" )
+string ( TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_PACKAGE_NAME_LOWERCASE )
 
 if ( SUFFIX )
 	set ( FULL_VERSION "${FULL_VERSION}${SUFFIX}" )
@@ -15,8 +22,17 @@ if ( TAG )
 	set ( FULL_VERSION "${FULL_VERSION}-${TAG}" )
 endif ()
 
-set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${FULL_VERSION}" )
-set ( RPM_DIR "@BINARY_DIR@/_CPack_Packages/Linux/RPM" ) # @CPACK_TOPLEVEL_DIRECTORY@
-set ( MANTICORE_SOURCE_DIR @SOURCE_DIR@ )
-set ( MANTICORE_BINARY_DIR @BINARY_DIR@ )
+if ( DISTR_SUFFIX )
+	set ( FULL_VERSION "${FULL_VERSION}${DISTR_SUFFIX}" )
+endif ()
+
+# delimiter between name and version
+set ( _delim "-" )
+if (${CPACK_GENERATOR} STREQUAL "DEB")
+	set ( _delim "_" )
+endif()
+
+set ( CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME_LOWERCASE}${_delim}${FULL_VERSION}" )
 
+# rpm specific (used inside .spec template)
+set ( CPACK_RPM_PACKAGE_VERSION "${VERNUMBERS}-${GIT_TIMESTAMP_ID}.${GIT_COMMIT_ID}" )

+ 37 - 0
cmake/SetBuildType.cmake

@@ -0,0 +1,37 @@
+# Helper script - scans cmake/builds for concrete distr rules.
+# Rules for each distr must be placed in separate .cmake file.
+# Each file with rule must be named asd build_*.cmake (that is used to find them).
+# Name of the distr must be in comment in the first line. The name
+# must not be too long, since could be reffered not only from GUI menu,
+# but also from command line, like -DDISTR=rhel7, etc. and so,
+# defs like -DDISTR="my super-puper os" is not so good in the case.
+
+# It gives possibility to add more choices without touching the rest of files.
+
+SET ( MENUDISTR )
+SET ( FILESDISTR )
+file ( GLOB _BUILDS "cmake/builds/build_*.cmake" )
+# list among all build_...cmake, take first line and extract name from it
+foreach ( CHOICE ${_BUILDS} )
+	file ( READ ${CHOICE} CHOICE_NAME LIMIT 1024 )
+	string ( REGEX REPLACE "\n.*" "" CHOICE_NAME "${CHOICE_NAME}" )
+	string ( REGEX REPLACE "^# -* " "" CHOICE_NAME "${CHOICE_NAME}" )
+	string ( REGEX REPLACE " -*$" "" CHOICE_NAME "${CHOICE_NAME}" )
+	list ( APPEND MENUDISTR "${CHOICE_NAME}" )
+	list ( APPEND FILESDISTR "${CHOICE}" )
+endforeach ( CHOICE ${_BUILDS} )
+
+IF ( NOT DISTR )
+	SET ( DISTR rhel7 CACHE STRING "Choose the distr." FORCE )
+ENDIF ()
+
+set_property ( CACHE DISTR PROPERTY STRINGS ${MENUDISTR} )
+
+# find back the file by name of the distr and include it
+list ( FIND MENUDISTR "${DISTR}" _idistr )
+if ( _idistr GREATER -1 )
+	list ( GET FILESDISTR ${_idistr} _RULES )
+	include (${_RULES})
+else()
+	message ( STATUS "no distr selected " )
+endif()

+ 106 - 0
cmake/builds/CommonDeb.cmake

@@ -0,0 +1,106 @@
+# Common debian-specific build variables
+set ( CPACK_GENERATOR "DEB" )
+
+# dpkg --print-architecture. Too boring to include exact command.
+IF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
+	SET ( CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64 )
+ELSEIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686" )
+	SET ( CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386 )
+ENDIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
+
+# block below used to patch the minconf and full conf for debian
+file ( READ "sphinx-min.conf.in" _MINCONF LIMIT 10240 )
+file ( READ "sphinx.conf.in" _FULLCONF )
+string ( REPLACE "@CONFDIR@/log/searchd.pid" "@RUNDIR@/searchd.pid" _MINCONF "${_MINCONF}" )
+string ( REPLACE "@CONFDIR@/log/searchd.pid" "@RUNDIR@/searchd.pid" _FULLCONF "${_FULLCONF}" )
+string ( REPLACE "@CONFDIR@/log" "@LOGDIR@" _FULLCONF "${_FULLCONF}" )
+string ( REPLACE "@CONFDIR@/log" "@LOGDIR@" _FULLCONF "${_FULLCONF}" )
+file ( WRITE "${MANTICORE_BINARY_DIR}/sphinx-min.conf.in" "${_MINCONF}" )
+file ( WRITE "${MANTICORE_BINARY_DIR}/sphinx.conf.in" "${_FULLCONF}" )
+unset ( _MINCONF )
+unset ( _FULLCONF )
+
+set ( CONFDIR "/var/lib/manticore" )
+set ( RUNDIR "/var/run/manticore" )
+set ( LOGDIR "/var/log/manticore" )
+configure_file ( "${MANTICORE_BINARY_DIR}/sphinx-min.conf.in" "${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist" @ONLY )
+configure_file ( "${MANTICORE_BINARY_DIR}/sphinx.conf.in" "${MANTICORE_BINARY_DIR}/sphinx.conf.dist" @ONLY )
+
+# install some internal admin sripts for debian
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/postinst.in"
+		"${MANTICORE_BINARY_DIR}/postinst" @ONLY )
+
+# Add one more component group
+set ( CPACK_COMPONENT_ADM_GROUP "bin" )
+set ( CPACK_COMPONENT_ADM_DISPLAY_NAME "Helper scripts" )
+
+# Copy a default configuration file
+INSTALL ( FILES ${MANTICORE_BINARY_DIR}/sphinx.conf.dist
+		DESTINATION /etc/sphinxsearch COMPONENT doc RENAME sphinx.conf )
+
+install ( FILES doc/indexer.1 doc/indextool.1 doc/searchd.1 doc/spelldump.1
+		DESTINATION share/man/man1 COMPONENT doc )
+
+install ( DIRECTORY api DESTINATION share/${PACKAGE_NAME} COMPONENT doc )
+
+install ( FILES doc/sphinx.html doc/sphinx.txt
+		doc/internals-index-format.txt doc/internals-format-versions.txt
+		doc/internals-coding-standard.txt
+		dist/deb/README.Debian
+		dist/deb/copyright
+		DESTINATION share/doc/${PACKAGE_NAME} COMPONENT doc )
+
+install ( FILES example.sql ${MANTICORE_BINARY_DIR}/sphinx.conf.dist
+		${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist
+		DESTINATION share/doc/${PACKAGE_NAME}/example-conf COMPONENT doc )
+
+install ( FILES dist/deb/manticore.default
+		DESTINATION /etc/default COMPONENT adm RENAME manticore)
+
+install ( FILES dist/deb/manticore.upstart
+		DESTINATION /etc/init COMPONENT adm RENAME manticore.conf )
+
+install ( FILES dist/deb/manticore.init
+		DESTINATION /etc/init.d COMPONENT adm RENAME manticore )
+
+install ( DIRECTORY DESTINATION /var/lib/manticore/data COMPONENT adm)
+install ( DIRECTORY DESTINATION /var/run/manticore COMPONENT adm )
+install ( DIRECTORY DESTINATION /var/log/manticore COMPONENT adm )
+
+# tickets per components
+set ( CPACK_DEBIAN_PACKAGE_DESCRIPTION "Fast standalone full-text SQL search engine
+ Manticore (ex. Sphinx) is a standalone full text search engine, meant to provide fast,
+ size-efficient and relevant fulltext search functions to other applications.
+ Sphinx was specially designed to integrate well with SQL databases and
+ scripting languages. Currently built-in data sources support fetching data
+ either via direct connection to MySQL or PostgreSQL, or using XML pipe
+ mechanism (a pipe to indexer in special XML-based format which Sphinx
+ recognizes).
+ .
+ Sphinx is an acronym which is officially decoded as SQL Phrase Index." )
+
+# component 'bin'
+set ( CPACK_DEBIAN_BIN_PACKAGE_NAME "manticore" )
+# version
+# arch
+
+# dependencies will be auto calculated. FIXME! M.b. point them directly?
+#set ( CPACK_DEBIAN_BIN_PACKAGE_DEPENDS "libc6 (>= 2.15), libexpat (>= 2.0.1), libgcc1 (>= 1:3.0), libstdc++6 (>= 5.2), zlib1g (>= 1:1.1.4), lsb-base (>= 4.1+Debian11ubuntu7)" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_SHLIBDEPS "ON" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_SECTION "misc" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_PRIORITY "optional" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/conffiles;${MANTICORE_BINARY_DIR}/postinst;${MANTICORE_BINARY_DIR}/prerm;${EXTRA_SCRIPTS}" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_CONTROL_STRICT_PERMISSION "ON" )
+set ( CPACK_DEBIAN_BIN_PACKAGE_REPLACES "sphinxsearch" )
+
+# component 'dbg' (debug symbols)
+set ( CPACK_DEBIAN_DBG_PACKAGE_NAME "manticore-dbg" )
+# no dependencies
+set ( CPACK_DEBIAN_DBG_PACKAGE_DEPENDS "" )
+set ( CPACK_DEBIAN_DBG_PACKAGE_SECTION "debug" )
+set ( CPACK_DEBIAN_DBG_PACKAGE_PRIORITY "extra" )
+
+
+
+
+#set ( CPACK_DEBIAN_PACKAGE_DEBUG "ON" )

+ 33 - 0
cmake/builds/CommonRpm.cmake

@@ -0,0 +1,33 @@
+# Common rpm-specific build variables
+set ( CPACK_GENERATOR "RPM" )
+set ( CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/dist/rpm/manticore.spec.in" )
+# doesn't work anyway
+#set ( CPACK_RPM_bin_USER_BINARY_SPECFILE "" )
+
+IF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
+	SET ( CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64" )
+ELSEIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686" )
+	SET ( CPACK_RPM_PACKAGE_ARCHITECTURE "i386" )
+ENDIF ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" )
+
+SET ( CPACK_RPM_PACKAGE_LICENSE "GNU General Public License v. 2 (GPL2)" )
+
+
+# block below used to patch the minconf - add a slash at the end of 'binlog_path' section
+file ( READ "sphinx-min.conf.in" _MINCONF LIMIT 10240 )
+string ( REGEX REPLACE "(binlog_path[ \t]+\\=[ \t]+\\@CONFDIR\\@/data)" "\\1/" _MINCONF "${_MINCONF}" )
+file ( WRITE "${MANTICORE_BINARY_DIR}/sphinx-min.conf.in" "${_MINCONF}")
+unset (_MINCONF)
+
+set ( CONFDIR "/var" )
+configure_file ( "${MANTICORE_BINARY_DIR}/sphinx-min.conf.in" "${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist" @ONLY )
+configure_file ( "sphinx.conf.in" "${MANTICORE_BINARY_DIR}/sphinx.conf.dist" @ONLY )
+
+install ( FILES ${MANTICORE_BINARY_DIR}/sphinx-min.conf.dist
+		${MANTICORE_BINARY_DIR}/sphinx.conf.dist
+		DESTINATION share/doc/${PACKAGE_NAME} COMPONENT doc )
+install ( FILES doc/indexer.1 doc/indextool.1 doc/searchd.1 doc/spelldump.1
+		DESTINATION share/man/man1 COMPONENT doc )
+install ( DIRECTORY api DESTINATION share/${PACKAGE_NAME} COMPONENT doc )
+install ( FILES COPYING doc/sphinx.html doc/sphinx.txt example.sql
+		DESTINATION share/doc/${PACKAGE_NAME} COMPONENT doc )

+ 29 - 0
cmake/builds/build_jessie.cmake

@@ -0,0 +1,29 @@
+# ---------- jessie ----------
+# Above line is mandatory!
+# rules to build deb package for Debian jessie
+
+message ( STATUS "Will create DEB for Debian (jessie)" )
+
+# some jessie-specific variables and files
+
+set ( DISTR_SUFFIX "~jessie_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" )
+
+# m.b. postinst.xenial, postinst.debian and postinst.trusty
+FILE ( READ dist/deb/postinst.debian POSTINST_SPECIFIC )
+
+# m.b. prerm.ubuntu, prerm.debian
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/prerm.debian"
+		"${MANTICORE_BINARY_DIR}/prerm" COPYONLY )
+
+# m.b. posrtrm.systemd, posrtm.wheezy targeted to posrtm, and also preinst.trusty targeted to preinst
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/postrm.systemd"
+		"${MANTICORE_BINARY_DIR}/postrm" COPYONLY )
+
+# m.b. posrtrm, preinst - see also above
+set ( EXTRA_SCRIPTS "${MANTICORE_BINARY_DIR}/postrm;" )
+
+include ( builds/CommonDeb )
+
+# everywhere, but not on wheezy
+install ( FILES dist/deb/manticore.service
+		DESTINATION /lib/systemd/system COMPONENT adm )

+ 7 - 0
cmake/builds/build_rhel6.cmake

@@ -0,0 +1,7 @@
+# ---------- rhel6 ----------
+# Above line is mandatory!
+# rules to build rpm package for Red Hat linux 6 / Centos 6
+
+message ( STATUS "Will create RPM for RedHat/Centos 6" )
+include ( builds/CommonRpm )
+LIST ( APPEND PKGSUFFIXES "rhel6" )

+ 7 - 0
cmake/builds/build_rhel7.cmake

@@ -0,0 +1,7 @@
+# ---------- rhel7 ----------
+# Above line is mandatory!
+# rules to build rpm package for Red Hat linux 7 / Centos 7
+
+message ( STATUS "Will create RPM for RedHat/Centos 7" )
+include ( builds/CommonRpm )
+LIST ( APPEND PKGSUFFIXES "rhel7" )

+ 29 - 0
cmake/builds/build_trusty.cmake

@@ -0,0 +1,29 @@
+# ---------- trusty ----------
+# Above line is mandatory!
+# rules to build deb package for Ubuntu 14.04 (Trusty)
+
+message ( STATUS "Will create DEB for Ubuntu 14.04 (Trusty)" )
+
+# some trusty-specific variables and files
+
+set ( DISTR_SUFFIX "~trusty_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+
+# m.b. postinst.xenial, postinst.debian and postinst.trusty
+FILE ( READ dist/deb/postinst.trusty POSTINST_SPECIFIC)
+
+# m.b. prerm.ubuntu, prerm.debian
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/prerm.ubuntu"
+		"${MANTICORE_BINARY_DIR}/prerm" COPYONLY )
+
+# m.b. posrtrm.systemd, posrtm.wheezy targeted to posrtm, and also preinst.trusty targeted to preinst
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/preinst.trusty"
+		"${MANTICORE_BINARY_DIR}/preinst" COPYONLY )
+
+# m.b. posrtrm, preinst - see also above
+set ( EXTRA_SCRIPTS "${MANTICORE_BINARY_DIR}/preinst;" )
+
+include ( builds/CommonDeb )
+
+# everywhere, but not on wheezy
+install ( FILES dist/deb/manticore.service
+		DESTINATION /lib/systemd/system COMPONENT adm )

+ 25 - 0
cmake/builds/build_wheezy.cmake

@@ -0,0 +1,25 @@
+# ---------- wheezy ----------
+# Above line is mandatory!
+# rules to build deb package for Debian wheezy
+
+message ( STATUS "Will create DEB for Debian (wheezy)" )
+
+# some wheezy-specific variables and files
+
+set ( DISTR_SUFFIX "~wheezy_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}" )
+
+# m.b. postinst.xenial, postinst.debian and postinst.trusty
+FILE ( READ dist/deb/postinst.debian POSTINST_SPECIFIC )
+
+# m.b. prerm.ubuntu, prerm.debian
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/prerm.debian"
+		"${MANTICORE_BINARY_DIR}/prerm" COPYONLY )
+
+# m.b. posrtrm.systemd, posrtm.wheezy targeted to posrtm, and also preinst.trusty targeted to preinst
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/postrm.wheezy"
+		"${MANTICORE_BINARY_DIR}/postrm" COPYONLY )
+
+# m.b. posrtrm, preinst - see also above
+set ( EXTRA_SCRIPTS "${MANTICORE_BINARY_DIR}/postrm;" )
+
+include ( builds/CommonDeb )

+ 29 - 0
cmake/builds/build_xenial.cmake

@@ -0,0 +1,29 @@
+# ---------- xenial ----------
+# Above line is mandatory!
+# rules to build deb package for Ubuntu 16.04 (xenial)
+
+message ( STATUS "Will create DEB for Ubuntu 16.04 (Xenial)" )
+
+# some xenial-specific variables and files
+
+set ( DISTR_SUFFIX "~xenial_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+
+# m.b. postinst.xenial, postinst.debian and postinst.trusty
+FILE ( READ dist/deb/postinst.xenial POSTINST_SPECIFIC)
+
+# m.b. prerm.ubuntu, prerm.debian
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/prerm.ubuntu"
+		"${MANTICORE_BINARY_DIR}/prerm" COPYONLY )
+
+# m.b. posrtrm.systemd, posrtm.wheezy targeted to posrtm, and also preinst.trusty targeted to preinst
+configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/dist/deb/postrm.systemd"
+		"${MANTICORE_BINARY_DIR}/postrm" COPYONLY )
+
+# m.b. posrtrm, preinst - see also above
+set ( EXTRA_SCRIPTS "${MANTICORE_BINARY_DIR}/postrm;" )
+
+include ( builds/CommonDeb )
+
+# everywhere, but not on wheezy
+install ( FILES dist/deb/manticore.service
+		DESTINATION /lib/systemd/system COMPONENT adm )

+ 0 - 1
config/searchd.conf

@@ -1 +0,0 @@
-d /var/run/sphinx 0755 manticore manticore -

+ 8 - 0
dist/deb/README.Debian

@@ -0,0 +1,8 @@
+Manticore
+------------
+
+searchd will start automatically however the default configuration does not supply
+any indexes. Therefore, searchd will not continue running. You have to edit
+/etc/sphinxsearch/sphinx.conf to get any meaningful mode of operation.
+
+Documentation is available in /usr/share/doc/manticore.

+ 4 - 0
dist/deb/conffiles

@@ -0,0 +1,4 @@
+/etc/default/manticore
+/etc/init/manticore.conf
+/etc/sphinxsearch/sphinx.conf
+/etc/init.d/manticore

+ 43 - 0
dist/deb/copyright

@@ -0,0 +1,43 @@
+This work was packaged for Debian by:
+
+    Manticore builds team <[email protected]> on Tue, 27 Jun 2017 20:53:00 +0700
+    
+It is based on package for previous release, created by Sphinx builds team <[email protected]>.
+Which, in turn, is based on package for previous release, created by Radu Spineanu <[email protected]>.
+Which, in turn, is based on the Ubuntu package by Marco Rodrigues and David Leal from 
+launchpad.net.
+
+It was downloaded from http://sphinxsearch.com/downloads/
+
+Upstream Author: Andrew Aksyonoff <[email protected]>
+
+Copyright:
+
+----- License of sphinxsearch
+
+   Copyright (c) 2001-2015, Andrew Aksyonoff
+   Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 dated June, 1991.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program;  if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+   MA 02110-1301, USA.
+
+On Debian GNU/Linux systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
+
+----- Other Licenses and Copyright
+
+Directory: api/libsphinxclient and files
+Copyright (c) Sphinx Technologies Inc
+License: GNU Library General Public License
+

+ 10 - 0
dist/deb/manticore.default

@@ -0,0 +1,10 @@
+#
+# Settings for the manticore searchd daemon
+# Please read /usr/share/doc/manticore/README.Debian for details.
+#
+
+# Should manticore run automatically on startup? (default: no)
+# Before doing this you might want to modify /etc/sphinxsearch/sphinx.conf
+# so that it works for you.
+START=no
+

+ 173 - 0
dist/deb/manticore.init

@@ -0,0 +1,173 @@
+#! /bin/sh
+#
+#       Written by Miquel van Smoorenburg <[email protected]>.
+#       Modified for Debian
+#       by Ian Murdock <[email protected]>.
+#       Further changes by Javier Fernandez-Sanguino <[email protected]>
+#       Modified for sphinx by Radu Spineanu <[email protected]>
+#	Modified by Anton Tsitlionok <[email protected]>, 2013
+#
+#
+
+### BEGIN INIT INFO
+# Provides:          manticore
+# Required-Start:    $local_fs $remote_fs $syslog $network $time
+# Required-Stop:     $local_fs $remote_fs $syslog $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Fast standalone full-text SQL search engine
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/bin/searchd
+NAME=manticore
+DESC=manticore
+
+test -x $DAEMON || exit 0
+
+LOGDIR=/var/log/manticore
+PIDFILE=/var/run/manticore/searchd.pid
+DODTIME=1                   # Time to wait for the server to die, in seconds
+                            # If this value is set too low you might not
+                            # let some servers to die gracefully and
+                            # 'restart' will not work
+
+STARTDELAY=0.5
+
+# Include manticore defaults if available
+if [ -f /etc/default/manticore ] ; then
+    . /etc/default/manticore
+fi
+
+if [ "$START" != "yes" ]; then
+  echo "To enable $NAME, edit /etc/default/manticore and set START=yes"
+  exit 0
+fi
+
+
+set -e
+
+running_pid()
+{
+    # Check if a given process pid's cmdline matches a given name
+    pid=$1
+    name=$2
+    [ -z "$pid" ] && return 1
+    [ ! -d /proc/$pid ] &&  return 1
+    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
+    # Is this the expected child?
+    [ "$cmd" != "$name" ] &&  return 1
+    return 0
+}
+
+running()
+{
+# Check if the process is running looking at /proc
+# (works for all users)
+
+    # No pidfile, probably no daemon present
+    [ ! -f "$PIDFILE" ] && return 1
+    # Obtain the pid and check it against the binary name
+    pid=`cat $PIDFILE`
+    running_pid $pid $DAEMON || return 1
+    return 0
+}
+
+do_force_stop() {
+# Forcefully kill the process
+    [ ! -f "$PIDFILE" ] && return
+    if running ; then
+        kill -15 $pid
+        # Is it really dead?
+        [ -n "$DODTIME" ] && sleep "$DODTIME"s
+        if running ; then
+            kill -9 $pid
+            [ -n "$DODTIME" ] && sleep "$DODTIME"s
+            if running ; then
+                echo "Cannot kill $LABEL (pid=$pid)!"
+                exit 1
+            fi
+        fi
+    fi
+    rm -f $PIDFILE
+    return 0
+}
+
+do_start() {
+	test -e /var/run/manticore || install -m 755 -o root -d root /var/run/manticore
+        # Check if we have the configuration file
+        if [ ! -f /etc/sphinxsearch/sphinx.conf ]; then
+            echo "\n"
+            echo "Please create an /etc/sphinxsearch/sphinx.conf configuration file."
+            echo "A template is provided as /etc/sphinxsearch/sphinx.conf.sample."
+            exit 1
+        fi
+
+        start-stop-daemon --start --pidfile $PIDFILE  --exec ${DAEMON}
+}
+do_stop() {
+        start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE \
+            --exec $DAEMON
+}
+
+case "$1" in
+  start)
+        echo -n "Starting $DESC: "
+        do_start
+        [ -n "$STARTDELAY" ] && sleep $STARTDELAY
+
+        if running ; then
+            echo "$NAME is started."
+        else
+            echo " ERROR."
+        fi
+        ;; 
+
+  stop)
+        	echo -n "Stopping $DESC: "
+	if running ; then
+        	do_stop
+        	echo "stopped."
+	else	
+		echo "already stopped."
+        fi
+        ;;
+
+  force-stop)
+        if running ; then
+	        echo -n "Forcefully stopping $DESC: "
+        	do_force_stop
+		echo "stopped."
+	else
+		echo -n "$NAME is already stopped. Forcing: "
+		do_force_stop
+		echo "stopped."
+        fi
+        ;;
+  restart|reload|force-reload)
+    echo -n "Restarting $DESC: "
+        do_stop
+        [ -n "$DODTIME" ] && sleep $DODTIME
+        do_start
+        echo "$NAME is restarted."
+        ;;
+
+  status)
+    echo -n "$NAME is "
+    if running ;  then
+        echo "running."
+    else
+        echo "not running."
+        exit 1
+    fi
+    ;;
+  *)
+    N=/etc/init.d/$NAME
+    # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+    echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2
+    exit 1
+    ;;
+esac
+
+exit 0

+ 28 - 0
dist/deb/manticore.service

@@ -0,0 +1,28 @@
+[Unit]
+Description=Manticore Search Engine
+After=network.target remote-fs.target nss-lookup.target
+After=syslog.target
+
+[Service]
+Type=forking
+User=manticore
+Group=manticore
+# Run ExecStartPre with root-permissions
+PermissionsStartOnly=true
+ExecStartPre=/bin/mkdir -p /var/run/manticore
+ExecStartPre=/bin/chown manticore.manticore /var/run/manticore
+# Run ExecStart with User=manticore / Group=manticore
+ExecStart=/usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf
+ExecStop=/usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf --stopwait
+KillMode=process
+KillSignal=SIGTERM
+SendSIGKILL=no
+LimitNOFILE=infinity
+TimeoutStartSec=infinity
+PIDFile=/var/run/manticore/searchd.pid
+
+[Install]
+WantedBy=multi-user.target
+Alias=manticore.service
+Alias=searchd.service
+

+ 35 - 0
dist/deb/manticore.upstart

@@ -0,0 +1,35 @@
+# Manticore Service
+
+description     "Manticore Daemon"
+author          "Manticore Software LTD (www.manticoresearch.com)"
+env MANTICOREUSER="manticore"
+start on (net-device-up
+          and local-filesystems
+	  and runlevel [2345])
+stop on runlevel [016]
+
+respawn
+respawn limit 10 35
+
+# The default of 5 seconds is too low if we have rt indices and have to flush them
+kill timeout 30
+env DEFAULTFILE="/etc/default/manticore"
+pre-start script
+    mkdir -p -m 0755 -o manticore -g manticore /var/run/manticore
+    if [ -f "$DEFAULTFILE" ]; then
+	. "$DEFAULTFILE"
+    fi
+    if [ "z$START" != "zyes" ]; then
+	stop
+	logger "To enable manticore, edit /etc/default/manticore and set START=yes"
+	exit 0
+    fi
+    if [ ! -f /etc/sphinxsearch/sphinx.conf ]; then
+        logger "Please create an /etc/sphinxsearch/sphinx.conf configuration file."
+        logger "Templates are in the /usr/share/doc/manticore/example-conf/ directory."
+        exit 0
+    fi
+end script
+
+exec start-stop-daemon --start --chuid $MANTICOREUSER --exec /usr/bin/searchd -- --nodetach
+

+ 6 - 0
dist/deb/postinst.debian

@@ -0,0 +1,6 @@
+cat # Automatically added by build_{wheezy|jessie}.cmake
+if [ -x "/etc/init.d/manticore" ]; then
+	update-rc.d manticore defaults >/dev/null
+	invoke-rc.d manticore start || exit $?
+fi
+# End automatically added section

+ 49 - 0
dist/deb/postinst.in

@@ -0,0 +1,49 @@
+#!/bin/sh
+# postinst script for manticore
+#
+# see: dh_installdeb(1)
+
+set -e
+
+if ! getent group manticore >/dev/null; then
+   addgroup --system manticore
+fi
+if ! getent passwd manticore >/dev/null; then
+   adduser --system --ingroup manticore  --no-create-home --shell /bin/bash manticore
+fi
+DATADIR=/var/lib/manticore
+LOGDIR=/var/log/manticore
+RUNDIR=/var/run/manticore
+SYSCONFDIR=/etc/sphinxsearch
+chown manticore:manticore $DATADIR -R
+chown manticore:manticore $LOGDIR -R
+chown manticore:manticore $RUNDIR -R
+chown manticore:manticore $SYSCONFDIR -R
+
+case "$1" in
+    configure|abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+#add manticore init script to system start
+
+#update-rc.d manticore defaults
+echo ""
+echo "Do not forget to reindex all indexes by running: indexer --all"
+echo ""
+#start manticore service
+
+#invoke-rc.d manticore start
+                        
+# section below id distribute-specivic.
+# It contains shell code generated by cmake cpack script.
+
+@POSTINST_SPECIFIC@
+
+
+exit 0

+ 9 - 0
dist/deb/postinst.trusty

@@ -0,0 +1,9 @@
+# Automatically added by build_trusty.cmake
+if [ -x "/etc/init.d/manticore" ] || [ -e "/etc/init/manticore.conf" ]; then
+	if [ ! -e "/etc/init/manticore.conf" ]; then
+		update-rc.d manticore defaults >/dev/null
+	fi
+	invoke-rc.d manticore start || exit $?
+fi
+update-rc.d -f manticore remove >/dev/null || exit $?
+# End automatically added section

+ 10 - 0
dist/deb/postinst.xenial

@@ -0,0 +1,10 @@
+# Automatically added by build_xenial.cmake
+if [ " $1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
+	if [ -x "/etc/init.d/manticore" ]; then
+		update-rc.d manticore defaults >/dev/null
+	fi
+	if [ -x "/etc/init.d/manticore" ] || [ -e "/etc/init/manticore.conf" ]; then
+		invoke-rc.d manticore start || exit $?
+	fi
+fi
+# End automatically added section

+ 12 - 0
dist/deb/postrm.systemd

@@ -0,0 +1,12 @@
+#!/bin/sh
+set -e
+# Automatically added by build_xenial, build_jessie
+if [ "$1" = "purge" ] ; then
+	update-rc.d manticore remove >/dev/null
+fi
+
+# In case this system is running systemd, we make systemd reload the unit files
+# to pick up changes.
+if [ -d /run/systemd/system ] ; then
+	systemctl --system daemon-reload >/dev/null || true
+fi

+ 6 - 0
dist/deb/postrm.wheezy

@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+# Automatically added by build_wheezy.cmake
+if [ "$1" = "purge" ] ; then
+	update-rc.d manticore remove >/dev/null
+fi

+ 10 - 0
dist/deb/preinst.trusty

@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+# Automatically added by build_trusty.cmake
+if [ "$1" = install ] || [ "$1" = upgrade ]; then
+	if [ -e "/etc/init.d/manticore" ] && [ -L "/etc/init.d/manticore" ] \
+	   && [ $(readlink -f "/etc/init.d/manticore") = /lib/init/upstart-job ]
+	then
+		rm -f "/etc/init.d/manticore"
+	fi
+fi

+ 6 - 0
dist/deb/prerm.debian

@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+# Automatically added by build_wheezy, build_jessie
+if [ -x "/etc/init.d/manticore" ]; then
+	invoke-rc.d manticore stop || exit $?
+fi

+ 6 - 0
dist/deb/prerm.ubuntu

@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+# Automatically added by build_xenial, build_trusty
+if [ -x "/etc/init.d/manticore" ] || [ -e "/etc/init/manticore.conf" ]; then
+	invoke-rc.d manticore stop || exit $?
+fi

+ 105 - 0
dist/rpm/manticore.init

@@ -0,0 +1,105 @@
+#!/bin/sh
+#
+# manticore searchd Free open-source SQL full-text search engine
+#
+# chkconfig:   - 20 80
+# description: Starts and stops the manticore searchd daemon that handles \
+#	       all search requests.
+
+### BEGIN INIT INFO
+# Provides: searchd
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Should-Start: $remote_fs
+# Should-Stop: $remote_fs
+# Default-Start: 
+# Default-Stop: 0 1 2 3 4 5 6
+# Short-Description: start and stop manticore searchd daemon
+# Description: Manticore is a free open-source SQL full-text search engine
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+exec="/usr/bin/searchd"
+prog="searchd"
+user="manticore"
+config="/etc/sphinx/sphinx.conf"
+lockfile=/var/lock/subsys/searchd
+
+start() {
+    [ -x $exec ] || exit 5
+    [ -f $config ] || exit 6
+    echo -n $"Starting $prog: "
+    # if not running, start it up here, usually something like "daemon $exec"
+    daemon --user $user $exec --config $config
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
+}
+
+stop() {
+    echo -n $"Stopping $prog: "
+    # stop it here, often "killproc $prog"
+    killproc $prog
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+reload() {
+    restart
+}
+
+force_reload() {
+    restart
+}
+
+rh_status() {
+    # run checks to determine if the service is running or use generic status
+    status $prog
+}
+
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
+
+
+case "$1" in
+    start)
+        rh_status_q && exit 0
+        $1
+        ;;
+    stop)
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
+        $1
+        ;;
+    force-reload)
+        force_reload
+        ;;
+    status)
+        rh_status
+        ;;
+    condrestart|try-restart)
+        rh_status_q || exit 0
+        restart
+        ;;
+    *)
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+        exit 2
+esac
+exit $?

+ 2 - 2
manticore.spec.in → dist/rpm/manticore.spec.in

@@ -51,7 +51,7 @@ Requires(preun): initscripts
 %define _rpmfilename @CPACK_RPM_FILE_NAME@
 %define _unpackaged_files_terminate_build 0
 %define _topdir @CPACK_RPM_DIRECTORY@
-%define _scripts @MANTICORE_SOURCE_DIR@/config
+%define _scripts @SOURCE_DIR@/dist/rpm
 %define _part @CPACK_RPM_PACKAGE_COMPONENT_PART_PATH@
 # 0%{?fedora} 0%{?dist} 1%{?dist} %{dist}
 @TMP_RPM_SPEC_INSTALL_POST@
@@ -107,7 +107,7 @@ mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/lib/manticore
 
 # Create sphinx.conf
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sphinx
-cp @MANTICORE_BINARY_DIR@/sphinx-min.conf.dist \
+cp @BINARY_DIR@/sphinx-min.conf.dist \
     $RPM_BUILD_ROOT%{_sysconfdir}/sphinx/sphinx.conf
 
 # Updates sphinx.conf paths

+ 1 - 0
dist/rpm/searchd.conf

@@ -0,0 +1 @@
+d /var/run/manticore 0755 manticore manticore -

+ 0 - 0
config/searchd.service → dist/rpm/searchd.service


+ 5 - 2
sphinxrev.cmake

@@ -51,6 +51,11 @@ if ( NOT SPH_GIT_COMMIT_ID )
 	endif ()
 endif ()
 
+# extract version number string from sphinx.h
+FILE ( STRINGS "${SOURCE_DIR}/src/sphinx.h" _STRINGS LIMIT_COUNT 500
+		REGEX "^#define[ \t]+SPHINX_VERSION_NUMBERS.*" )
+STRING ( REGEX REPLACE ".*\"(.*)\"(.*)$" "\\1" VERNUMBERS "${_STRINGS}" )
+
 # All info collected (we need SPH_GIT_COMMIT_ID, GIT_TIMESTAMP_ID, GIT_BRANCH_ID and SPHINX_TAG, if any)
 message ( STATUS "Branch is ${GIT_BRANCH_ID}, ${GIT_TIMESTAMP_ID}, ${SPH_GIT_COMMIT_ID}" )
 
@@ -58,5 +63,3 @@ configure_file ( "${SOURCE_DIR}/src/sphinxversion.h.in" "${BINARY_DIR}/config/ge
 configure_file ( "${SOURCE_DIR}/CPackOptions.cmake.in" "${BINARY_DIR}/config/CPackOptions.cmake" @ONLY )
 
 
-
-

+ 1 - 0
src/CMakeLists.txt

@@ -38,6 +38,7 @@ add_custom_target (
 		-D BINARY_DIR=${CMAKE_BINARY_DIR}
 		-D SPHINX_TAG="${SPHINX_TAG}"
 		-D CPACK_SUFFIX="${SPHINX_PACKAGE_SUFFIX}"
+		-D DISTR_SUFFIX="${DISTR_SUFFIX}"
 		-D PACKAGE_NAME="${PACKAGE_NAME}"
 		-P ${CMAKE_SOURCE_DIR}/sphinxrev.cmake
 )