Skip to content

Commit 2bb0eb8

Browse files
jamsterdefunkt
authored andcommitted
updated rake install tasks to allow user to choose an install directory by adding INSTALL_DIR=/your/path/here to the command line args
1 parent 12583b6 commit 2bb0eb8

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

tasks/redis.rake

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class RedisRunner
5151

5252
end
5353

54+
INSTALL_DIR = ENV['INSTALL_DIR'] || '/tmp/redis'
55+
56+
5457
namespace :redis do
5558

5659
desc 'About redis'
@@ -93,27 +96,27 @@ namespace :redis do
9396
end
9497

9598
%w(redis-benchmark redis-cli redis-server).each do |bin|
96-
sh "cp /tmp/redis/src/#{bin} #{bin_dir}"
99+
sh "cp #{INSTALL_DIR}/src/#{bin} #{bin_dir}"
97100
end
98101

99102
puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
100103

101104
unless File.exists?("#{conf_dir}/redis.conf")
102-
sh "cp /tmp/redis/redis.conf #{conf_dir}/redis.conf"
105+
sh "cp #{INSTALL_DIR}/redis.conf #{conf_dir}/redis.conf"
103106
puts "Installed redis.conf to #{conf_dir} \n You should look at this file!"
104107
end
105108
end
106109

107110
task :make do
108-
sh "cd /tmp/redis/src && make clean"
109-
sh "cd /tmp/redis/src && make"
111+
sh "cd #{INSTALL_DIR}/src && make clean"
112+
sh "cd #{INSTALL_DIR}/src && make"
110113
end
111114

112115
desc "Download package"
113116
task :download do
114-
sh 'rm -rf /tmp/redis/' if File.exists?("/tmp/redis/.svn")
115-
sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?('/tmp/redis')
116-
sh "cd /tmp/redis && git pull" if File.exists?("/tmp/redis/.git")
117+
sh "rm -rf #{INSTALL_DIR}/" if File.exists?("#{INSTALL_DIR}/.svn")
118+
sh "git clone git://github.com/antirez/redis.git #{INSTALL_DIR}" unless File.exists?(INSTALL_DIR)
119+
sh "cd #{INSTALL_DIR} && git pull" if File.exists?("#{INSTALL_DIR}/.git")
117120
end
118121

119122
end
@@ -129,30 +132,31 @@ namespace :dtach do
129132
task :install => [:about, :download, :make] do
130133

131134
bin_dir = "/usr/bin"
135+
132136

133137
if ENV['PREFIX']
134138
bin_dir = "#{ENV['PREFIX']}/bin"
135139
sh "mkdir -p #{bin_dir}" unless File.exists?("#{bin_dir}")
136140
end
137141

138-
sh "cp /tmp/dtach-0.8/dtach #{bin_dir}"
142+
sh "cp #{INSTALL_DIR}/dtach-0.8/dtach #{bin_dir}"
139143
end
140144

141145
task :make do
142-
sh 'cd /tmp/dtach-0.8/ && ./configure && make'
146+
sh "cd #{INSTALL_DIR}/dtach-0.8/ && ./configure && make"
143147
end
144148

145149
desc "Download package"
146150
task :download do
147-
unless File.exists?('/tmp/dtach-0.8.tar.gz')
151+
unless File.exists?("#{INSTALL_DIR}/dtach-0.8.tar.gz")
148152
require 'net/http'
149153

150154
url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
151-
open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
155+
open("#{INSTALL_DIR}/dtach-0.8.tar.gz", 'wb') do |file| file.write(open(url).read) end
152156
end
153157

154-
unless File.directory?('/tmp/dtach-0.8')
155-
sh 'cd /tmp && tar xzf dtach-0.8.tar.gz'
158+
unless File.directory?("#{INSTALL_DIR}/dtach-0.8")
159+
sh "cd #{INSTALL_DIR} && tar xzf dtach-0.8.tar.gz"
156160
end
157161
end
158162
end

0 commit comments

Comments
 (0)