diff --git a/CMakeLists.txt b/CMakeLists.txt
index 214a49c2986418f02af666f26474d06f675e741a..7ab76c862975637ad542c77a734881d3974a1a7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@ find_program(GIT git)
 find_program(RAGEL ragel)
 find_program(CONFETTI confetti)
 find_program(LD ld)
+find_program(POD2MAN pod2man)
 
 include(cmake/check_objective_c_compiler.cmake)
 include(cmake/luajit.cmake)
@@ -50,6 +51,15 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
 #
 # On 32-bit systems, support files larger than 2GB
+# (see man page for feature_test_macros).
+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
+elseif (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
+    set(TARGET_OS_FREEBSD 1)
+    set(TARGET_OS_DEBIAN_FREEBSD 1)
+# Enable GNU glibc extentions.
+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
+#
+# On 32-bit systems, support files larger than 2GB
 # (see man page for feature_test_macros).
     set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
@@ -183,6 +193,9 @@ endif()
 if (NOT DEFINED CMAKE_LOCALSTATE_DIR)
     set (CMAKE_LOCALSTATE_DIR "var")
 endif()
+if (NOT DEFINED CMAKE_MAN_DIR)
+    set (CMAKE_MAN_DIR "man")
+endif()
 
 #
 # Now handle all configuration options.
@@ -216,7 +229,7 @@ addresses are printed." ${CMAKE_COMPILER_IS_GNUCC})
 set (HAVE_BFD False)
 if (ENABLE_BACKTRACE)
     if (NOT ${CMAKE_COMPILER_IS_GNUCC} OR
-        NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86"))
+        NOT (${CMAKE_SYSTEM_PROCESSOR} MATCHES "86|amd64"))
         # We only know this option to work with gcc
         # on x86 architecture.
         message (FATAL_ERROR "ENABLE_BACKTRACE option is set but the system is not x86 based (${CMAKE_SYSTEM_PROCESSOR}) or the compiler is not GNU GCC (${CMAKE_C_COMPILER}).")
@@ -250,7 +263,7 @@ add_subdirectory(core)
 add_subdirectory(mod)
 add_subdirectory(client)
 add_subdirectory(test)
-add_subdirectory(doc EXCLUDE_FROM_ALL)
+add_subdirectory(doc)
 add_subdirectory(extra)
 
 install (FILES README LICENSE doc/box-protocol.txt
diff --git a/cmake/tarantool_cpack.cmake b/cmake/tarantool_cpack.cmake
index b7ff041bbab89c17ea2d8f99655c2f54955e4875..1532f9e62846dbec44357b5c097c0f043021443c 100644
--- a/cmake/tarantool_cpack.cmake
+++ b/cmake/tarantool_cpack.cmake
@@ -47,7 +47,11 @@ set (CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}"
     "${CMAKE_SOURCE_DIR}/third_party/coro/Makefile"
     "${CMAKE_SOURCE_DIR}/connector/Makefile"
     "${CMAKE_SOURCE_DIR}/connector/c/Makefile"
-    "${CMAKE_SOURCE_DIR}/connector/c/sql/Makefile"
+    "${CMAKE_SOURCE_DIR}/connector/c/include/Makefile"
+    "${CMAKE_SOURCE_DIR}/connector/c/tnt/Makefile"
+    "${CMAKE_SOURCE_DIR}/connector/c/tntnet/Makefile"
+    "${CMAKE_SOURCE_DIR}/connector/c/tntsql/Makefile"
+    "${CMAKE_SOURCE_DIR}/connector/c/tntrp/Makefile"
     "${CMAKE_SOURCE_DIR}/mod/Makefile"
     "${CMAKE_SOURCE_DIR}/mod/box/Makefile"
     "${CMAKE_SOURCE_DIR}/cfg/Makefile"
@@ -56,6 +60,7 @@ set (CPACK_SOURCE_IGNORE_FILES "${CPACK_SOURCE_IGNORE_FILES}"
     "${CMAKE_SOURCE_DIR}/doc/Makefile"
     "${CMAKE_SOURCE_DIR}/doc/user/Makefile"
     "${CMAKE_SOURCE_DIR}/doc/developer/Makefile"
+    "${CMAKE_SOURCE_DIR}/doc/man/Makefile"
 )
 
 set (CPACK_SOURCE_PACKAGE_FILE_NAME "tarantool-${TARANTOOL_VERSION}-src")
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
index fb753cf491c9721c6897d53fab979f44b89a9c05..336505f8b88f247909c185ad37dcefda1f533ef5 100644
--- a/core/CMakeLists.txt
+++ b/core/CMakeLists.txt
@@ -22,7 +22,7 @@ endif()
 #
 # libev uses ceil and floor from the standard math library
 #
-target_link_libraries(ev m)
+target_link_libraries(ev m rt)
 
 #
 # Build admin.m from admin.rl, but only if admin.rl was changed.
@@ -82,6 +82,10 @@ if (TARGET_OS_LINUX)
   set (common_libraries ${common_libraries} dl)
 endif()
 
+if (TARGET_OS_DEBIAN_FREEBSD)
+  set (common_libraries ${common_libraries} dl)
+endif()
+
 if (ENABLE_GCOV)
   set (common_libraries ${common_libraries} gcov)
 endif()
diff --git a/core/say.m b/core/say.m
index fdbe0e5667ba351aff49f785932a77e177446ddd..0fe923b16b5ed699243761152ab55cb7dd5b24ca 100644
--- a/core/say.m
+++ b/core/say.m
@@ -40,6 +40,7 @@
 #include "tarantool.h"
 
 int sayfd = STDERR_FILENO;
+pid_t logger_pid;
 
 static char
 level_to_char(int level)
@@ -94,12 +95,15 @@ say_logger_init(int nonblock)
 			 */
 			setpgid(0, 0);
 			execve(argv[0], argv, envp);
-		} else {
-			close(pipefd[0]);
-			dup2(pipefd[1], STDERR_FILENO);
-			dup2(pipefd[1], STDOUT_FILENO);
-			sayfd = pipefd[1];
+			say_syserror("Can't start logger: %s", cfg.logger);
+			_exit(EXIT_FAILURE);
 		}
+		close(pipefd[0]);
+		dup2(pipefd[1], STDERR_FILENO);
+		dup2(pipefd[1], STDOUT_FILENO);
+		sayfd = pipefd[1];
+
+		logger_pid = pid;
 	} else {
 		sayfd = STDERR_FILENO;
 	}
