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文とか使って、冪等性を意識しております。