From df24154c0d32c28d8bea03da6870d0e325dc0cbe Mon Sep 17 00:00:00 2001
From: bigbes <bigbes@gmail.com>
Date: Fri, 6 Jun 2014 01:21:08 +0400
Subject: [PATCH] - Create 3 new rpm-specs:   *
 extra/rpm/tarantool-scl.rpm.spec - SCL spec for 1.5   *
 extra/rpm/tarantool-el.rpm.spec.in - Enetrprise Linux 5/6 Specification   *
 extra/rpm/tarantool.rpm.spec.in - Specification for other Linuxs - Build
 (tarantool-el.rpm.spec and tarantool.rpm.spec) with `--define 'scl 15'`for
 SCL build. - Preserve old spec (for compatibility) - Add dependencies into
 Specifications, two specs for Mock. - Create configuration files for Mock
 builds for EL-{5,6}-{i386,x86_64}

  Working with Mock:
    cmake .
    make new_rpm{_el,}_src
    mock -r <config> --init
    mock -r <config> --rebuild <path_to_srpm>

  Merging commits
---
 .gitignore                               |   2 +
 cmake/package.cmake                      |   3 +-
 cmake/rpm.cmake                          |  77 +++++-
 extra/CMakeLists.txt                     |  81 +++---
 extra/rpm/mock/tarantool-el-5-i386.cfg   |  74 ++++++
 extra/rpm/mock/tarantool-el-5-x86_64.cfg |  74 ++++++
 extra/rpm/mock/tarantool-el-6-i386.cfg   |  72 ++++++
 extra/rpm/mock/tarantool-el-6-x86_64.cfg |  72 ++++++
 extra/rpm/tarantool-el.rpm.spec.in       | 298 +++++++++++++++++++++++
 extra/rpm/tarantool-scl.rpm.spec         |  68 ++++++
 extra/rpm/tarantool.rpm.spec.in          | 294 ++++++++++++++++++++++
 test/CMakeLists.txt                      |  12 +-
 12 files changed, 1077 insertions(+), 50 deletions(-)
 create mode 100644 extra/rpm/mock/tarantool-el-5-i386.cfg
 create mode 100644 extra/rpm/mock/tarantool-el-5-x86_64.cfg
 create mode 100644 extra/rpm/mock/tarantool-el-6-i386.cfg
 create mode 100644 extra/rpm/mock/tarantool-el-6-x86_64.cfg
 create mode 100644 extra/rpm/tarantool-el.rpm.spec.in
 create mode 100644 extra/rpm/tarantool-scl.rpm.spec
 create mode 100644 extra/rpm/tarantool.rpm.spec.in