diff --git a/core/tarantool.m b/core/tarantool.m
index ee745d90bd217a90c407a622d8ecbc2942e46d5f..01b21b93db2aec42a380a5dff73517bb1b42032c 100644
--- a/core/tarantool.m
+++ b/core/tarantool.m
@@ -106,8 +106,8 @@ load_cfg(struct tarantool_cfg *conf, i32 check_rdonly)
 	}
 
 	parse_cfg_file_tarantool_cfg(conf, f, check_rdonly, &n_accepted, &n_skipped);
-	fclose(f);
 
+	fclose(f);
 	if (check_cfg_tarantool_cfg(conf) != 0)
 		return -1;
 
@@ -298,6 +298,7 @@ signal_free(void)
 {
 	if (sigs == NULL)
 		return;
+
 	int i;
 	for (i = 0 ; i < 4 ; i++)
 		ev_signal_stop(&sigs[i]);
@@ -496,7 +497,8 @@ main(int argc, char **argv)
 			   gopt_option('h', 0, gopt_shorts('h', '?'), gopt_longs("help"),
 				       NULL, "display this help and exit"),
 			   gopt_option('V', 0, gopt_shorts('V'), gopt_longs("version"),
-				       NULL, "print program version and exit"));
+				       NULL, "print program version and exit")
+		);
 
 	void *opt = gopt_sort(&argc, (const char **)argv, opt_def);
 	main_opt = opt;
