Skip to content
Browse files

Refactored Sphinx recipes. DRY and reusable.

  • Loading branch information...
1 parent 076fbbd commit d4f74568041536599656c668f2bc495ea85552d2 @pat pat committed Aug 4, 2011
View
8 vagrant_base/sphinx/metadata.rb
@@ -6,9 +6,11 @@
version '0.1.0'
depends 'build-essential'
-recipe 'sphinx', 'Installs and configures Sphinx 2.0.1-beta'
-recipe 'sphinx::sphinx-1.10', 'Installs and configures Sphinx 1.10-beta'
-recipe 'sphinx::sphinx-0.9.9', 'Installs and configures Sphinx 0.9.9'
+recipe 'sphinx', 'Installs Sphinx 2.0.1-beta'
+recipe 'sphinx:all', 'Installs Sphinx 2.0.1-beta, 1.10-beta and 0.9.9'
+recipe 'sphinx::sphinx-2.0.1', 'Installs Sphinx 2.0.1-beta'
+recipe 'sphinx::sphinx-1.10', 'Installs Sphinx 1.10-beta'
+recipe 'sphinx::sphinx-0.9.9', 'Installs Sphinx 0.9.9'
%w{ ubuntu debian }.each do |os|
supports os
View
7 vagrant_base/sphinx/recipes/all.rb
@@ -0,0 +1,7 @@
+node.set[:sphinx][:versions] = {
+ '2.0.1-beta' => '/usr/local',
+ '1.10-beta' => '/usr/local/sphinx-1.10',
+ '0.9.9' => '/usr/local/sphinx-0.9.9'
+}
+
+include_recipe 'sphinx::install'
View
45 vagrant_base/sphinx/recipes/default.rb
@@ -1,42 +1,5 @@
-package "libmysql++-dev" do
- action :install
-end
+node.set[:sphinx][:versions] = {
+ '2.0.1-beta' => '/usr/local'
+}
-package "postgresql-client" do
- action :install
-end
-
-package "libpq-dev" do
- action :install
-end
-
-
-directory '/tmp/sphinx_install' do
- mode '0755'
- action :create
-end
-
-remote_file "/tmp/sphinx_install/sphinx-2.0.1.tar.gz" do
- source "http://www.sphinxsearch.com/files/sphinx-2.0.1-beta.tar.gz"
- mode "0644"
- action :create_if_missing
-end
-
-execute "untar sphinx archive" do
- command "tar xvfz sphinx-2.0.1.tar.gz"
- cwd "/tmp/sphinx_install"
-end
-
-execute "Download libstemmer" do
- command 'curl -O http://snowball.tartarus.org/dist/libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-2.0.1'
-end
-
-execute "Untar libstemmer" do
- command 'tar zxvf libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-2.0.1'
-end
-
-execute './configure --with-mysql --with-pgsql --with-libstemmer --prefix=/usr/local && make && make install' do
- cwd '/tmp/sphinx_install/sphinx-2.0.1'
-end
+include_recipe 'sphinx::install'
View
38 vagrant_base/sphinx/recipes/install.rb
@@ -0,0 +1,38 @@
+package 'libmysql++-dev' do
+ action :install
+end
+
+package 'postgresql-client' do
+ action :install
+end
+
+package 'libpq-dev' do
+ action :install
+end
+
+script 'download libstemmer once' do
+ interpreter 'bash'
+ code <<-SHELL
+ mkdir -p /tmp/sphinx_install
+ cd /tmp/sphinx_install
+ wget http://snowball.tartarus.org/dist/libstemmer_c.tgz
+ SHELL
+end
+
+node.sphinx.versions.each do |version, path|
+ log("Installing Sphinx #{version} to #{path}") { level :debug }
+
+ script 'install sphinx with libstemmer' do
+ interpreter 'bash'
+ code <<-SHELL
+ cd /tmp/sphinx_install
+ wget http://www.sphinxsearch.com/files/sphinx-#{version}.tar.gz
+ tar zxvf sphinx-#{version}.tar.gz
+ cp libstemmer_c.tgz sphinx-#{version}/libstemmer_c.tgz
+ cd sphinx-#{version}
+ tar zxvf libstemmer_c.tgz
+ ./configure --with-mysql --with-pgsql --with-libstemmer --prefix=#{path}
+ make && make install
+ SHELL
+ end
+end
View
45 vagrant_base/sphinx/recipes/sphinx-0.9.9.rb
@@ -1,42 +1,5 @@
-package "libmysql++-dev" do
- action :install
-end
+node.set[:sphinx][:versions] = {
+ '0.9.9' => '/usr/local'
+}
-package "postgresql-client" do
- action :install
-end
-
-package "libpq-dev" do
- action :install
-end
-
-
-directory '/tmp/sphinx_install' do
- mode '0755'
- action :create
-end
-
-remote_file "/tmp/sphinx_install/sphinx-0.9.9.tar.gz" do
- source "http://www.sphinxsearch.com/files/sphinx-0.9.9.tar.gz"
- mode "0644"
- action :create_if_missing
-end
-
-execute "untar sphinx archive" do
- command "tar xvfz sphinx-0.9.9.tar.gz"
- cwd "/tmp/sphinx_install"
-end
-
-execute "Download libstemmer" do
- command 'curl -O http://snowball.tartarus.org/dist/libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-0.9.9'
-end
-
-execute "Untar libstemmer" do
- command 'tar zxvf libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-0.9.9'
-end
-
-execute './configure --with-mysql --with-pgsql --with-libstemmer --prefix=/usr/local/sphinx-0.9.9 && make && make install' do
- cwd '/tmp/sphinx_install/sphinx-0.9.9'
-end
+include_recipe 'sphinx::install'
View
45 vagrant_base/sphinx/recipes/sphinx-1.10.rb
@@ -1,42 +1,5 @@
-package "libmysql++-dev" do
- action :install
-end
+node.set[:sphinx][:versions] = {
+ '1.10-beta' => '/usr/local'
+}
-package "postgresql-client" do
- action :install
-end
-
-package "libpq-dev" do
- action :install
-end
-
-
-directory '/tmp/sphinx_install' do
- mode '0755'
- action :create
-end
-
-remote_file "/tmp/sphinx_install/sphinx-1.10.tar.gz" do
- source "http://www.sphinxsearch.com/files/sphinx-1.10-beta.tar.gz"
- mode "0644"
- action :create_if_missing
-end
-
-execute "untar sphinx archive" do
- command "tar xvfz sphinx-1.10.tar.gz"
- cwd "/tmp/sphinx_install"
-end
-
-execute "Download libstemmer" do
- command 'curl -O http://snowball.tartarus.org/dist/libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-1.10'
-end
-
-execute "Untar libstemmer" do
- command 'tar zxvf libstemmer_c.tgz'
- cwd '/tmp/sphinx_install/sphinx-1.10'
-end
-
-execute './configure --with-mysql --with-pgsql --with-libstemmer --prefix=/usr/local/sphinx-1.10 && make && make install' do
- cwd '/tmp/sphinx_install/sphinx-1.10'
-end
+include_recipe 'sphinx::install'
View
5 vagrant_base/sphinx/recipes/sphinx-2.0.1.rb
@@ -0,0 +1,5 @@
+node.set[:sphinx][:versions] = {
+ '2.0.1-beta' => '/usr/local'
+}
+
+include_recipe 'sphinx::install'

0 comments on commit d4f7456

Please sign in to comment.
Something went wrong with that request. Please try again.