Skip to content

Commit

Permalink
updated rake install tasks to allow user to choose an install directo…
Browse files Browse the repository at this point in the history
…ry by adding INSTALL_DIR=/your/path/here to the command line args
  • Loading branch information
jamster authored and defunkt committed Feb 3, 2011
1 parent 12583b6 commit 2bb0eb8
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tasks/redis.rake
Expand Up @@ -51,6 +51,9 @@ class RedisRunner

end

INSTALL_DIR = ENV['INSTALL_DIR'] || '/tmp/redis'


namespace :redis do

desc 'About redis'
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2bb0eb8

Please sign in to comment.