diff --git a/debian/README.source b/debian/README.source
new file mode 100644
index 0000000000000000000000000000000000000000..5e9cd7025c54c37e086bf912bbae881c65e657c0
--- /dev/null
+++ b/debian/README.source
@@ -0,0 +1,3 @@
+Upstream contains some libraries that have already been present in Debian.
+
+Now I work to replace them by debian's copies, but the work requires time.
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000000000000000000000000000000000000..3ee8dc6dcc6cd653c1d59cffdcaa17047986cd4a
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,77 @@
+tarantool (1.4.4+20120127-1) unstable; urgency=low
+
+  * Merge with upstream.
+  * Package can purge not owned files, closes: #657132.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Fri, 27 Jan 2012 23:37:53 +0400
+
+tarantool (1.4.4+20120117-1) unstable; urgency=low
+
+  * Merge my changes with upstream.
+  * Disable tests after building process.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Mon, 16 Jan 2012 22:35:44 +0400
+
+tarantool (1.4.4+20120116-2) unstable; urgency=low
+
+  * Add rt into Debian/kFreeBSD likdepends.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Mon, 16 Jan 2012 16:54:17 +0400
+
+tarantool (1.4.4+20120116-1) unstable; urgency=low
+
+  * New git snapshot.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Mon, 16 Jan 2012 11:36:19 +0400
+
+tarantool (1.4.4+20111229+2-2) unstable; urgency=low
+
+  * use cd instead chdir, closes: 653611;
+  * use spaces instead '\t' symbol, closes: 653607;
+  * use readlink instead perl command, closes: 653613.
+  thanks to Norbert Kiesel <nkiesel@tbdnetworks.com> for all bugreports.
+  * add libmr-tarantool-perl to 'suggests' section of debian/control.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Thu, 29 Dec 2011 23:21:06 +0400
+
+tarantool (1.4.4+20111229+2-1) unstable; urgency=low
+
+  * Debian/kFreeBSD doesn't have proctitle.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Thu, 29 Dec 2011 17:18:51 +0400
+
+tarantool (1.4.4+20111229+1-1) unstable; urgency=low
+
+  * Try to patch build-system for Debian kFreeBSD.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Thu, 29 Dec 2011 13:41:48 +0400
+
+tarantool (1.4.4+20111229-1) unstable; urgency=low
+
+  * Fix test box/args.test.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Thu, 29 Dec 2011 08:49:34 +0400
+
+tarantool (1.4.4+20111228-3) unstable; urgency=low
+
+  * kFreeBSD: uses glibc, amd64 is x86 architecture.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Wed, 28 Dec 2011 23:38:12 +0400
+
+tarantool (1.4.4+20111228-2) unstable; urgency=low
+
+  * Specify architectures.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Wed, 28 Dec 2011 22:40:28 +0400
+
+tarantool (1.4.4+20111228-1) unstable; urgency=low
+
+  * Fix build system for kFreeBSD.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Wed, 28 Dec 2011 21:36:33 +0400
+
+tarantool (1.4.4-1) unstable; urgency=low
+
+  * Init debian release, closes: #652911.
+
+ -- Dmitry E. Oboukhov <unera@debian.org>  Sun, 18 Dec 2011 11:35:37 +0400
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000000000000000000000000000000000000..45a4fb75db864000d01701c0f7a51864bd4daabf
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+8
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000000000000000000000000000000000000..214b595f66d17cd9ae1a5b5d2980467459406730
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,89 @@
+Source: tarantool
+Maintainer: Dmitry E. Oboukhov <unera@debian.org>
+Build-Depends: cdbs, debhelper (>= 8),
+ gobjc,
+ cmake,
+ libreadline-dev,
+ python-yaml,
+ python-daemon,
+ python-pexpect
+Section: database
+Standards-Version: 3.9.2
+Homepage: http://tarantool.org/
+VCS-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/tarantool.git;a=summary
+VCS-Git: git+ssh://git.debian.org/git/collab-maint/tarantool.git
+
+Package: tarantool-common
+Architecture: all
+Priority: optional
+Depends: ${misc:Depends}, adduser
+Description: high performance key/value storage server
+ Tarantool is an open-source NoSQL database, developed by Mail.ru.
+ Its key properties include:
+ .
+  * all data is maintained in RAM
+  * data persistence is implemented using Write Ahead Log and snapshotting
+  * supports asynchronous replication and hot standby
+  * uses coroutines and asynchronous I/O to implement high-performance
+    lock-free access to data
+  * available on Linux and FreeBSD
+  * stored procedures in Lua are supported
+ .
+ This package provides configs and logs infrastructure for tarantool.
+
+Package: tarantool
+Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}, tarantool-common
+Suggests: libmr-tarantool-perl
+Description: high performance key/value storage server
+ Tarantool is an open-source NoSQL database, developed by Mail.ru.
+ Its key properties include:
+ .
+  * all data is maintained in RAM
+  * data persistence is implemented using Write Ahead Log and snapshotting
+  * supports asynchronous replication and hot standby
+  * uses coroutines and asynchronous I/O to implement high-performance
+    lock-free access to data
+  * available on Linux and FreeBSD
+  * stored procedures in Lua are supported
+ .
+ This package provides tarantool server.
+
+Package: tarantool-dbg
+Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386
+Priority: extra
+Section: debug
+Depends: ${shlibs:Depends}, ${misc:Depends},
+     tarantool (= ${binary:Version})
+Description: high performance key/value storage server
+ Tarantool is an open-source NoSQL database, developed by Mail.ru.
+ Its key properties include:
+ .
+  * all data is maintained in RAM
+  * data persistence is implemented using Write Ahead Log and snapshotting
+  * supports asynchronous replication and hot standby
+  * uses coroutines and asynchronous I/O to implement high-performance
+    lock-free access to data
+  * available on Linux and FreeBSD
+  * stored procedures in Lua are supported
+ .
+ This package provides debug symbols for all tarantool packages.
+
+Package: tarantool-connector-c
+Architecture: i386 amd64 kfreebsd-i386 kfreebsd-amd64 hurd-i386
+Priority: optional
+Depends: ${shlibs:Depends}
+Description: high performance key/value storage server
+ Tarantool is an open-source NoSQL database, developed by Mail.ru.
+ Its key properties include:
+ .
+  * all data is maintained in RAM
+  * data persistence is implemented using Write Ahead Log and snapshotting
+  * supports asynchronous replication and hot standby
+  * uses coroutines and asynchronous I/O to implement high-performance
+    lock-free access to data
+  * available on Linux and FreeBSD
+  * stored procedures in Lua are supported
+ .
+ This package provides tarantool C client libraries.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000000000000000000000000000000000000..3bcd1a8adafb00d82a8acf7a37a4485d3f9996f9
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,410 @@
+Format: http://dep.debian.net/deps/dep5/
+Debianized-By: Dmitry E. Oboukhov <unera@debian.org>
+Upstream-Name: tarantool, tarantool-box
+Upstream-Contact: tarantool-developers@lists.launchpad.net
+Source: https://github.com/mailru/tarantool
+
+Files: third_party/libev/* third_party/coro/*
+Copyright: 2007,2008,2009 Marc Alexander Lehmann.
+License:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ .
+     * Redistributions of source code must retain the above copyright
+       notice, this list of conditions and the following disclaimer.
+ .
+     * Redistributions in binary form must reproduce the above
+       copyright notice, this list of conditions and the following
+       disclaimer in the documentation and/or other materials provided
+       with the distribution.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ .
+ Alternatively, the contents of this package may be used under the terms
+ of the GNU General Public License ("GPL") version 2 or any later version,
+ in which case the provisions of the GPL are applicable instead of the
+ above. If you wish to allow the use of your version of this package only
+ under the terms of the GPL and not to allow others to use your version of
+ this file under the BSD license, indicate your decision by deleting the
+ provisions above and replace them with the notice and other provisions
+ required by the GPL in this and the other files of this package. If you do
+ not delete the provisions above, a recipient may use your version of this
+ file under either the BSD or the GPL.
+
+Files: third_party/crc32.c
+Copyright: 1986 Gary S. Brown.
+License:
+ You may use this program, or code or tables extracted from it,
+ as desired without restriction.
+Copyright: 2004-2006 Intel Corporation - All Rights Reserved
+License:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+    may be used to endorse or promote products derived from this software
+    without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+Files: third_party/memcached/*
+Copyright: 2003, Danga Interactive, Inc.
+License:
+ Copyright (c) 2003, Danga Interactive, Inc.
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ .
+     * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ .
+     * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ .
+     * Neither the name of the Danga Interactive nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Files: third_party/luajit/*
+Copyright: 2005-2011 Mike Pall. All rights reserved.
+    1994-2011 Lua.org, PUC-Rio.
+License:
+ LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/
+ .
+ Copyright (C) 2005-2011 Mike Pall. All rights reserved.
+ .
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ .
+ [ MIT license: http://www.opensource.org/licenses/mit-license.php ]
+ .
+ [ LuaJIT includes code from Lua 5.1/5.2, which has this license statement: ]
+ .
+ Copyright (C) 1994-2011 Lua.org, PUC-Rio.
+ .
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ .
+ [ LuaJIT includes code from dlmalloc, which has this license statement: ]
+ .
+ This is a version (aka dlmalloc) of malloc/free/realloc written by
+ Doug Lea and released to the public domain, as explained at
+ http://creativecommons.org/licenses/publicdomain
+
+Files: third_party/qsort_arg.c
+    third_party/queue.h
+    connector/c/tntsql/include/tnt_queue.h
+Copyright: 1992, 1993 The Regents of the University of California.
+License:
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+        notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+        notice, this list of conditions and the following disclaimer in the
+        documentation and/or other materials provided with the distribution.
+ 3. Neither the name of the University nor the names of its contributors
+        may be used to endorse or promote products derived from this software
+        without specific prior written permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.      IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+Files: third_party/valgrind/*
+Copyright: 2000-2010 Julian Seward.
+License:
+ All rights reserved.
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ .
+ 2. The origin of this software must not be misrepresented; you must
+    not claim that you wrote the original software.  If you use this
+    software in a product, an acknowledgment in the product
+    documentation would be appreciated but is not required.
+ .
+ 3. Altered source versions must be plainly marked as such, and must
+    not be misrepresented as being the original software.
+ .
+ 4. The name of the author may not be used to endorse or promote
+    products derived from this software without specific prior written
+    permission.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+Files: third_party/sptree.h
+Copyright: 2010 Mail.RU
+    2010 Teodor Sigaev
+License:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ .
+ THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+Files: third_party/proctitle.c
+Copyright: 2000-2010 PostgreSQL Global Development Group
+License:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ .
+ THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+Files: connector/connector/php/*
+Copyright: 1997-2008 The PHP Group
+License:
+ This source file is subject to version 3.01 of the PHP license
+ that is bundled with this package in the file LICENSE, and is
+ available through the world-wide-web at the following url:
+ .
+ http://www.php.net/license/3_01.txt
+ .
+ If you did not receive a copy of the PHP license and are unable to
+ obtain it through the world-wide-web, please send a note to
+ license@php.net so we can mail you a copy immediately.
+ .
+ .
+ --------------------------------------------------------------------
+                   The PHP License, version 3.01
+ Copyright (c) 1999 - 2010 The PHP Group. All rights reserved.
+ --------------------------------------------------------------------
+ .
+ Redistribution and use in source and binary forms, with or without
+ modification, is permitted provided that the following conditions
+ are met:
+ .
+   1. Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+ .
+   2. Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in
+      the documentation and/or other materials provided with the
+      distribution.
+ .
+   3. The name "PHP" must not be used to endorse or promote products
+      derived from this software without prior written permission. For
+      written permission, please contact group@php.net.
+ .
+   4. Products derived from this software may not be called "PHP", nor
+      may "PHP" appear in their name, without prior written permission
+      from group@php.net.  You may indicate that your software works in
+      conjunction with PHP by saying "Foo for PHP" instead of calling
+      it "PHP Foo" or "phpfoo"
+ .
+   5. The PHP Group may publish revised and/or new versions of the
+      license from time to time. Each version will be given a
+      distinguishing version number.
+      Once covered code has been published under a particular version
+      of the license, you may always continue to use it under the terms
+      of that version. You may also choose to use such covered code
+      under the terms of any subsequent version of the license
+      published by the PHP Group. No one other than the PHP Group has
+      the right to modify the terms applicable to covered code created
+      under this License.
+ .
+   6. Redistributions of any form whatsoever must retain the following
+      acknowledgment:
+      "This product includes PHP software, freely available from
+      <http://www.php.net/software/>".
+ .
+ THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
+ ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PHP
+ DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ OF THE POSSIBILITY OF SUCH DAMAGE.
+ .
+ --------------------------------------------------------------------
+ .
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the PHP Group.
+ .
+ The PHP Group can be contacted via Email at group@php.net.
+ .
+ For more information on the PHP Group and the PHP project,
+ please see <http://www.php.net>.
+ .
+ PHP includes the Zend Engine, freely available at
+ <http://www.zend.com>.
+
+Files: debian/*
+Copyright: 2011 Dmitry E. Oboukhov <unera@debian.org>
+License: GPLv3
+ 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, either version 3 of the License, or
+ (at your option) any later version.
+ .
+ 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.
+ .
+ On debian systems full text of GPLv3 license can be found in file:
+ /usr/share/common-licenses/GPL-3
+
+Files: *
+Copyright: 2009, 2010 Mail.RU,
+    2009, 2010 Yuriy Vostrikov,
+    2011 Konstantin Osipov
+License:
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ .
+ 1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+ .
+ THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
diff --git a/debian/etc/example.cfg b/debian/etc/example.cfg
new file mode 100644
index 0000000000000000000000000000000000000000..166250a6f3877155ce615005bd308e4df2368afa
--- /dev/null
+++ b/debian/etc/example.cfg
@@ -0,0 +1,42 @@
+#
+# Limit of memory used to store tuples to 100MB
+# (0.1 GB)
+# This effectively limits the memory, used by
+# Tarantool. However, index and connection memory
+# is stored outside the slab allocator, hence
+# the effective memory usage can be higher (sometimes
+# twice as high).
+#
+slab_alloc_arena = 0.1
+
+#
+# Read only and read-write port.
+primary_port = 33013
+
+# Read-only port.
+secondary_port = 33014
+
+# 
+# count of file descriptors
+#
+file_descriptors = 8192
+
+#
+# The port for administrative commands.
+#
+admin_port = 33015
+
+#
+# Each write ahead log contains this many rows.
+# When the limit is reached, Tarantool closes
+# the WAL and starts a new one.
+rows_per_wal = 50000
+
+# Define a simple space with 1 HASH-based
+# primary key.
+space[0].enabled = 1
+space[0].index[0].type = "HASH"
+space[0].index[0].unique = 1
+space[0].index[0].key_field[0].fieldno = 0
+space[0].index[0].key_field[0].type = "NUM"
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000000000000000000000000000000000000..46b11a4569e70fa35f1a36a893dfe8670262bb94
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,53 @@
+#!/usr/bin/make -f
+
+VERSION  := $(shell dpkg-parsechangelog|grep ^Version|awk '{print $$2}')
+UVERSION := $(shell echo $(VERSION)|sed 's/-[[:digit:]]\+$$//')
+
+DEB_CMAKE_EXTRA_FLAGS := \
+	-DCMAKE_BUILD_TYPE=RelWithDebugInfo \
+	-DENABLE_CLIENT=true
+
+DEB_DH_INSTALLINIT_ARGS := --name=tarantool
+
+DEB_CMAKE_INSTALL_PREFIX := /usr
+DEB_CMAKE_NORMAL_ARGS := -DCMAKE_INSTALL_PREFIX="$(DEB_CMAKE_INSTALL_PREFIX)" \
+    -DCMAKE_C_FLAGS="$(CFLAGS)" \
+    -DCMAKE_CXX_FLAGS="$(CXXFLAGS)" \
+    -DCMAKE_SKIP_RPATH=ON \
+    -DCMAKE_VERBOSE_MAKEFILE=ON \
+    -DCMAKE_SYSCONF_DIR=/etc/tarantool \
+    -DCMAKE_LOCALSTATE_DIR=/var \
+    -DENABLE_STATIC=ON
+#    -DCMAKE_C_COMPILER:FILEPATH="$(CC)" \
+#    -DCMAKE_CXX_COMPILER:FILEPATH="$(CXX)" \
+
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/cmake.mk
+
+DEB_BUILDDIR := build-area
+
+tarball: clean
+	cd .. && tar --exclude=.git --exclude=debian \
+		-czf tarantool_$(UVERSION).orig.tar.gz tarantool-$(UVERSION)
+
+clean::
+	find -type f -name \*.pyc -delete
+#	find test -name \*.reject -delete
+
+install/tarantool-dbg::
+	rm -fr debian/tarantool-dbg/usr/share/doc/tarantool-dbg
+
+install/tarantool::
+#         make -C build-area test-force || /bin/true
+
+install/tarantool-connector-c::
+#
+
+install/tarantool-common::
+	pod2man -c 'tarantool instances control' \
+	    debian/tarantool_instance.pod > build-area/tarantool_instance.1
+	pod2man -c 'tarantool log rotation' \
+	    debian/tarantool_logrotate.pod > build-area/tarantool_logrotate.1
+	install -m0755 extra/logger.pl \
+	    debian/tarantool-common/usr/lib/tarantool/logger
diff --git a/debian/scripts/tarantool_instance b/debian/scripts/tarantool_instance
new file mode 100755
index 0000000000000000000000000000000000000000..e97f9c6ad6c90b63d71d74585b90e6539843b543
--- /dev/null
+++ b/debian/scripts/tarantool_instance
@@ -0,0 +1,109 @@
+#!/bin/sh
+
+set -e
+
+CFG=$1
+ACTION=$2
+CONFIG_DIR=/var/lib/tarantool/started
+SNAPSHOT_DIR=/var/lib/tarantool/snapshot
+PID_DIR=/var/run/tarantool
+LOG_DIR=/var/log/tarantool
+BOX=/usr/bin/tarantool_box
+SSD=start-stop-daemon
+CFG_DIR=/etc/tarantool/instances.enabled
+
+cd $CFG_DIR
+
+usage="Usage: sh $0 /path/to/config.file start|stop"
+
+if test -z "$CFG"; then
+    echo $usage
+    exit 5
+fi
+
+if ! echo $ACTION|grep -q '^\(start\|stop\)$'; then
+    echo $usage
+    exit 5
+fi
+
+
+if ! test -r "$CFG"; then
+    if echo $CFG|grep -q '\.cfg$'; then
+        echo File $CFG not found
+        exit 10
+    else
+        if ! test -r "$CFG.cfg"; then
+            echo "Instance config '$CFG' not found"
+            exit 15
+        fi
+        CFG="$CFG.cfg"
+    fi
+fi
+
+CFG=`readlink -f "$CFG"`
+
+if ! test -x $BOX; then
+    echo "$BOX not found or can't be started"
+    exit 20
+fi
+
+NAME=`basename $CFG .cfg`
+
+PID=$PID_DIR/$NAME.pid
+SCFG=$CONFIG_DIR/$NAME
+RUNDIR=$SNAPSHOT_DIR/$NAME
+LOG=$LOG_DIR/$NAME.log
+LOGGER="exec /usr/lib/tarantool/logger $LOG"
+SOCKETS=`grep \
+    '^[[:space:]]*file_descriptors[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \
+    | tail -n 1 \
+    | sed 's/[^[:digit:]]//g'
+`
+
+SSDARGS_NO_PID="--quiet --chdir $RUNDIR --chuid tarantool --exec"
+SSDARGS="--pidfile $PID $SSDARGS_NO_PID"
+
+if [ $SOCKETS -gt 1024  -a $SOCKETS -lt 65000 ]; then
+    ulimit -n $SOCKETS
+fi
+
+ulimit -c unlimited
+
+comment_str="#### - commented by init script"
+sed "s/^[[:space:]]*file_descriptors.*/# & $comment_str/" $CFG > $SCFG
+
+echo "pid_file = $PID"        >> $SCFG
+echo "logger   = \"$LOGGER\"" >> $SCFG
+
+$BOX -c $SCFG -v --check-config
+
+if [ ! -d $RUNDIR ]; then
+    install -d -otarantool -gtarantool -m0750 $RUNDIR
+    cd $RUNDIR
+    if ! $SSD --start $SSDARGS $BOX -- --init-storage -v -c $SCFG;
+    then
+        rm -fr $RUNDIR
+        exit 25
+    fi
+fi
+
+if [ $ACTION = 'start' ]; then
+    echo -n "    Starting '$NAME' ... "
+else
+    echo -n "    Stopping '$NAME' ... "
+fi
+
+if $SSD --$ACTION $SSDARGS $BOX -- -B -v -c $SCFG; then
+    echo "ok"
+else
+    ret=$?
+    if [ $ret -eq 1 ]; then
+        if [ $ACTION = 'start' ]; then
+            echo "already started"
+        else
+            echo "already stoppped"
+        fi
+    else
+        echo "failed"
+    fi
+fi
diff --git a/debian/scripts/tarantool_logrotate b/debian/scripts/tarantool_logrotate
new file mode 100755
index 0000000000000000000000000000000000000000..da2896c0ef3793df62913d1eb6792ab717058aa2
--- /dev/null
+++ b/debian/scripts/tarantool_logrotate
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+set -e
+
+CLI="/usr/bin/tarantool"
+CONFIG_DIR="/var/lib/tarantool/started"
+PID_DIR="/var/run/tarantool"
+PROMPT=`basename $0`
+
+error() {
+	echo "$PROMPT error: $*" 1>&2
+	exit 1
+}
+
+logger_notify() {
+	CFG=$1
+	PORT_PRIMARY=`grep \
+	  '^[[:space:]]*primary_port[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \
+	  | tail -n 1 \
+	  | sed 's/[^[:digit:]]//g'
+	`
+	[ $? -eq 0 ] || error "failed to get primary port"
+	PORT_ADMIN=`grep \
+	  '^[[:space:]]*admin_port[[:space:]]*=[[:space:]]*[[:digit:]]\+' $CFG \
+	  | tail -n 1 \
+	  | sed 's/[^[:digit:]]//g'
+	`
+	[ $? -eq 0 ] || error "failed to get admin port"
+	LOGGER_PID=`${CLI} -p $PORT_PRIMARY -m $PORT_ADMIN "show info" \
+	  | grep 'logger_pid:' \
+	  | sed 's/[^[:digit:]]//g'
+	`
+	[ $? -eq 0 ] || error "failed to get logger pid"
+	kill -HUP $LOGGER_PID
+}
+
+if ! echo $1|grep -q '^\(start\)$'; then
+	echo "Tarantool log rotation script"
+	echo "Usage: $0 <start>"
+    exit 5
+fi
+
+if test -d ${PID_DIR}; then
+	for file in `ls -1 $PID_DIR`; do
+		INSTANCE=`basename $file .pid`
+		logger_notify "$CONFIG_DIR/$INSTANCE"
+	done
+fi
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000000000000000000000000000000000000..163aaf8d82b6c54f23c45f32895dbdfdcc27b047
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/debian/tarantool-common.dirs b/debian/tarantool-common.dirs
new file mode 100644
index 0000000000000000000000000000000000000000..3da13a16fe7c1fa67d13c81d29d043cb4d1aaaf1
--- /dev/null
+++ b/debian/tarantool-common.dirs
@@ -0,0 +1,3 @@
+/etc/tarantool/instances.available
+/etc/tarantool/instances.enabled
+/usr/lib/tarantool
diff --git a/debian/tarantool-common.install b/debian/tarantool-common.install
new file mode 100644
index 0000000000000000000000000000000000000000..da80b29de556d199defc74eb109bd7e8e44ad293
--- /dev/null
+++ b/debian/tarantool-common.install
@@ -0,0 +1,3 @@
+debian/etc/example.cfg /etc/tarantool/instances.available/
+debian/scripts/tarantool_instance /usr/sbin
+debian/scripts/tarantool_logrotate /usr/sbin
diff --git a/debian/tarantool-common.logrotate b/debian/tarantool-common.logrotate
new file mode 100644
index 0000000000000000000000000000000000000000..1dc3e9b24e2142245b1820ea090e6553f0e92d5d
--- /dev/null
+++ b/debian/tarantool-common.logrotate
@@ -0,0 +1,12 @@
+/var/log/tarantool/*.log {
+    daily
+    size 512k
+    missingok
+    rotate 10
+    compress
+    delaycompress
+    create 0640 tarantool adm
+    postrotate
+        /usr/sbin/tarantool_logrotate start
+    endscript
+}
diff --git a/debian/tarantool-common.manpages b/debian/tarantool-common.manpages
new file mode 100644
index 0000000000000000000000000000000000000000..5f67776ab9bc87862c15076efeb09ef350535ecf
--- /dev/null
+++ b/debian/tarantool-common.manpages
@@ -0,0 +1,4 @@
+build-area/doc/man/tarantool.1
+build-area/doc/man/tarantool_box.1
+build-area/tarantool_instance.1
+build-area/tarantool_logrotate.1
diff --git a/debian/tarantool-common.postinst b/debian/tarantool-common.postinst
new file mode 100644
index 0000000000000000000000000000000000000000..3aaaf7f4b12e5df7bc3a95ba6fdbf10184a2962d
--- /dev/null
+++ b/debian/tarantool-common.postinst
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+SYSUSER=tarantool
+
+case "$1" in
+    configure)
+        if ! getent passwd $SYSUSER > /dev/null; then
+            adduser \
+                --system \
+                --group \
+                --quiet \
+                --home \
+                /var/spool/$SYSUSER \
+                --no-create-home \
+                --disabled-login \
+                    tarantool
+        fi
+
+        install -d -o$SYSUSER -gadm -m2750 /var/log/tarantool
+        install -d -o$SYSUSER -g$SYSUSER -m750 /var/run/tarantool
+        install -d -o$SYSUSER -g$SYSUSER -m750 /var/lib/tarantool/started
+        install -d -o$SYSUSER -g$SYSUSER -m750 /var/lib/tarantool/snapshot
+    ;;
+esac
+
+#DEBHELPER#
diff --git a/debian/tarantool-common.postrm b/debian/tarantool-common.postrm
new file mode 100644
index 0000000000000000000000000000000000000000..302d376d72739d6d14fbce03067d15e0a3c30742
--- /dev/null
+++ b/debian/tarantool-common.postrm
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+case "$1" in
+    purge)
+        rm -fr  \
+            /var/log/tarantool \
+            /var/run/tarantool \
+            /var/lib/tarantool
+    ;;
+esac
+
+#DEBHELPER#
+
diff --git a/debian/tarantool-common.tarantool.init b/debian/tarantool-common.tarantool.init
new file mode 100644
index 0000000000000000000000000000000000000000..664b3d4abfd5ae02829087582d831df877799ca5
--- /dev/null
+++ b/debian/tarantool-common.tarantool.init
@@ -0,0 +1,87 @@
+#! /bin/sh
+# /etc/init.d/tarantool
+### BEGIN INIT INFO
+# Provides:          tarantool
+# Required-Start:    $remote_fs
+# Required-Stop:     $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Tarantool init script
+# Description:       This file should be used to construct scripts to be
+#                    placed in /etc/init.d.
+### END INIT INFO
+
+# Author: Dmitry E. Oboukhov <unera@debian.org>
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+CONF_DIR=/etc/tarantool/instances.enabled
+SCRIPTNAME=/etc/init.d/tarantool
+DAEMON=/usr/bin/tarantool_box
+INSTANCES=`find $CONF_DIR -xtype f -name '*.cfg'`
+INSTSCRIPT=/usr/sbin/tarantool_instance
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+. /lib/init/vars.sh
+
+if test -z "$INSTANCES"; then
+    echo "tarantool: There are no instances in $CONF_DIR"
+    exit 0
+fi
+
+
+#
+# Function that starts the daemon/service
+#
+do_start() {
+    echo "tarantool: Staring instances"
+    for inst in $INSTANCES; do
+        $INSTSCRIPT $inst start
+    done
+    return 0
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop() {
+    echo "tarantool: Stopping instances"
+    for inst in $INSTANCES; do
+        $INSTSCRIPT $inst stop
+    done
+    return 0
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+    do_stop
+    do_start
+}
+
+case "$1" in
+    start)
+        do_start
+    ;;
+
+    stop)
+        do_stop
+    ;;
+
+    status)
+    ;;
+
+    restart|force-reload)
+        do_stop
+        do_start
+    ;;
+    
+    *)
+	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+	exit 3
+    ;;
+esac
+
+:
diff --git a/debian/tarantool-connector-c.dirs b/debian/tarantool-connector-c.dirs
new file mode 100644
index 0000000000000000000000000000000000000000..776aa81f12490522301f3e026c23ff10920fd187
--- /dev/null
+++ b/debian/tarantool-connector-c.dirs
@@ -0,0 +1 @@
+/usr/include/libtnt
diff --git a/debian/tarantool-connector-c.install b/debian/tarantool-connector-c.install
new file mode 100644
index 0000000000000000000000000000000000000000..5a8de06bbe6362715cbb88e57c253a41c0c721b0
--- /dev/null
+++ b/debian/tarantool-connector-c.install
@@ -0,0 +1,9 @@
+build-area/connector/c/tnt/libtnt.so /usr/lib
+build-area/connector/c/tntnet/libtntnet.so /usr/lib
+build-area/connector/c/tntsql/libtntsql.so /usr/lib
+
+build-area/connector/c/tnt/libtnt.a /usr/lib
+build-area/connector/c/tntnet/libtntnet.a /usr/lib
+build-area/connector/c/tntsql/libtntsql.a /usr/lib
+
+connector/c/include/libtnt /usr/include
diff --git a/debian/tarantool.README.Debian b/debian/tarantool.README.Debian
new file mode 100644
index 0000000000000000000000000000000000000000..f9bdb10e1149960381dc51ec95df850748ad63a2
--- /dev/null
+++ b/debian/tarantool.README.Debian
@@ -0,0 +1,8 @@
+To create new instance You should:
+
+  1. place instance_name.cfg into /etc/tarantool/instances.available/
+  2. create symlink
+  	 /etc/tarantool/instances.available/instance_name.cfg ->
+  		/etc/tarantool/instances.enabled/instance_name.cfg
+  3. do invoke-rc.d tarantool restart
+
diff --git a/debian/tarantool.install b/debian/tarantool.install
new file mode 100644
index 0000000000000000000000000000000000000000..8e3fa42212a9c9665356b481ceb8ce33337e80a7
--- /dev/null
+++ b/debian/tarantool.install
@@ -0,0 +1,2 @@
+usr/bin/tarantool_box
+usr/bin/tarantool
diff --git a/debian/tarantool.manpages b/debian/tarantool.manpages
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/debian/tarantool_instance.pod b/debian/tarantool_instance.pod
new file mode 100644
index 0000000000000000000000000000000000000000..f18cf2845c6e1d33076d352243ceff5b19e8f1d9
--- /dev/null
+++ b/debian/tarantool_instance.pod
@@ -0,0 +1,34 @@
+=head1 NAME
+
+tarantool_instance - utility to start/stop tarantool instances
+
+
+=head1 SINOPSYS
+
+    tarantool_instance NAME start
+    tarantool_instance NAME stop
+
+
+=head1 DESCRIPTION
+
+The utility seeks instance in B</etc/tarantool/instances.enabled/> directory.
+It seeks I<< /etc/tarantool/instances.enabled/B<NAME>.cfg >>, but You can use
+filepath instead B<NAME>.
+
+The utility extends tarantool's configs by the following variables:
+
+=over
+
+=item file_descriptors = COUNT
+
+You can set sockets limit for the instance.
+
+=back
+
+The utility copies instance's config to directory
+B</var/lib/tarantool/started/>, exclude additional variables,
+then starts or stops instance.
+
+In the first starting the utilitie creates
+I<< /var/lib/tarantool/snapshot/B<NAME> >> directory and empty snapshot
+inside the directory.
diff --git a/debian/tarantool_logrotate.pod b/debian/tarantool_logrotate.pod
new file mode 100644
index 0000000000000000000000000000000000000000..1248621bb9d9dede25a23f99669397307e05025f
--- /dev/null
+++ b/debian/tarantool_logrotate.pod
@@ -0,0 +1,15 @@
+=head1 NAME
+
+tarantool_logrotate - utility to rotate tarantool instances logs
+
+
+=head1 SINOPSYS
+
+    tarantool_logrotate
+
+
+=head1 DESCRIPTION
+
+The utility tries to connect to each running tarantool instance to get
+logger pid file, then it sends SIGUSR2 to logger which initiates
+log rotataion procedure.
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 0000000000000000000000000000000000000000..d10e1525a1447b7566ba1bebb2ec63ec2e8167be
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,3 @@
+version=3
+	https://github.com/mailru/tarantool/tags \
+		.*/tarball/(\d+(?:\.\d+)+)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index d38b79a0364bc032489b0ab86f99f2894d0422b5..c76ffc4e8c040013cf289421850cda6237e5a0f5 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,3 +1,4 @@
-add_subdirectory(user)
-add_subdirectory(developer)
-add_subdirectory(www-data.in)
+add_subdirectory(user EXCLUDE_FROM_ALL)
+add_subdirectory(developer EXCLUDE_FROM_ALL)
+add_subdirectory(www-data.in EXCLUDE_FROM_ALL)
+add_subdirectory(man)
diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..765d4a7466e744f23d2169b3146ec9942fb4d319
--- /dev/null
+++ b/doc/man/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_custom_target(man ALL
+    COMMAND ${POD2MAN} -c 'high performance key/value storage server'
+	    ${CMAKE_SOURCE_DIR}/doc/man/tarantool_box.pod > ${PROJECT_BINARY_DIR}/doc/man/tarantool_box.1
+    COMMAND ${POD2MAN} -c 'readline SQL-client for tarantool'
+	    ${CMAKE_SOURCE_DIR}/doc/man/tarantool.pod > ${PROJECT_BINARY_DIR}/doc/man/tarantool.1
+    )
+
+install(FILES ${PROJECT_BINARY_DIR}/doc/man/tarantool_box.1 DESTINATION "${CMAKE_MAN_DIR}")
+if (ENABLE_CLIENT)
+    install(FILES ${PROJECT_BINARY_DIR}/doc/man/tarantool.1 DESTINATION "${CMAKE_MAN_DIR}")
+endif()
diff --git a/doc/man/tarantool.pod b/doc/man/tarantool.pod
new file mode 100644
index 0000000000000000000000000000000000000000..06c1e1ae54a5a50c6f5d3be5ea43ebc59de0a488
--- /dev/null
+++ b/doc/man/tarantool.pod
@@ -0,0 +1,31 @@
+=head1 NAME
+
+tarantool - readline SQL-client for L<tarantool>.
+
+=head1 SYNOPSIS
+
+    tarantool [OPTIONS]
+
+=head1 Command-line options
+
+=over
+
+=item -a <host>, --host <host>
+
+Defines Server address.
+
+=item -p <port>, --port <port>
+
+Defines server port.
+
+=item -m <port>, --port-admin <port>
+
+Defines Server admin port.
+
+=item -h, --help
+
+Displays helpscreen and exits.
+
+=back
+
+
diff --git a/doc/man/tarantool_box.pod b/doc/man/tarantool_box.pod
new file mode 100644
index 0000000000000000000000000000000000000000..e48a14931d43b02ef63d7ad14a502e2e25c4ebcd
--- /dev/null
+++ b/doc/man/tarantool_box.pod
@@ -0,0 +1,100 @@
+=head1 NAME
+
+tarantool_box - open-source NoSQL database
+
+=head1 SYNOPSIS
+
+    tarantool_box [OPTIONS]
+
+=head1 DESCRIPTION
+
+Tarantool is an open-source NoSQL database, developed by Mail.ru.
+
+Its key properties include:
+
+=over
+
+=item *
+    
+Licence: simplified BSD
+
+=item *
+    
+All data is maintained in RAM
+
+=item *
+    
+Data persistence is implemented using Write Ahead Log and snapshotting
+
+=item *
+    
+Supports asynchronous replication and hot standby
+
+=item *
+    
+Uses coroutines and asynchronous I/O to implement
+high-performance lock-free access to data
+
+=item *
+    
+Available on Linux and FreeBSD
+
+=item *
+    
+Stored procedures in Lua are supported.
+
+=back
+
+=head2 Data model
+
+The basic atom of storage in Tarantool is called tuple. A tuple
+can have arbitrary number of fields. The first field in the tuple
+is always the identifying unique key. Tuples form spaces. It is
+possible to search tuples in spaces using the primary or secondary
+keys. Fields in a tuple are type-agnostic. It is possible to change,
+as well as add or remove fields.
+
+=head1 Command-line options
+
+=over
+
+=item --cfg-get=KEY
+
+Returns a value from configuration file described by B<KEY>.
+
+=item --check-config
+
+Checks configuration file for errors.
+
+=item -c FILE, --config=FILE
+
+Points a path to configuration file (default: B</etc/tarantool.cfg>).
+
+=item --cat=FILE
+
+Cats snapshot file to stdout in readable format and exits.
+
+=item --init-storage
+
+Initializes storage (an empty snapshot file) and exits.
+
+=item -v, --verbose
+
+Increases verbosity level in log messages.
+
+=item -B, --background
+
+Redirects input/output streams to a log file and runs as
+daemon.
+
+=item -h, --help
+
+Displays helpscreen and exits.
+
+=item -V, --version
+
+Prints program version and exits.
+
+=back
+
+
diff --git a/extra/logger.pl b/extra/logger.pl
index c081d6a1f849906dbc0490e31b2ccfc9eb2ccc8b..d7d260e98b2fc6eea03c8ceb19e06daa5aeae1e1 100644
--- a/extra/logger.pl
+++ b/extra/logger.pl
@@ -7,13 +7,14 @@ my $reopen;
 $SIG{HUP} = sub { $reopen = 1 };
 
 my $fh;
