diff --git a/tasks/redis.rake b/tasks/redis.rake index 58d8e652d..b1970f3df 100644 --- a/tasks/redis.rake +++ b/tasks/redis.rake @@ -51,6 +51,9 @@ class RedisRunner end +INSTALL_DIR = ENV['INSTALL_DIR'] || '/tmp/redis' + + namespace :redis do desc 'About redis' @@ -93,27 +96,27 @@ namespace :redis do end %w(redis-benchmark redis-cli redis-server).each do |bin| - sh "cp /tmp/redis/src/#{bin} #{bin_dir}" + sh "cp #{INSTALL_DIR}/src/#{bin} #{bin_dir}" end puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}" unless File.exists?("#{conf_dir}/redis.conf") - sh "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf" + sh "cp #{INSTALL_DIR}/redis.conf #{conf_dir}/redis.conf" puts "Installed redis.conf to #{conf_dir} \n You should look at this file!" end end task :make do - sh "cd /tmp/redis/src && make clean" - sh "cd /tmp/redis/src && make" + sh "cd #{INSTALL_DIR}/src && make clean" + sh "cd #{INSTALL_DIR}/src && make" end desc "Download package" task :download do - sh 'rm -rf /tmp/redis/' if File.exists?("/tmp/redis/.svn") - sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?('/tmp/redis') - sh "cd /tmp/redis && git pull" if File.exists?("/tmp/redis/.git") + sh "rm -rf #{INSTALL_DIR}/" if File.exists?("#{INSTALL_DIR}/.svn") + sh "git clone git://github.com/antirez/redis.git #{INSTALL_DIR}" unless File.exists?(INSTALL_DIR) + sh "cd #{INSTALL_DIR} && git pull" if File.exists?("#{INSTALL_DIR}/.git") end end @@ -129,30 +132,31 @@ namespace :dtach do task :install => [:about, :download, :make] do bin_dir = "/usr/bin" + if ENV['PREFIX'] bin_dir = "#{ENV['PREFIX']}/bin" sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}") end - sh "cp /tmp/dtach-0.8/dtach #{bin_dir}" + sh "cp #{INSTALL_DIR}/dtach-0.8/dtach #{bin_dir}" end task :make do - sh 'cd /tmp/dtach-0.8/ && ./configure && make' + sh "cd #{INSTALL_DIR}/dtach-0.8/ && ./configure && make" end desc "Download package" task :download do - unless File.exists?('/tmp/dtach-0.8.tar.gz') + unless File.exists?("#{INSTALL_DIR}/dtach-0.8.tar.gz") require 'net/http' url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz' - open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end + open("#{INSTALL_DIR}/dtach-0.8.tar.gz", 'wb') do |file| file.write(open(url).read) end end - unless File.directory?('/tmp/dtach-0.8') - sh 'cd /tmp && tar xzf dtach-0.8.tar.gz' + unless File.directory?("#{INSTALL_DIR}/dtach-0.8") + sh "cd #{INSTALL_DIR} && tar xzf dtach-0.8.tar.gz" end end end