From b97bedccaa9e0816e6afb5e238b81c29e5dcdc80 Mon Sep 17 00:00:00 2001
From: bigbes <bigbes@gmail.com>
Date: Mon, 26 May 2014 12:27:59 +0400
Subject: [PATCH] Add new brewspec and fix wrong python package name

* New brewspec, that gives ability to build latest stable
  (for latest master you need to pass '--devel' flag)
* All dependencies are inside this spec
* We can now test Tarantool (you need to pass '--with-tests'
  flag to 'brew')
* We can build Tarantool with -DCMAKE_BUILD_TYPE=Debug (default is
  'Release')
* Fix for name of pypi module - ('python-daemon', not 'daemon')
* Fix README for MacOSX
---
 README.MacOSX                  | 10 +++-
 doc/user/tutorial.xml          |  6 +--
 doc/www-data.in/download.cmake |  2 +-
 extra/tarantool.rb             | 89 ++++++++++++++++++++++++++++++++++
 4 files changed, 101 insertions(+), 6 deletions(-)
 create mode 100644 extra/tarantool.rb

diff --git a/README.MacOSX b/README.MacOSX
index cf24c08f1f..a53a02fc82 100644
--- a/README.MacOSX
+++ b/README.MacOSX
@@ -8,7 +8,13 @@ homebrew as MacPorts.
 
 If you want to build at the Homebrew environment execute just:
 
-        brew install http://tarantool.org/dist/tarantool.rb
+    brew install https://raw.githubusercontent.com/tarantool/tarantool/master/extra/tarantool.rb
+
+Possible flags are:
+
+    --devel - for installing master's branch version
+    --with-tests - for testing tarantool after building/installing
+    --with-debug - for building tarantool with -DCMAKE_BUILD_TYPE=Debug
 
 Target OS: MacOS X "Lion"
 
@@ -33,7 +39,7 @@ Go to http://developer.apple.com/ to download and install the latest version
 of "Command Line Tools for Xcode". This package contains /usr/bin/clang and
 /usr/bin/clang++ binaries. Check that clang version is at least 3.2.
 
-3. Install necessary python modules: pyYAML, daemon
+3. Install necessary python modules: pyYAML, python-daemon, pexpect
 -------------
 NB: it is recommended to install python modules through setup.py,
 using the default python (which should be >= 2.6.x and < 3.x);
diff --git a/doc/user/tutorial.xml b/doc/user/tutorial.xml
index 445d07c6b1..8bbb44c252 100644
--- a/doc/user/tutorial.xml
+++ b/doc/user/tutorial.xml
@@ -319,9 +319,9 @@ ones unless you intend to work on the documentation.
 # (if wget fails, check the <citetitle xlink:href="http://pypi.python.org/pypi/python-daemon" xlink:title="Python daemon">python-daemon</citetitle> web site
 # to see what the current version is.)
 <command>cd</command> ~
-<command>wget</command> http://pypi.python.org/packages/source/d/daemon/daemon-1.0.tar.gz
-<command>tar</command> <option>-xzvf</option> daemon-1.0.tar.gz
-<command>cd</command> daemon-1.0
+<command>wget</command> http://pypi.python.org/packages/source/p/python-daemon/python-daemon-1.5.5.tar.gz
+<command>tar</command> <option>-xzvf</option> python-daemon-1.5.5.tar.gz
+<command>cd</command> python-daemon-1.5.5
 <command>sudo python</command> setup.py install
 # python module for template engine (jinja2): For documentation:
 # (If wget fails, check the <citetitle xlink:href="https://pypi.python.org/pypi/Jinja2" xlink:title="Python Jinja2">python-jinja2</citetitle> web site