diff --git a/.gitignore b/.gitignore
index 2d49e3327b..f1f0bc13b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,6 +43,8 @@ doc/www-data/*.html
 doc/www-data/*.ru.html
 doc/www-data.in/_text/download.md
 extra/rpm.spec
+extra/rpm/tarantool.rpm.spec
+extra/rpm/tarantool-el.rpm.spec
 include/tarantool/config.h
 install_manifest.txt
 lcov
diff --git a/cmake/package.cmake b/cmake/package.cmake
index 66e0c47621..6c6504ee19 100644
--- a/cmake/package.cmake
+++ b/cmake/package.cmake
@@ -11,7 +11,8 @@ set (CPACK_SOURCE_GENERATOR "TGZ")
 set (CPACK_SOURCE_IGNORE_FILES
     "\\\\.git" "_CPack_Packages"
     "CMakeCache.txt" "CPackSourceConfig.cmake" "CPackConfig.cmake"
-    "CMakeFiles" "\\\\.gz" "\\\\.Z" "\\\\.zip" "\\\\.rpm"
+    "CMakeFiles" "\\\\.gz" "\\\\.Z" "\\\\.zip"
+    "x86_64\\\\.rpm" "i386\\\\.rpm" "i686\\\\.rpm"
     "\\\\.o" "\\\\.so" "\\\\.a"
     "client/tarantool/tarantool"
     "src/box/tarantool_box"
diff --git a/cmake/rpm.cmake b/cmake/rpm.cmake
index 1675cf8304..7c11a6429b 100644
--- a/cmake/rpm.cmake
+++ b/cmake/rpm.cmake
@@ -13,6 +13,14 @@ execute_process (COMMAND ${GIT} rev-list --oneline ${VERSION}..
     OUTPUT_VARIABLE RELEASE
     OUTPUT_STRIP_TRAILING_WHITESPACE)
 
+execute_process (COMMAND ${RPMBUILD} -E '%_srcrpmdir'
+    OUTPUT_VARIABLE RPM_SRCRPMDIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+execute_process (COMMAND ${RPMBUILD} -E '%_sourcedir'
+    OUTPUT_VARIABLE RPM_SOURCEDIR
+    OUTPUT_STRIP_TRAILING_WHITESPACE)
+
 set (RPM_PACKAGE_VERSION ${VERSION} CACHE STRING "" FORCE)
 set (RPM_PACKAGE_RELEASE ${RELEASE} CACHE STRING "" FORCE)
 
@@ -21,29 +29,82 @@ set (RPM_SOURCE_DIRECTORY_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME}
 set (RPM_PACKAGE_SOURCE_FILE_NAME ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
      CACHE STRING "" FORCE)
 
-set (RPM_ROOT "${PROJECT_BINARY_DIR}/RPM" CACHE STRING "" FORCE)
-set (RPM_BUILDROOT "${RPM_ROOT}/BUILDROOT" CACHE STRING "" FORCE)
+set (RPM_BUILDROOT "${PROJECT_BINARY_DIR}/RPM/BUILDROOT" CACHE STRING "" FORCE)
 
 add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
     WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
     COMMAND $(MAKE) package_source)
 
+add_custom_command(OUTPUT ${RPM_BUILDROOT}
+    COMMAND ${MKDIR} -p ${RPM_BUILDROOT})
+
+##############################################################################################
+
+set (RPM_ROOT "${PROJECT_BINARY_DIR}/RPM" CACHE STRING "" FORCE)
+
 add_custom_command(OUTPUT ${RPM_ROOT}
-    COMMAND ${MKDIR} -p ${RPM_ROOT}/BUILD ${RPM_ROOT}/BUILDROOT
-            ${RPM_ROOT}/SOURCES)
+    COMMAND ${MKDIR} -p ${RPM_ROOT}/{BUILD,SOURCES,SRPMS} ${RPM_ROOT}/RPMS/{i386,x86_64})
 
 add_custom_target(rpm
     DEPENDS ${RPM_ROOT}
     DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
-    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME}
-            ${RPM_ROOT}/SOURCES
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_ROOT}/SOURCES
     COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm.spec
     WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
 
 add_custom_target(rpm_src
     DEPENDS ${RPM_ROOT}
     DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
-    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME}
-            ${RPM_ROOT}/SOURCES
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_ROOT}/SOURCES
     COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bs ${PROJECT_SOURCE_DIR}/extra/rpm.spec
     WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+##############################################################################################
+
+add_custom_target(new_rpm
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool.rpm.spec
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+add_custom_target(new_rpm_src
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bs ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool.rpm.spec
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+add_custom_target(new_rpm_scl
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool-scl.rpm.spec
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool.rpm.spec --define 'scl 15'
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+add_custom_target(new_rpm_el
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool-el.rpm.spec
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+add_custom_target(new_rpm_el_src
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bs ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool-el.rpm.spec
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+add_custom_target(new_rpm_el_scl
+    DEPENDS ${RPM_BUILDROOT}
+    DEPENDS ${PROJECT_SOURCE_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+    COMMAND ${CP} ${PROJECT_BINARY_DIR}/${RPM_PACKAGE_SOURCE_FILE_NAME} ${RPM_SOURCEDIR}
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool-scl.rpm.spec
+    COMMAND ${RPMBUILD} --buildroot ${RPM_BUILDROOT} -bb ${PROJECT_SOURCE_DIR}/extra/rpm/tarantool-el.rpm.spec --define 'scl 15'
+    WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
+
+# TODO: Add MOCK builds
+#     : -DMOCK_TARGET
+#     : -DMOCK_OS: EPEL / FEDORA
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt
index 2cc0fafc3e..1cc074606c 100644
--- a/extra/CMakeLists.txt
+++ b/extra/CMakeLists.txt
@@ -1,51 +1,56 @@
-
 #
 # Scripts for a RPM package
 #
 if (ENABLE_RPM)
-	# chmod +x 655
-	install (FILES tarantool_box DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
-		 PERMISSIONS
-		 OWNER_READ OWNER_WRITE
-		 GROUP_READ GROUP_EXECUTE
-		 WORLD_READ WORLD_EXECUTE)
-	# chmod +x 755
-	install (FILES tarantool_multi.sh DESTINATION bin
-		 PERMISSIONS
-		 OWNER_READ OWNER_WRITE OWNER_EXECUTE
-		 GROUP_READ GROUP_EXECUTE
-		 WORLD_READ WORLD_EXECUTE)
-	# chmod +x 755
-	install (FILES tarantool_deploy.sh DESTINATION bin
-		 PERMISSIONS
-		 OWNER_READ OWNER_WRITE OWNER_EXECUTE
-		 GROUP_READ GROUP_EXECUTE
-		 WORLD_READ WORLD_EXECUTE)
+    # chmod +x 655
+    if (NOT(RPM_SCL_PREFIX STREQUAL ""))
+        set(RPM_SCL_PREFIX_TEMP1 "${RPM_SCL_PREFIX}-")
+    endif()
+    install (FILES tarantool_box DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d/
+         RENAME ${RPM_SCL_PREFIX_TEMP1}tarantool_box
+         PERMISSIONS
+         OWNER_READ OWNER_WRITE
+         GROUP_READ GROUP_EXECUTE
+         WORLD_READ WORLD_EXECUTE)
+    # chmod +x 755
+    install (FILES tarantool_multi.sh DESTINATION bin
+         PERMISSIONS
+         OWNER_READ OWNER_WRITE OWNER_EXECUTE
+         GROUP_READ GROUP_EXECUTE
+         WORLD_READ WORLD_EXECUTE)
+    # chmod +x 755
+    install (FILES tarantool_deploy.sh DESTINATION bin
+         PERMISSIONS
+         OWNER_READ OWNER_WRITE OWNER_EXECUTE
+         GROUP_READ GROUP_EXECUTE
+         WORLD_READ WORLD_EXECUTE)
 endif()
 
 configure_file(rpm.spec.in rpm.spec @ONLY)
+configure_file(rpm/tarantool.rpm.spec.in rpm/tarantool.rpm.spec @ONLY)
+configure_file(rpm/tarantool-el.rpm.spec.in rpm/tarantool-el.rpm.spec @ONLY)
 
 if (TARGET_OS_DARWIN)
-	# NOTE: need add execution 'plutil -lint org.tarantool.tarantool_${TARANTOOL_PRODUCT}.plist
-	# to check syntax of plist file.
-	# Also cmake doesn't support changing package id from 'com.' to 'org.'
-	# Need chage to 'org.' after update lines this file:
-	# https://github.com/Kitware/CMake/blob/v2.8.11.2/Source/CPack/cmCPackPackageMakerGenerator.cxx#L763
-	# 
-	# ^^^ DO NOT CHANGE DARWIN_PACKAGE_ID BEFORE SEE URL ABOVE ^^^
-	#
-	set (DARWIN_PACKAGE_ID "com")
-	set (LUANCHD_PLIST "${DARWIN_PACKAGE_ID}.${CPACK_PACKAGE_VENDOR}.tarantool_${TARANTOOL_PRODUCT}.plist")
-	# Configure scripts for *.pkg and luanchd daemon by templates
-	configure_file(dmg/postflight.in postflight @ONLY)
-	configure_file(org.tarantool.in ${LUANCHD_PLIST} @ONLY)
-	# chmod +x 644
-	install (FILES ${CMAKE_BINARY_DIR}/extra/${LUANCHD_PLIST}
+    # NOTE: need add execution 'plutil -lint org.tarantool.tarantool_${TARANTOOL_PRODUCT}.plist
+    # to check syntax of plist file.
+    # Also cmake doesn't support changing package id from 'com.' to 'org.'
+    # Need chage to 'org.' after update lines this file:
+    # https://github.com/Kitware/CMake/blob/v2.8.11.2/Source/CPack/cmCPackPackageMakerGenerator.cxx#L763
+    #
+    # ^^^ DO NOT CHANGE DARWIN_PACKAGE_ID BEFORE SEE URL ABOVE ^^^
+    #
+    set (DARWIN_PACKAGE_ID "com")
+    set (LUANCHD_PLIST "${DARWIN_PACKAGE_ID}.${CPACK_PACKAGE_VENDOR}.tarantool_${TARANTOOL_PRODUCT}.plist")
+    # Configure scripts for *.pkg and luanchd daemon by templates
+    configure_file(dmg/postflight.in postflight @ONLY)
+    configure_file(org.tarantool.in ${LUANCHD_PLIST} @ONLY)
+    # chmod +x 644
+    install (FILES ${CMAKE_BINARY_DIR}/extra/${LUANCHD_PLIST}
                  DESTINATION share/tarantool
-		 PERMISSIONS
-		 OWNER_READ OWNER_WRITE
-		 GROUP_READ GROUP_READ
-		 WORLD_READ WORLD_READ)
+         PERMISSIONS
+         OWNER_READ OWNER_WRITE
+         GROUP_READ GROUP_READ
+         WORLD_READ WORLD_READ)
 endif()
 
 add_executable(txt2c txt2c.c)
diff --git a/extra/rpm/mock/tarantool-el-5-i386.cfg b/extra/rpm/mock/tarantool-el-5-i386.cfg
new file mode 100644
index 0000000000..03f8d0c074
--- /dev/null
+++ b/extra/rpm/mock/tarantool-el-5-i386.cfg
@@ -0,0 +1,74 @@
+config_opts['root'] = 'epel-5-i386'
+config_opts['target_arch'] = 'i386'
+config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64')
+config_opts['chroot_setup_cmd'] = 'install buildsys-build'
+config_opts['dist'] = 'el5'  # only useful for --resultdir variable subst
+config_opts['plugin_conf']['ccache_enable'] = False
+# beware RHEL use 5Server or 5Client
+config_opts['releasever'] = '5'
+if not config_opts.has_key('macros'):  config_opts['macros'] = {}
+config_opts['macros']['%__arch_install_post'] = '%{nil}'
+
+config_opts['yum.conf'] = """
+[main]
+cachedir=/var/cache/yum
+debuglevel=1
+reposdir=/dev/null
+logfile=/var/log/yum.log
+retries=20
+obsoletes=1
+gpgcheck=0
+assumeyes=1
+syslog_ident=mock
+syslog_device=
+
+# repos
+[base]
+name=BaseOS
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=5&arch=i386&repo=os
+exclude=postgresql*,cmake*
+
+[updates]
+name=updates
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=5&arch=i386&repo=updates
+exclude=postgresql*,cmake*
+
+[groups]
+name=groups
+baseurl=http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
+
+[epel]
+name=epel
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=i386
+
+[testing]
+name=epel-testing
+enabled=1
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel5&arch=i386
+
+[local]
+name=local
+baseurl=http://kojipkgs.fedoraproject.org/repos/dist-5E-epel-build/latest/i386/
+cost=2000
+enabled=0
+
+[pgdg91]
+name=PostgreSQL 9.1 $releasever - $basearch
+baseurl=http://yum.postgresql.org/9.1/redhat/rhel-$releasever-$basearch
+enabled=1
+gpgcheck=0
+
+[testing-devtoolset-2-centos]
+name=testing 2 devtools for CentOS
+baseurl=http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
+gpgcheck=0
+
+
+[epel-debug]
+name=epel-debug
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=i386
+failovermethod=priority
+enabled=0
+"""
diff --git a/extra/rpm/mock/tarantool-el-5-x86_64.cfg b/extra/rpm/mock/tarantool-el-5-x86_64.cfg
new file mode 100644
index 0000000000..aaea051dfa
--- /dev/null
+++ b/extra/rpm/mock/tarantool-el-5-x86_64.cfg
@@ -0,0 +1,74 @@
+config_opts['root'] = 'epel-5-x86_64'
+config_opts['target_arch'] = 'x86_64'
+config_opts['legal_host_arches'] = ('x86_64',)
+config_opts['chroot_setup_cmd'] = 'install buildsys-build'
+config_opts['dist'] = 'el5'  # only useful for --resultdir variable subst
+config_opts['plugin_conf']['ccache_enable'] = False
+# beware RHEL use 5Server or 5Client
+config_opts['releasever'] = '5'
+if not config_opts.has_key('macros'):  config_opts['macros'] = {}
+config_opts['macros']['%__arch_install_post'] = '%{nil}'
+
+config_opts['yum.conf'] = """
+[main]
+cachedir=/var/cache/yum
+debuglevel=1
+reposdir=/dev/null
+logfile=/var/log/yum.log
+retries=20
+obsoletes=1
+gpgcheck=0
+assumeyes=1
+syslog_ident=mock
+syslog_device=
+
+# repos
+[base]
+name=BaseOS
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os
+exclude=postgresql*,cmake*
+
+[updates]
+name=updates
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=updates
+exclude=postgresql*,cmake*
+
+[groups]
+name=groups
+baseurl=http://buildsys.fedoraproject.org/buildgroups/rhel5/x86_64/
+
+[epel]
+name=epel
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=x86_64
+
+[testing]
+name=epel-testing
+enabled=1
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel5&arch=x86_64
+
+[local]
+name=local
+baseurl=http://kojipkgs.fedoraproject.org/repos/dist-5E-epel-build/latest/x86_64/
+cost=2000
+enabled=0
+
+[pgdg91]
+name=PostgreSQL 9.1 $releasever - $basearch
+baseurl=http://yum.postgresql.org/9.1/redhat/rhel-$releasever-$basearch
+enabled=1
+gpgcheck=0
+
+[testing-devtoolset-2-centos]
+name=testing 2 devtools for CentOS
+baseurl=http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
+gpgcheck=0
+
+
+[epel-debug]
+name=epel-debug
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-5&arch=x86_64
+failovermethod=priority
+enabled=0
+"""
diff --git a/extra/rpm/mock/tarantool-el-6-i386.cfg b/extra/rpm/mock/tarantool-el-6-i386.cfg
new file mode 100644
index 0000000000..f7275d6ba6
--- /dev/null
+++ b/extra/rpm/mock/tarantool-el-6-i386.cfg
@@ -0,0 +1,72 @@
+config_opts['root'] = 'epel-6-i386'
+config_opts['target_arch'] = 'i386'
+config_opts['legal_host_arches'] = ('i386', 'i586', 'i686', 'x86_64')
+config_opts['chroot_setup_cmd'] = 'install @buildsys-build'
+config_opts['dist'] = 'el6'  # only useful for --resultdir variable subst
+config_opts['plugin_conf']['ccache_enable'] = False
+# beware RHEL use 6Server or 6Client
+config_opts['releasever'] = '6'
+
+config_opts['yum.conf'] = """
+[main]
+cachedir=/var/cache/yum
+debuglevel=1
+reposdir=/dev/null
+logfile=/var/log/yum.log
+retries=20
+obsoletes=1
+gpgcheck=0
+assumeyes=1
+syslog_ident=mock
+syslog_device=
+
+# repos
+[base]
+name=BaseOS
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=os
+exclude=postgresql*,cmake*
+failovermethod=priority
+
+[updates]
+name=updates
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=6&arch=i386&repo=updates
+exclude=postgresql*,cmake*
+failovermethod=priority
+
+[epel]
+name=epel
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=i386
+failovermethod=priority
+
+[testing]
+name=epel-testing
+enabled=1
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel6&arch=i386
+failovermethod=priority
+
+[local]
+name=local
+baseurl=http://kojipkgs.fedoraproject.org/repos/dist-6E-epel-build/latest/i386/
+cost=2000
+enabled=0
+
+[pgdg91]
+name=PostgreSQL 9.1 $releasever - $basearch
+baseurl=http://yum.postgresql.org/9.1/redhat/rhel-$releasever-$basearch
+enabled=1
+gpgcheck=0
+
+[testing-devtoolset-2-centos]
+name=testing 2 devtools for CentOS
+baseurl=http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
+gpgcheck=0
+
+
+[epel-debug]
+name=epel-debug
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-6&arch=i386
+failovermethod=priority
+enabled=0
+"""
diff --git a/extra/rpm/mock/tarantool-el-6-x86_64.cfg b/extra/rpm/mock/tarantool-el-6-x86_64.cfg
new file mode 100644
index 0000000000..534fbc0853
--- /dev/null
+++ b/extra/rpm/mock/tarantool-el-6-x86_64.cfg
@@ -0,0 +1,72 @@
+config_opts['root'] = 'epel-6-x86_64'
+config_opts['target_arch'] = 'x86_64'
+config_opts['legal_host_arches'] = ('x86_64',)
+config_opts['chroot_setup_cmd'] = 'install @buildsys-build'
+config_opts['dist'] = 'el6'  # only useful for --resultdir variable subst
+config_opts['plugin_conf']['ccache_enable'] = False
+# beware RHEL use 6Server or 6Client
+config_opts['releasever'] = '6'
+
+config_opts['yum.conf'] = """
+[main]
+cachedir=/var/cache/yum
+debuglevel=1
+reposdir=/dev/null
+logfile=/var/log/yum.log
+retries=20
+obsoletes=1
+gpgcheck=0
+assumeyes=1
+syslog_ident=mock
+syslog_device=
+
+# repos
+[base]
+name=BaseOS
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os
+exclude=postgresql*,cmake*
+failovermethod=priority
+
+[updates]
+name=updates
+enabled=1
+mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=updates
+exclude=postgresql*,cmake*
+failovermethod=priority
+
+[epel]
+name=epel
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch=x86_64
+failovermethod=priority
+
+[testing]
+name=epel-testing
+enabled=1
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=testing-epel6&arch=x86_64
+failovermethod=priority
+
+[local]
+name=local
+baseurl=http://kojipkgs.fedoraproject.org/repos/dist-6E-epel-build/latest/x86_64/
+cost=2000
+enabled=0
+
+[pgdg91]
+name=PostgreSQL 9.1 $releasever - $basearch
+baseurl=http://yum.postgresql.org/9.1/redhat/rhel-$releasever-$basearch
+enabled=1
+gpgcheck=0
+
+[testing-devtoolset-2-centos]
+name=testing 2 devtools for CentOS
+baseurl=http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
+gpgcheck=0
+
+
+[epel-debug]
+name=epel-debug
+mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-6&arch=x86_64
+failovermethod=priority
+enabled=0
+"""
diff --git a/extra/rpm/tarantool-el.rpm.spec.in b/extra/rpm/tarantool-el.rpm.spec.in
new file mode 100644
index 0000000000..35465f3f56
--- /dev/null
+++ b/extra/rpm/tarantool-el.rpm.spec.in
@@ -0,0 +1,298 @@
+%{?scl:%{?scl_package:%scl_package tarantool}}
+
+%{!?mysql:%define mysql 1}
+%{!?pgsql:%define pgsql 1}
+%{!?client:%define client 1}
+%{!?build_type:%define build_type RelWithDebugInfo}
+
+BuildRequires: scl-utils
+BuildRequires: scl-utils-build
+BuildRequires: devtoolset-2-toolchain
+BuildRequires: devtoolset-2-binutils-devel
+BuildRequires: cmake28
+
+
+Name: %{?scl_prefix}tarantool
+Version: @RPM_PACKAGE_VERSION@
+Release: @RPM_PACKAGE_RELEASE@
+Group: Applications/Databases
+Summary: Tarantool - an efficient in-memory data store
+Vendor: tarantool.org
+License: BSD
+Requires: %{?scl_prefix}tarantool-debuginfo = @RPM_PACKAGE_VERSION@-@RPM_PACKAGE_RELEASE@
+URL: http://tarantool.org
+Source0: @RPM_PACKAGE_SOURCE_FILE_NAME@
+%description
+Tarantool is a high performance in-memory NoSQL database. It supports
+replication, online backup, stored procedures in Lua.
+
+This package provides the server daemon and administration
+scripts.
+
+# Tarantool sql module
+
+%package sql-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-sql-module
+%description -n %{?scl_prefix}tarantool-sql-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a common sql interface to use with
+tarantool-pg-module or by tarantool-mysql-module.
+
+%if %pgsql
+%package pg-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-pg-module
+BuildRequires: postgresql-devel >= 9.0
+Requires: postgresql-libs >= 9.0
+%description -n %{?scl_prefix}tarantool-pg-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a PostgreSQL interface to use with
+tarantool-sql-module.
+%endif
+
+%if %mysql
+%package mysql-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-mysql-module
+BuildRequires: mysql-devel >= 5.0
+Requires: mysql-libs >= 5.0
+%description -n %{?scl_prefix}tarantool-mysql-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a MySQL interface to use with
+tarantool-sql-module.
+%endif
+
+# Tarantool sophia module
+
+%package sophia-module
+Summary: Tarantool sophia bindings
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-sophia-module
+%description -n %{?scl_prefix}tarantool-sophia-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides tarantool lua bindings to the
+sophia database.
+
+# Tarantool client spec
+%if %client
+%package client
+Summary: Tarantool command line client with history support
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-client
+BuildRequires: readline-devel
+Requires: readline
+%description -n %{?scl_prefix}tarantool-client
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a command line client for Tarantool
+with history support.
+%endif
+
+# Tarantool dev spec
+
+%package dev
+Summary: Tarantool C connector and header files
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-dev
+%description -n %{?scl_prefix}tarantool-dev
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides Tarantool client libraries.
+
+###
+
+%prep
+%setup -n @RPM_SOURCE_DIRECTORY_NAME@
+
+%build
+# https://fedoraproject.org/wiki/Packaging:RPMMacros
+scl enable devtoolset-2 '\
+cmake28 . \
+    -DCMAKE_BUILD_TYPE=%{build_type} \
+    -DENABLE_BACKTRACE=ON \
+    -DENABLE_RPM=ON \
+%if %client
+    -DENABLE_CLIENT=ON \
+%else
+    -DENABLE_CLIENT=OFF \
+%endif
+%if %pgsql
+    -DWITH_POSTGRESQL=ON \
+%else
+    -DWITH_POSTGRESQL=OFF \
+%endif
+%if %mysql
+    -DWITH_MYSQL=ON \
+%else
+    -DWITH_MYSQL=OFF \
+%endif
+    %{?scl:-DRPM_SCL_PREFIX=%scl} \
+    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+    -DCMAKE_INSTALL_SYSCONFDIR=%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir} \
+    -DCMAKE_INSTALL_BINDIR=%{_bindir} \
+    -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
+    -DCMAKE_INSTALL_LIBEXECDIR=%{_libexecdir} \
+    -DCMAKE_INSTALL_SBINDIR=%{_sbindir} \
+    -DCMAKE_INSTALL_SHAREDSTATEDIR=%{_sharedstatedir} \
+    -DCMAKE_INSTALL_DATADIR=%{_datadir} \
+    -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
+    -DCMAKE_INSTALL_INFODIR=%{_infodir} \
+    -DCMAKE_INSTALL_MANDIR=%{_mandir} \
+    -DCMAKE_INSTALL_LOCALSTATEDIR=%{_localstatedir}
+
+scl enable devtoolset-2 \
+'make %{?_smp_mflags}'
+
+%install
+make DESTDIR=%{buildroot} install
+
+%post
+groupadd tarantool > /dev/null 2>&1
+useradd -r -g tarantool tarantool > /dev/null 2>&1
+# Performe a single instance setup
+/usr/bin/tarantool_deploy.sh --yes --quiet 1.1
+
+%preun
+
+%files
+%defattr(-,root,root,-)
+
+%dir "%{_datadir}/tarantool"
+"%{_datadir}/tarantool/00000000000000000001.snap"
+
+%dir "%{_datadir}/doc/tarantool"
+"%{_datadir}/doc/tarantool/README.md"
+"%{_datadir}/doc/tarantool/LICENSE"
+"%{_datadir}/doc/tarantool/box-protocol.txt"
+"%{_mandir}/man1/tarantool_box.1.gz"
+
+"%{_bindir}/tarantool_box"
+"%{_bindir}/tarantool_multi.sh"
+"%{_bindir}/tarantool_deploy.sh"
+"%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/init.d/%{?scl:%{scl}-}tarantool_box"
+
+%dir "%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/tarantool"
+%config(noreplace) "%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/tarantool/tarantool%{?scl:-%scl}.cfg"
+
+%files sql-module
+%defattr(-,root,root,-)
+%dir "%{_datadir}/tarantool"
+%dir "%{_datadir}/tarantool/box"
+%dir "%{_datadir}/tarantool/box/net"
+"%{_datadir}/tarantool/box/net/sql.lua"
+
+%if %pgsql
+%files pg-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool/"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/net/pg.so"
+%endif
+
+%if %mysql
+%files mysql-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/net/mysql.so"
+%endif
+
+%files sophia-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/sophia.so"
+
+%files dev
+%defattr(-,root,root,-)
+%dir "%{_includedir}/tarantool"
+"%{_includedir}/tarantool/tnt.h"
+"%{_includedir}/tarantool/tnt_buf.h"
+"%{_includedir}/tarantool/tnt_call.h"
+"%{_includedir}/tarantool/tnt_delete.h"
+"%{_includedir}/tarantool/tnt_dir.h"
+"%{_includedir}/tarantool/tnt_enc.h"
+"%{_includedir}/tarantool/tnt_insert.h"
+"%{_includedir}/tarantool/tnt_io.h"
+"%{_includedir}/tarantool/tnt_iob.h"
+"%{_includedir}/tarantool/tnt_iter.h"
+"%{_includedir}/tarantool/tnt_lex.h"
+"%{_includedir}/tarantool/tnt_log.h"
+"%{_includedir}/tarantool/tnt_mem.h"
+"%{_includedir}/tarantool/tnt_net.h"
+"%{_includedir}/tarantool/tnt_opt.h"
+"%{_includedir}/tarantool/tnt_ping.h"
+"%{_includedir}/tarantool/tnt_proto.h"
+"%{_includedir}/tarantool/tnt_queue.h"
+"%{_includedir}/tarantool/tnt_reply.h"
+"%{_includedir}/tarantool/tnt_request.h"
+"%{_includedir}/tarantool/tnt_rpl.h"
+"%{_includedir}/tarantool/tnt_select.h"
+"%{_includedir}/tarantool/tnt_snapshot.h"
+"%{_includedir}/tarantool/tnt_sql.h"
+"%{_includedir}/tarantool/tnt_stream.h"
+"%{_includedir}/tarantool/tnt_tuple.h"
+"%{_includedir}/tarantool/tnt_update.h"
+"%{_includedir}/tarantool/tnt_utf8.h"
+"%{_includedir}/tarantool/tnt_xlog.h"
+"%{_libdir}/libtarantool.a"
+"%{_libdir}/libtarantool.so"
+"%{_libdir}/libtarantool.so.1"
+"%{_libdir}/libtarantool.so.1.1"
+"%{_libdir}/libtarantoolnet.a"
+"%{_libdir}/libtarantoolnet.so"
+"%{_libdir}/libtarantoolnet.so.1"
+"%{_libdir}/libtarantoolnet.so.1.1"
+"%{_libdir}/libtarantoolrpl.a"
+"%{_libdir}/libtarantoolrpl.so"
+"%{_libdir}/libtarantoolrpl.so.1"
+"%{_libdir}/libtarantoolrpl.so.1.1"
+"%{_libdir}/libtarantoolsql.a"
+"%{_libdir}/libtarantoolsql.so"
+"%{_libdir}/libtarantoolsql.so.1"
+"%{_libdir}/libtarantoolsql.so.1.1"
+%dir "%{_includedir}/tarantool"
+"%{_includedir}/tarantool/config.h"
+"%{_includedir}/tarantool/lauxlib.h"
+"%{_includedir}/tarantool/luaconf.h"
+"%{_includedir}/tarantool/lua.h"
+"%{_includedir}/tarantool/lua.hpp"
+"%{_includedir}/tarantool/luajit.h"
+"%{_includedir}/tarantool/lualib.h"
+
+%if %client
+%files client
+%defattr(-,root,root,-)
+"%{_mandir}/man1/tarantool.1.gz"
+"%{_bindir}/tarantool"
+"%{_bindir}/tarancheck"
+"%{_bindir}/tarantar"
+%endif
+
+%changelog
+* Fri Jun 06 2014 Eugine Blikh <bigbes@tarantool.org> 1.0-2
+- Add SCL support
+- Add flags support
+- Add some dependencies
+* Mon May 20 2013 Dmitry Simonenko <support@tarantool.org> 1.0-1
+- Initial version of the RPM spec
diff --git a/extra/rpm/tarantool-scl.rpm.spec b/extra/rpm/tarantool-scl.rpm.spec
new file mode 100644
index 0000000000..6d8e8415fa
--- /dev/null
+++ b/extra/rpm/tarantool-scl.rpm.spec
@@ -0,0 +1,68 @@
+%global scl 15
+
+%{?scl:%global _scl_prefix /opt/tarantool}
+%{?scl:%scl_package}
+
+%{?scl:%global scl_name tarantool-%scl}
+
+Summary: Package that installs %scl Software Collection.
+Name: %scl_name
+Version: 1.0
+Release: 1%{?dist}
+Buildarch: noarch
+License: BSD
+Group: Applications/File
+Requires: %{scl_prefix}tarantool
+Requires: %{scl_prefix}tarantool-sql-module
+Requires: %{scl_prefix}tarantool-pg-module
+Requires: %{scl_prefix}tarantool-mysql-module
+Requires: %{scl_prefix}tarantool-sophia-module
+Requires: %{scl_prefix}tarantool-client
+Requires: %{scl_prefix}tarantool-dev
+%{?scl:BuildRequires: scl-utils-build}
+%{?scl:BuildRequires: iso-codes}
+
+%description
+This is the main package for %scl_name Software Collection.
+
+%package build
+Summary: Package shipping basic build configuration
+Group: Applications/File
+
+%description build
+Package shipping essential configuration macros to build %scl Software Collection.
+
+%package runtime
+Summary: Package that handles %scl_name Software Collection.
+Group: Applications/File
+Requires: scl-utils
+
+%description runtime
+Package shipping essential configuration macros to build %scl Software Collection.
+
+%prep
+%setup -c -T
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}/%{_scl_scripts}/root
+cat > %{buildroot}/%{_scl_scripts}/enable <<\EOF
+export PATH=%{_bindir}${PATH+:${PATH}}
+export MANPATH=%{_mandir}:$MANPATH
+export INFOPATH=%{_infodir}${INFOPATH:+:${INFOPATH}}
+export LD_LIBRARY_PATH=%{_libdir}:\$LD_LIBRARY_PATH
+EOF
+%scl_install
+
+%files
+
+%files build
+%{_root_sysconfdir}/rpm/macros.%{scl}-config
+
+%files runtime
+%scl_files
+
+%changelog
+* Fri Jun 06 2014 Blikh Eugine <bigbes@gmail.com> 1.0 1
+- Initial release
+- Initscripts are broken.
diff --git a/extra/rpm/tarantool.rpm.spec.in b/extra/rpm/tarantool.rpm.spec.in
new file mode 100644
index 0000000000..4378b041af
--- /dev/null
+++ b/extra/rpm/tarantool.rpm.spec.in
@@ -0,0 +1,294 @@
+%{?scl:%{?scl_package:%scl_package tarantool}}
+
+%{!?mysql:%define mysql 1}
+%{!?pgsql:%define pgsql 1}
+%{!?client:%define client 1}
+%{!?build_type:%define build_type RelWithDebugInfo}
+
+BuildRequires: scl-utils
+BuildRequires: scl-utils-build
+BuildRequires: cmake
+BuildRequires: gcc >= 4.5
+
+Name: %{?scl_prefix}tarantool
+Version: @RPM_PACKAGE_VERSION@
+Release: @RPM_PACKAGE_RELEASE@
+Group: Applications/Databases
+Summary: Tarantool - an efficient in-memory data store
+Vendor: tarantool.org
+License: BSD
+Requires: %{?scl_prefix}tarantool-debuginfo = @RPM_PACKAGE_VERSION@-@RPM_PACKAGE_RELEASE@
+URL: http://tarantool.org
+Source0: @RPM_PACKAGE_SOURCE_FILE_NAME@
+%description
+Tarantool is a high performance in-memory NoSQL database. It supports
+replication, online backup, stored procedures in Lua.
+
+This package provides the server daemon and administration
+scripts.
+
+# Tarantool sql module
+
+%package sql-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-sql-module
+%description -n %{?scl_prefix}tarantool-sql-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a common sql interface to use with
+tarantool-pg-module or by tarantool-mysql-module.
+
+%if %pgsql
+%package pg-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-pg-module
+BuildRequires: postgresql-devel >= 9.0
+Requires: postgresql-libs >= 9.0
+%description -n %{?scl_prefix}tarantool-pg-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a PostgreSQL interface to use with
+tarantool-sql-module.
+%endif
+
+%if %mysql
+%package mysql-module
+Summary: Tarantool common sql interface
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-mysql-module
+BuildRequires: mysql-devel >= 5.0
+Requires: mysql-libs >= 5.0
+%description -n %{?scl_prefix}tarantool-mysql-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a MySQL interface to use with
+tarantool-sql-module.
+%endif
+
+# Tarantool sophia module
+
+%package sophia-module
+Summary: Tarantool sophia bindings
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-sophia-module
+%description -n %{?scl_prefix}tarantool-sophia-module
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides tarantool lua bindings to the
+sophia database.
+
+# Tarantool client spec
+%if %client
+%package client
+Summary: Tarantool command line client with history support
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-client
+BuildRequires: readline-devel
+Requires: readline
+%description -n %{?scl_prefix}tarantool-client
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides a command line client for Tarantool
+with history support.
+%endif
+
+# Tarantool dev spec
+
+%package dev
+Summary: Tarantool C connector and header files
+Vendor: tarantool.org
+Group: Applications/Databases
+Provides: %{?scl_prefix}tarantool-dev
+%description -n %{?scl_prefix}tarantool-dev
+Tarantool is a high performance in-memory NoSQL database.
+It supports replication, online backup, stored procedures in Lua.
+
+This package provides Tarantool client libraries.
+
+###
+
+%prep
+%setup -n @RPM_SOURCE_DIRECTORY_NAME@
+
+%build
+# https://fedoraproject.org/wiki/Packaging:RPMMacros
+cmake . \
+    -DCMAKE_BUILD_TYPE=%{build_type} \
+    -DENABLE_BACKTRACE=ON \
+    -DENABLE_RPM=ON \
+%if %client
+    -DENABLE_CLIENT=ON \
+%else
+    -DENABLE_CLIENT=OFF \
+%endif
+%if %pgsql
+    -DWITH_POSTGRESQL=ON \
+%else
+    -DWITH_POSTGRESQL=OFF \
+%endif
+%if %mysql
+    -DWITH_MYSQL=ON \
+%else
+    -DWITH_MYSQL=OFF \
+%endif
+    %{?scl:-DRPM_SCL_PREFIX=%scl} \
+    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+    -DCMAKE_INSTALL_SYSCONFDIR=%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir} \
+    -DCMAKE_INSTALL_BINDIR=%{_bindir} \
+    -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
+    -DCMAKE_INSTALL_LIBEXECDIR=%{_libexecdir} \
+    -DCMAKE_INSTALL_SBINDIR=%{_sbindir} \
+    -DCMAKE_INSTALL_SHAREDSTATEDIR=%{_sharedstatedir} \
+    -DCMAKE_INSTALL_DATADIR=%{_datadir} \
+    -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir} \
+    -DCMAKE_INSTALL_INFODIR=%{_infodir} \
+    -DCMAKE_INSTALL_MANDIR=%{_mandir} \
+    -DCMAKE_INSTALL_LOCALSTATEDIR=%{_localstatedir}
+
+make %{?_smp_mflags}
+
+%install
+make DESTDIR=%{buildroot} install
+
+%post
+groupadd tarantool > /dev/null 2>&1
+useradd -r -g tarantool tarantool > /dev/null 2>&1
+# Performe a single instance setup
+/usr/bin/tarantool_deploy.sh --yes --quiet 1.1
+
+%preun
+
+%files
+%defattr(-,root,root,-)
+
+%dir "%{_datadir}/tarantool"
+"%{_datadir}/tarantool/00000000000000000001.snap"
+
+%dir "%{_datadir}/doc/tarantool"
+"%{_datadir}/doc/tarantool/README.md"
+"%{_datadir}/doc/tarantool/LICENSE"
+"%{_datadir}/doc/tarantool/box-protocol.txt"
+"%{_mandir}/man1/tarantool_box.1.gz"
+
+"%{_bindir}/tarantool_box"
+"%{_bindir}/tarantool_multi.sh"
+"%{_bindir}/tarantool_deploy.sh"
+"%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/init.d/%{?scl:%{scl}-}tarantool_box"
+
+%dir "%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/tarantool"
+%config(noreplace) "%{?scl:%_root_sysconfdir}%{!?scl:%_sysconfdir}/tarantool/tarantool%{?scl:-%scl}.cfg"
+
+%files sql-module
+%defattr(-,root,root,-)
+%dir "%{_datadir}/tarantool"
+%dir "%{_datadir}/tarantool/box"
+%dir "%{_datadir}/tarantool/box/net"
+"%{_datadir}/tarantool/box/net/sql.lua"
+
+%if %pgsql
+%files pg-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool/"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/net/pg.so"
+%endif
+
+%if %mysql
+%files mysql-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/net/mysql.so"
+%endif
+
+%files sophia-module
+%defattr(-,root,root,-)
+%dir "%{_libdir}/tarantool"
+%dir "%{_libdir}/tarantool/box"
+"%{_libdir}/tarantool/box/sophia.so"
+
+%files dev
+%defattr(-,root,root,-)
+%dir "%{_includedir}/tarantool"
+"%{_includedir}/tarantool/tnt.h"
+"%{_includedir}/tarantool/tnt_buf.h"
+"%{_includedir}/tarantool/tnt_call.h"
+"%{_includedir}/tarantool/tnt_delete.h"
+"%{_includedir}/tarantool/tnt_dir.h"
+"%{_includedir}/tarantool/tnt_enc.h"
+"%{_includedir}/tarantool/tnt_insert.h"
+"%{_includedir}/tarantool/tnt_io.h"
+"%{_includedir}/tarantool/tnt_iob.h"
+"%{_includedir}/tarantool/tnt_iter.h"
+"%{_includedir}/tarantool/tnt_lex.h"
+"%{_includedir}/tarantool/tnt_log.h"
+"%{_includedir}/tarantool/tnt_mem.h"
+"%{_includedir}/tarantool/tnt_net.h"
+"%{_includedir}/tarantool/tnt_opt.h"
+"%{_includedir}/tarantool/tnt_ping.h"
+"%{_includedir}/tarantool/tnt_proto.h"
+"%{_includedir}/tarantool/tnt_queue.h"
+"%{_includedir}/tarantool/tnt_reply.h"
+"%{_includedir}/tarantool/tnt_request.h"
+"%{_includedir}/tarantool/tnt_rpl.h"
+"%{_includedir}/tarantool/tnt_select.h"
+"%{_includedir}/tarantool/tnt_snapshot.h"
+"%{_includedir}/tarantool/tnt_sql.h"
+"%{_includedir}/tarantool/tnt_stream.h"
+"%{_includedir}/tarantool/tnt_tuple.h"
+"%{_includedir}/tarantool/tnt_update.h"
+"%{_includedir}/tarantool/tnt_utf8.h"
+"%{_includedir}/tarantool/tnt_xlog.h"
+"%{_libdir}/libtarantool.a"
+"%{_libdir}/libtarantool.so"
+"%{_libdir}/libtarantool.so.1"
+"%{_libdir}/libtarantool.so.1.1"
+"%{_libdir}/libtarantoolnet.a"
+"%{_libdir}/libtarantoolnet.so"
+"%{_libdir}/libtarantoolnet.so.1"
+"%{_libdir}/libtarantoolnet.so.1.1"
+"%{_libdir}/libtarantoolrpl.a"
+"%{_libdir}/libtarantoolrpl.so"
+"%{_libdir}/libtarantoolrpl.so.1"
+"%{_libdir}/libtarantoolrpl.so.1.1"
+"%{_libdir}/libtarantoolsql.a"
+"%{_libdir}/libtarantoolsql.so"
+"%{_libdir}/libtarantoolsql.so.1"
+"%{_libdir}/libtarantoolsql.so.1.1"
+%dir "%{_includedir}/tarantool"
+"%{_includedir}/tarantool/config.h"
+"%{_includedir}/tarantool/lauxlib.h"
+"%{_includedir}/tarantool/luaconf.h"
+"%{_includedir}/tarantool/lua.h"
+"%{_includedir}/tarantool/lua.hpp"
+"%{_includedir}/tarantool/luajit.h"
+"%{_includedir}/tarantool/lualib.h"
+
+%if %client
+%files client
+%defattr(-,root,root,-)
+"%{_mandir}/man1/tarantool.1.gz"
+"%{_bindir}/tarantool"
+"%{_bindir}/tarancheck"
+"%{_bindir}/tarantar"
+%endif
+
+%changelog
+* Fri Jun 06 2014 Eugine Blikh <bigbes@tarantool.org> 1.0-2
+- Add SCL support
+- Add flags support
+- Add some dependencies
+* Mon May 20 2013 Dmitry Simonenko <support@tarantool.org> 1.0-1
+- Initial version of the RPM spec
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 801402b75b..4f4ca1e1a9 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,6 +9,7 @@ add_custom_target(test
 add_custom_target(test-force
     COMMAND ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --force --vardir=${PROJECT_BINARY_DIR}/test/var)
 
+
 add_subdirectory(unit)
 add_subdirectory(box)
 add_subdirectory(connector_c)
@@ -20,9 +21,14 @@ macro(install_cfg type_cfg dest)
 endmacro(install_cfg)
 
 if (ENABLE_RPM)
-    install_cfg(rpm ${CMAKE_INSTALL_SYSCONFDIR}/tarantool/)
+    if (NOT(RPM_SCL_PREFIX STREQUAL ""))
+        set(RPM_SCL_PREFIX_TEMP2 "-${RPM_SCL_PREFIX}")
+    endif()
+    install (FILES ${CMAKE_SOURCE_DIR}/test/share/tarantool_rpm.cfg
+        DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/tarantool/
+             RENAME "tarantool${RPM_SCL_PREFIX_TEMP2}.cfg")
     install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap
-             DESTINATION share/tarantool)
+             DESTINATION ${CMAKE_INSTALL_DATADIR}/tarantool/)
 else()
     if (TARGET_OS_DARWIN)
         install_cfg(dmg ${CMAKE_INSTALL_SYSCONFDIR})
@@ -31,5 +37,5 @@ else()
     endif()
 
     install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap
-             DESTINATION "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/tarantool")
+             DESTINATION "${CMAKE_INSTALL_SHAREDSTATEDIR}/tarantool")
 endif()
-- 
GitLab