5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

the silver searcher の レシピ

Last updated at Posted at 2014-04-10

rpmからインストールするレシピ

install_path = "/usr/bin/ag"
bash "instal_the-silver-searcher" do
  user "root"
  group "root"
  code <<-EOH
rpm -ivh http://swiftsignal.com/packages/centos/6/x86_64/the-silver-searcher-0.14-1.el6.x86_64.rpm
  EOH
  not_if { ::File.exists?(install_path) }
end

the_silver_searcher github

source から インストールするレシピ

上記のレシピでもいいけど、諸事情により、ソースからインストールするレシピが必要になったので、rpmからインストールされたものを削除して、ソースからインストールするレシピを書いた。

rpmからインストールしたのを消す

rpm_install_path = "/usr/bin/ag"
if File.exists?(rpm_install_path)
  bash "uninstall_the-silver-searcher" do
    user "root"
    group "root"
    code <<-EOH
rpm -e the-silver-searcher
    EOH
  end
end

git から clone

git_clone_path = "/usr/local/src/the_silver_searcher"
source_install_path = "/usr/local/bin/ag"

git git_clone_path do
  repository "git://github.com/ggreer/the_silver_searcher.git"
  revision "master"
  action :sync
end

ビルド(コンパイル)に必要なパッケージをインストール

bash "yum development tools" do
  user "root"
  group "root"
  code <<-EOH
yum -y groupinstall "Development Tools"
  EOH
  not_if { ::File.exists?(source_install_path) }
end

depend_packages = %w{pcre-devel xz-devel}
depend_packages.each do |package_name|
  yum_package package_name do
    action :install
  end
end

ビルド & インストール

bash "install the_silver_searcher" do
  user "root"
  group "root"
  code <<-EOH
cd #{git_clone_path}
./build.sh
make install
  EOH
  not_if { ::File.exists?(source_install_path) }
end

bashで処理してるとこも、if文とか使って、冪等性を意識しております。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?