diff --git a/doc/www-data.in/download.cmake b/doc/www-data.in/download.cmake
index 8800ce8536..b9dd704dd0 100644
--- a/doc/www-data.in/download.cmake
+++ b/doc/www-data.in/download.cmake
@@ -134,7 +134,7 @@ download:
         You can install Tarantool using homebrew:
         
         ```
-        $ brew install --use-clang http://tarantool.org/dist/stable/tarantool.rb
+        $ brew install https://raw.githubusercontent.com/tarantool/tarantool/stable/extra/tarantool.rb
         ```
         
         Please upgrade `clang` to version 3.2 or later using
diff --git a/extra/tarantool.rb b/extra/tarantool.rb
new file mode 100644
index 0000000000..cd6a7aa55d
--- /dev/null
+++ b/extra/tarantool.rb
@@ -0,0 +1,89 @@
+require 'formula'
+
+class Tarantool < Formula
+  homepage 'http://tarantool.org'
+
+  depends_on 'cmake'    => :build
+  depends_on "readline" => :build
+
+  option 'with-debug', "Build Debug version"
+  option 'with-tests', "Run Tests after building"
+
+  stable do
+    url 'https://github.com/tarantool/tarantool.git', :using => :git, :branch => "stable"
+    depends_on 'e2fsprogs' => :recommended
+    if build.include? 'with-tests'
+      depends_on 'python-daemon' => [:python, "daemon",  :build]
+      depends_on 'pyyaml'        => [:python, "yaml",    :build]
+      depends_on 'pexpect'       => [:python, "pexpect", :build]
+    end
+    version "1.5"
+  end
+
+  devel do
+    url 'https://github.com/tarantool/tarantool.git', :using => :git, :branch => "master"
+    depends_on 'e2fsprogs' => :build
+    if build.include? 'with-tests'
+      depends_on 'python-daemon' => [:python, "daemon", :build]
+      depends_on 'pyyaml'        => [:python, "yaml",   :build]
+    end
+    version "1.6"
+  end
+
+  def install
+    args = []
+    if build.include? 'with-debug'
+      ENV.enable_warnings
+      ENV.deparallelize
+      args << ["-DCMAKE_BUILD_TYPE=Debug"]
+      ohai "Building with Debug"
+    else
+      args << ["-DCMAKE_BUILD_TYPE=Release"]
+      ohai "Building with Release"
+    end
+    args << "-DENABLE_CLIENT=True" if build.stable?
+    args += std_cmake_args
+    
+    ohai "Preparing"
+    version = `git -C #{cached_download} describe HEAD`
+    File.open("#{buildpath}/VERSION", 'w') {|file| file.write(version)}
+
+    ohai "Configuring:"
+    system "cmake", ".", *args
+
+    ohai "Building:"
+    system "make"
+
+    ohai "Installing:"
+    system "make install"
+
+    ohai "Installing man"
+    man1.install 'doc/man/tarantool.1'
+    if build.stable?
+      man1.install 'doc/man/tarantool_box.1'
+    end
+
+    ohai "Installing config"
+    if build.stable?
+      inreplace etc/"tarantool.cfg", /^work_dir =.*/, "work_dir = #{prefix}/var/lib/tarantool"
+    else
+      doc.install "test/box/box.lua"
+      inreplace doc/"box.lua" do |s|
+          s.gsub!(/^os = require.*\n/     , '')
+          s.gsub!(/(primary_port\s*=).*/, '\1 3301,')
+          s.gsub!(/(admin_port\s*=).*/  , '\1 3313,')
+          s.gsub!(/(rows_per_wal.*)/    , '\1,')
+          s.gsub!(/^}.*/                , "\twork_dir\t\t\t= \"#{prefix}/var/lib/tarantool\",\n}")
+      end
+    end
+
+    if build.include? 'with-tests'
+        ohai "Testing Tarantool with internal test suite:"
+        system "/usr/bin/env", "python", "#{buildpath}/test/test-run.py", "--builddir", "#{buildpath}", "--vardir", "#{buildpath}/test/var"
+    end
+  end
+
+  def test
+    system "#{bin}/tarantool", "--version"
+  end
+end
-- 
GitLab