-while (<>) {
+while (<STDIN>) {
     if ($reopen or not $fh) {
         undef $fh;
         undef $reopen;
-        open $fh, ">>$log" or next;
-        select $fh;
-        $| = 1;
+        if (open $fh, ">>", $log) {
+            select $fh;
+            $| = 1;
+        }
     }
 
     print;
diff --git a/include/say.h b/include/say.h
index b0f3b009588e0bb56a4c6fb53573a98a63494584..748d01d73f554a16892135743a750778ce640004 100644
--- a/include/say.h
+++ b/include/say.h
@@ -63,4 +63,6 @@ void _say(int level, const char *filename, int line, const char *error,
 #define say_info(...)			say(S_INFO, NULL, __VA_ARGS__)
 #define say_debug(...)			say(S_DEBUG, NULL, __VA_ARGS__)
 
+
+
 #endif /* TARANTOOL_SAY_H_INCLUDED */
diff --git a/mod/box/box.m b/mod/box/box.m
index 3635efecf6b0441014d9d65fd3fabcce6e8170b9..4f00f47564dc47e56e426dca9f0d104c5240d205 100644
--- a/mod/box/box.m
+++ b/mod/box/box.m
@@ -49,6 +49,8 @@
 #include "memcached.h"
 #include "box_lua.h"
 
+extern pid_t logger_pid;
+
 static void box_process_ro(u32 op, struct tbuf *request_data);
 static void box_process_rw(u32 op, struct tbuf *request_data);
 
@@ -2254,6 +2256,7 @@ mod_info(struct tbuf *out)
 	tbuf_printf(out, "  version: \"%s\"" CRLF, tarantool_version());
 	tbuf_printf(out, "  uptime: %i" CRLF, (int)tarantool_uptime());
 	tbuf_printf(out, "  pid: %i" CRLF, getpid());
+	tbuf_printf(out, "  logger_pid: %i" CRLF, logger_pid);
 	tbuf_printf(out, "  lsn: %" PRIi64 CRLF, recovery_state->confirmed_lsn);
 	tbuf_printf(out, "  recovery_lag: %.3f" CRLF, recovery_state->recovery_lag);
 	tbuf_printf(out, "  recovery_last_update: %.3f" CRLF,
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e7e1fadb89454ac36f68cb6cfca8444139fda4fd..b77e58c7141ad3293f525a578cd9247376f5daa5 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,9 @@
 add_custom_target(test
     COMMAND python ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --vardir=${PROJECT_BINARY_DIR}/test/var)
 
+add_custom_target(test-force
+    COMMAND python ${PROJECT_SOURCE_DIR}/test/test-run.py --builddir=${PROJECT_BINARY_DIR} --force --vardir=${PROJECT_BINARY_DIR}/test/var)
+
 add_subdirectory(box)
 add_subdirectory(connector_c)
 
diff --git a/test/box/admin.result b/test/box/admin.result
index 078f65688c395807c0750840e0b45b50b5987776..a40aaf1deef36c4817be77109bb643a957219c36 100644
--- a/test/box/admin.result
+++ b/test/box/admin.result
@@ -98,6 +98,7 @@ info:
   version: "1.minor.patch-<rev>-<commit>"
   uptime: <uptime>
   pid: <pid>
+  logger_pid: <pid>
   lsn: 3
   recovery_lag: 0.000
   recovery_last_update: 0.000
diff --git a/test/box/admin.test b/test/box/admin.test
index 29bed8a8c1fef7230d671b70750160c920c19fc3..986b4cb56ff5dc2ce384c22544770fce40dfd9b2 100644
--- a/test/box/admin.test
+++ b/test/box/admin.test
@@ -13,6 +13,7 @@ exec admin "save snapshot"
 exec sql "delete from t0 where k0 = 1"
 sys.stdout.push_filter("(\d)\.\d\.\d(-\d+-\w+)?", "\\1.minor.patch-<rev>-<commit>")
 sys.stdout.push_filter("pid: \d+", "pid: <pid>")
+sys.stdout.push_filter("logger_pid: \d+", "pid: <pid>")
 sys.stdout.push_filter("uptime: \d+", "uptime: <uptime>")
 sys.stdout.push_filter("uptime: \d+", "uptime: <uptime>")
 sys.stdout.push_filter("(/\S+)+/tarantool", "tarantool")
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 4fb0eefc05aeb6ad912fc7a6a02043ede64ba9d1..1820bf0f3f926a4b2c2fc489c481424e29afc390 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -1,8 +1,10 @@
 add_library (misc STATIC crc32.c proctitle.c qsort_arg.c)
 
-if (TARGET_OS_FREEBSD)
-  set_source_files_properties(proctitle.c PROPERTIES
-       COMPILE_FLAGS "-DHAVE_SETPROCTITLE")
+if (NOT TARGET_OS_DEBIAN_FREEBSD) 
+	if (TARGET_OS_FREEBSD)
+	  set_source_files_properties(proctitle.c PROPERTIES
+	       COMPILE_FLAGS "-DHAVE_SETPROCTITLE")
+	endif()
 endif()
 
 add_subdirectory(coro)