capistrano-rbenv 0.0.8 → 0.0.9a
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/capistrano-rbenv.rb +231 -3
- data/lib/capistrano-rbenv/version.rb +1 -1
- metadata +5 -6
- data/lib/capistrano-rbenv/deploy.rb +0 -228
data/lib/capistrano-rbenv.rb
CHANGED
@@ -1,8 +1,236 @@
|
|
1
|
-
require "capistrano-rbenv/deploy"
|
2
1
|
require "capistrano-rbenv/version"
|
2
|
+
require "capistrano/configuration"
|
3
|
+
require "capistrano/recipes/deploy/scm"
|
3
4
|
|
4
5
|
module Capistrano
|
5
|
-
module
|
6
|
-
|
6
|
+
module RbEnv
|
7
|
+
def self.extended(configuration)
|
8
|
+
configuration.load {
|
9
|
+
namespace(:rbenv) {
|
10
|
+
_cset(:rbenv_path) {
|
11
|
+
capture("echo $HOME/.rbenv").chomp()
|
12
|
+
}
|
13
|
+
_cset(:rbenv_bin) {
|
14
|
+
File.join(rbenv_path, 'bin', 'rbenv')
|
15
|
+
}
|
16
|
+
_cset(:rbenv_cmd) { # to use custom rbenv_path, we use `env` instead of cap's default_environment.
|
17
|
+
"env RBENV_VERSION=#{rbenv_ruby_version.dump} #{rbenv_bin}"
|
18
|
+
}
|
19
|
+
_cset(:rbenv_repository, 'git://github.com/sstephenson/rbenv.git')
|
20
|
+
_cset(:rbenv_branch, 'master')
|
21
|
+
|
22
|
+
_cset(:rbenv_plugins) {{
|
23
|
+
"ruby-build" => { :repository => "git://github.com/sstephenson/ruby-build.git", :branch => "master" },
|
24
|
+
}}
|
25
|
+
_cset(:rbenv_plugins_options, {}) # for backward compatibility. plugin options can be configured from :rbenv_plugins.
|
26
|
+
_cset(:rbenv_plugins_path) {
|
27
|
+
File.join(rbenv_path, 'plugins')
|
28
|
+
}
|
29
|
+
_cset(:rbenv_ruby_version, "1.9.3-p327")
|
30
|
+
|
31
|
+
_cset(:rbenv_use_bundler, true)
|
32
|
+
set(:bundle_cmd) { # override bundle_cmd in "bundler/capistrano"
|
33
|
+
rbenv_use_bundler ? "#{rbenv_cmd} exec bundle" : 'bundle'
|
34
|
+
}
|
35
|
+
|
36
|
+
desc("Setup rbenv.")
|
37
|
+
task(:setup, :except => { :no_release => true }) {
|
38
|
+
dependencies
|
39
|
+
update
|
40
|
+
configure
|
41
|
+
build
|
42
|
+
setup_bundler if rbenv_use_bundler
|
43
|
+
}
|
44
|
+
after 'deploy:setup', 'rbenv:setup'
|
45
|
+
|
46
|
+
def rbenv_update_repository(destination, options={})
|
47
|
+
configuration = Capistrano::Configuration.new()
|
48
|
+
options = {
|
49
|
+
:source => proc { Capistrano::Deploy::SCM.new(configuration[:scm], configuration) },
|
50
|
+
:revision => proc { configuration[:source].head },
|
51
|
+
:real_revision => proc {
|
52
|
+
configuration[:source].local.query_revision(configuration[:revision]) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } }
|
53
|
+
},
|
54
|
+
}.merge(options)
|
55
|
+
variables.merge(options).each do |key, val|
|
56
|
+
configuration.set(key, val)
|
57
|
+
end
|
58
|
+
source = configuration[:source]
|
59
|
+
revision = configuration[:real_revision]
|
60
|
+
#
|
61
|
+
# we cannot use source.sync since it cleans up untacked files in the repository.
|
62
|
+
# currently we are just calling git sub-commands directly to avoid the problems.
|
63
|
+
#
|
64
|
+
verbose = configuration[:scm_verbose] ? nil : "-q"
|
65
|
+
run((<<-EOS).gsub(/\s+/, ' ').strip)
|
66
|
+
if [ -d #{destination} ]; then
|
67
|
+
cd #{destination} &&
|
68
|
+
#{source.command} fetch #{verbose} #{source.origin} &&
|
69
|
+
#{source.command} fetch --tags #{verbose} #{source.origin} &&
|
70
|
+
#{source.command} reset #{verbose} --hard #{revision};
|
71
|
+
else
|
72
|
+
#{source.checkout(revision, destination)};
|
73
|
+
fi
|
74
|
+
EOS
|
75
|
+
end
|
76
|
+
|
77
|
+
desc("Update rbenv installation.")
|
78
|
+
task(:update, :except => { :no_release => true }) {
|
79
|
+
rbenv_update_repository(rbenv_path, :scm => :git, :repository => rbenv_repository, :branch => rbenv_branch)
|
80
|
+
plugins.update
|
81
|
+
}
|
82
|
+
|
83
|
+
desc("Purge rbenv.")
|
84
|
+
task(:purge, :except => { :no_release => true }) {
|
85
|
+
run("rm -rf #{rbenv_path}")
|
86
|
+
}
|
87
|
+
|
88
|
+
namespace(:plugins) {
|
89
|
+
desc("Update rbenv plugins.")
|
90
|
+
task(:update, :except => { :no_release => true }) {
|
91
|
+
rbenv_plugins.each do |name, repository|
|
92
|
+
# for backward compatibility, obtain plugin options from :rbenv_plugins_options first
|
93
|
+
options = rbenv_plugins_options.fetch(name, {})
|
94
|
+
options = options.merge(Hash === repository ? repository : {:repository => repository})
|
95
|
+
rbenv_update_repository(File.join(rbenv_plugins_path, name), options.merge(:scm => :git))
|
96
|
+
end
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
_cset(:rbenv_configure_home) { capture("echo $HOME").chomp }
|
101
|
+
_cset(:rbenv_configure_shell) { capture("echo $SHELL").chomp }
|
102
|
+
_cset(:rbenv_configure_files) {
|
103
|
+
if fetch(:rbenv_configure_basenames, nil)
|
104
|
+
[ rbenv_configure_basenames ].flatten.map { |basename|
|
105
|
+
File.join(rbenv_configure_home, basename)
|
106
|
+
}
|
107
|
+
else
|
108
|
+
bash_profile = File.join(rbenv_configure_home, '.bash_profile')
|
109
|
+
profile = File.join(rbenv_configure_home, '.profile')
|
110
|
+
case File.basename(rbenv_configure_shell)
|
111
|
+
when /bash/
|
112
|
+
[ capture("test -f #{profile.dump} && echo #{profile.dump} || echo #{bash_profile.dump}").chomp ]
|
113
|
+
when /zsh/
|
114
|
+
[ File.join(rbenv_configure_home, '.zshenv') ]
|
115
|
+
else # other sh compatible shell such like dash
|
116
|
+
[ profile ]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
}
|
120
|
+
_cset(:rbenv_configure_script) {
|
121
|
+
(<<-EOS).gsub(/^\s*/, '')
|
122
|
+
# Configured by capistrano-rbenv. Do not edit directly.
|
123
|
+
export PATH="#{rbenv_path}/bin:$PATH"
|
124
|
+
eval "$(rbenv init -)"
|
125
|
+
EOS
|
126
|
+
}
|
127
|
+
_cset(:rbenv_configure_signature, '##rbenv:configure')
|
128
|
+
task(:configure, :except => { :no_release => true }) {
|
129
|
+
if fetch(:rbenv_use_configure, true)
|
130
|
+
script = File.join('/tmp', "rbenv.#{$$}")
|
131
|
+
config = [ rbenv_configure_files ].flatten
|
132
|
+
config_map = Hash[ config.map { |f| [f, File.join('/tmp', "#{File.basename(f)}.#{$$}")] } ]
|
133
|
+
begin
|
134
|
+
execute = []
|
135
|
+
put(rbenv_configure_script, script)
|
136
|
+
config_map.each { |file, temp|
|
137
|
+
## (1) copy original config to temporaly file and then modify
|
138
|
+
execute << "( test -f #{file} || touch #{file} )"
|
139
|
+
execute << "cp -fp #{file} #{temp}"
|
140
|
+
execute << "sed -i -e '/^#{Regexp.escape(rbenv_configure_signature)}/,/^#{Regexp.escape(rbenv_configure_signature)}/d' #{temp}"
|
141
|
+
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
142
|
+
execute << "cat #{script} >> #{temp}"
|
143
|
+
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
144
|
+
## (2) update config only if it is needed
|
145
|
+
execute << "cp -fp #{file} #{file}.orig"
|
146
|
+
execute << "( diff -u #{file} #{temp} || mv -f #{temp} #{file} )"
|
147
|
+
}
|
148
|
+
run(execute.join(' && '))
|
149
|
+
ensure
|
150
|
+
remove = [ script ] + config_map.values
|
151
|
+
run("rm -f #{remove.join(' ')}") rescue nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
}
|
155
|
+
|
156
|
+
_cset(:rbenv_platform) {
|
157
|
+
capture((<<-EOS).gsub(/\s+/, ' ')).strip
|
158
|
+
if test -f /etc/debian_version; then
|
159
|
+
if test -f /etc/lsb-release && grep -i -q DISTRIB_ID=Ubuntu /etc/lsb-release; then
|
160
|
+
echo ubuntu;
|
161
|
+
else
|
162
|
+
echo debian;
|
163
|
+
fi;
|
164
|
+
elif test -f /etc/redhat-release; then
|
165
|
+
echo redhat;
|
166
|
+
else
|
167
|
+
echo unknown;
|
168
|
+
fi;
|
169
|
+
EOS
|
170
|
+
}
|
171
|
+
_cset(:rbenv_ruby_dependencies) {
|
172
|
+
case rbenv_platform
|
173
|
+
when /(debian|ubuntu)/i
|
174
|
+
%w(git-core build-essential libreadline6-dev zlib1g-dev libssl-dev bison)
|
175
|
+
when /redhat/i
|
176
|
+
%w(git-core autoconf glibc-devel patch readline readline-devel zlib zlib-devel openssl bison)
|
177
|
+
else
|
178
|
+
[]
|
179
|
+
end
|
180
|
+
}
|
181
|
+
task(:dependencies, :except => { :no_release => true }) {
|
182
|
+
unless rbenv_ruby_dependencies.empty?
|
183
|
+
case rbenv_platform
|
184
|
+
when /(debian|ubuntu)/i
|
185
|
+
begin
|
186
|
+
run("dpkg-query -s #{rbenv_ruby_dependencies.join(' ')} > /dev/null")
|
187
|
+
rescue
|
188
|
+
run("#{sudo} apt-get install -q -y #{rbenv_ruby_dependencies.join(' ')}")
|
189
|
+
end
|
190
|
+
when /redhat/i
|
191
|
+
begin
|
192
|
+
run("rpm -qi #{rbenv_ruby_dependencies.join(' ')} > /dev/null")
|
193
|
+
rescue
|
194
|
+
run("#{sudo} yum install -q -y #{rbenv_ruby_dependencies.join(' ')}")
|
195
|
+
end
|
196
|
+
else
|
197
|
+
# nop
|
198
|
+
end
|
199
|
+
end
|
200
|
+
}
|
201
|
+
|
202
|
+
desc("Build ruby within rbenv.")
|
203
|
+
task(:build, :except => { :no_release => true }) {
|
204
|
+
ruby = fetch(:rbenv_ruby_cmd, 'ruby')
|
205
|
+
if rbenv_ruby_version != 'system'
|
206
|
+
run("#{rbenv_bin} whence #{ruby} | fgrep -q #{rbenv_ruby_version} || #{rbenv_bin} install #{rbenv_ruby_version}")
|
207
|
+
end
|
208
|
+
run("#{rbenv_cmd} exec #{ruby} --version && #{rbenv_cmd} global #{rbenv_ruby_version}")
|
209
|
+
}
|
210
|
+
|
211
|
+
_cset(:rbenv_bundler_gem, 'bundler')
|
212
|
+
task(:setup_bundler, :except => { :no_release => true }) {
|
213
|
+
gem = "#{rbenv_cmd} exec gem"
|
214
|
+
if v = fetch(:rbenv_bundler_version, nil)
|
215
|
+
q = "-n #{rbenv_bundler_gem} -v #{v}"
|
216
|
+
f = "fgrep #{rbenv_bundler_gem} | fgrep #{v}"
|
217
|
+
i = "-v #{v} #{rbenv_bundler_gem}"
|
218
|
+
else
|
219
|
+
q = "-n #{rbenv_bundler_gem}"
|
220
|
+
f = "fgrep #{rbenv_bundler_gem}"
|
221
|
+
i = "#{rbenv_bundler_gem}"
|
222
|
+
end
|
223
|
+
run("unset -v GEM_HOME; #{gem} query #{q} 2>/dev/null | #{f} || #{gem} install -q #{i}")
|
224
|
+
run("#{rbenv_cmd} rehash && #{bundle_cmd} version")
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
end
|
7
229
|
end
|
8
230
|
end
|
231
|
+
|
232
|
+
if Capistrano::Configuration.instance
|
233
|
+
Capistrano::Configuration.instance.extend(Capistrano::RbEnv)
|
234
|
+
end
|
235
|
+
|
236
|
+
# vim:set ft=ruby ts=2 sw=2 :
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-rbenv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9a
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Yamashita Yuu
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -41,7 +41,6 @@ files:
|
|
41
41
|
- Rakefile
|
42
42
|
- capistrano-rbenv.gemspec
|
43
43
|
- lib/capistrano-rbenv.rb
|
44
|
-
- lib/capistrano-rbenv/deploy.rb
|
45
44
|
- lib/capistrano-rbenv/version.rb
|
46
45
|
homepage: https://github.com/yyuu/capistrano-rbenv
|
47
46
|
licenses: []
|
@@ -58,9 +57,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
58
|
none: false
|
60
59
|
requirements:
|
61
|
-
- - ! '
|
60
|
+
- - ! '>'
|
62
61
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
62
|
+
version: 1.3.1
|
64
63
|
requirements: []
|
65
64
|
rubyforge_project:
|
66
65
|
rubygems_version: 1.8.23
|
@@ -1,228 +0,0 @@
|
|
1
|
-
|
2
|
-
require "capistrano/configuration"
|
3
|
-
require "capistrano/recipes/deploy/scm"
|
4
|
-
|
5
|
-
module Capistrano
|
6
|
-
module RbEnv
|
7
|
-
def self.extended(configuration)
|
8
|
-
configuration.load {
|
9
|
-
namespace(:rbenv) {
|
10
|
-
_cset(:rbenv_path) {
|
11
|
-
capture("echo $HOME/.rbenv").chomp()
|
12
|
-
}
|
13
|
-
_cset(:rbenv_bin) {
|
14
|
-
File.join(rbenv_path, 'bin', 'rbenv')
|
15
|
-
}
|
16
|
-
_cset(:rbenv_cmd) { # to use custom rbenv_path, we use `env` instead of cap's default_environment.
|
17
|
-
"env RBENV_VERSION=#{rbenv_ruby_version.dump} #{rbenv_bin}"
|
18
|
-
}
|
19
|
-
_cset(:rbenv_repository, 'git://github.com/sstephenson/rbenv.git')
|
20
|
-
_cset(:rbenv_branch, 'master')
|
21
|
-
|
22
|
-
_cset(:rbenv_plugins) {{
|
23
|
-
"ruby-build" => { :repository => "git://github.com/sstephenson/ruby-build.git", :branch => "master" },
|
24
|
-
}}
|
25
|
-
_cset(:rbenv_plugins_options, {}) # for backward compatibility. plugin options can be configured from :rbenv_plugins.
|
26
|
-
_cset(:rbenv_plugins_path) {
|
27
|
-
File.join(rbenv_path, 'plugins')
|
28
|
-
}
|
29
|
-
_cset(:rbenv_ruby_version, "1.9.3-p327")
|
30
|
-
|
31
|
-
_cset(:rbenv_use_bundler, true)
|
32
|
-
set(:bundle_cmd) { # override bundle_cmd in "bundler/capistrano"
|
33
|
-
rbenv_use_bundler ? "#{rbenv_cmd} exec bundle" : 'bundle'
|
34
|
-
}
|
35
|
-
|
36
|
-
desc("Setup rbenv.")
|
37
|
-
task(:setup, :except => { :no_release => true }) {
|
38
|
-
dependencies
|
39
|
-
update
|
40
|
-
configure
|
41
|
-
build
|
42
|
-
setup_bundler if rbenv_use_bundler
|
43
|
-
}
|
44
|
-
after 'deploy:setup', 'rbenv:setup'
|
45
|
-
|
46
|
-
def rbenv_update_repository(destination, options={})
|
47
|
-
configuration = Capistrano::Configuration.new()
|
48
|
-
options = {
|
49
|
-
:source => proc { Capistrano::Deploy::SCM.new(configuration[:scm], configuration) },
|
50
|
-
:revision => proc { configuration[:source].head },
|
51
|
-
:real_revision => proc {
|
52
|
-
configuration[:source].local.query_revision(configuration[:revision]) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } }
|
53
|
-
},
|
54
|
-
}.merge(options)
|
55
|
-
variables.merge(options).each do |key, val|
|
56
|
-
configuration.set(key, val)
|
57
|
-
end
|
58
|
-
source = configuration[:source]
|
59
|
-
revision = configuration[:real_revision]
|
60
|
-
#
|
61
|
-
# we cannot use source.sync since it cleans up untacked files in the repository.
|
62
|
-
# currently we are just calling git sub-commands directly to avoid the problems.
|
63
|
-
#
|
64
|
-
verbose = configuration[:scm_verbose] ? nil : "-q"
|
65
|
-
run((<<-EOS).gsub(/\s+/, ' ').strip)
|
66
|
-
if [ -d #{destination} ]; then
|
67
|
-
cd #{destination} &&
|
68
|
-
#{source.command} fetch #{verbose} #{source.origin} &&
|
69
|
-
#{source.command} fetch --tags #{verbose} #{source.origin} &&
|
70
|
-
#{source.command} reset #{verbose} --hard #{revision};
|
71
|
-
else
|
72
|
-
#{source.checkout(revision, destination)};
|
73
|
-
fi
|
74
|
-
EOS
|
75
|
-
end
|
76
|
-
|
77
|
-
desc("Update rbenv installation.")
|
78
|
-
task(:update, :except => { :no_release => true }) {
|
79
|
-
rbenv_update_repository(rbenv_path, :scm => :git, :repository => rbenv_repository, :branch => rbenv_branch)
|
80
|
-
plugins.update
|
81
|
-
}
|
82
|
-
|
83
|
-
desc("Purge rbenv.")
|
84
|
-
task(:purge, :except => { :no_release => true }) {
|
85
|
-
run("rm -rf #{rbenv_path}")
|
86
|
-
}
|
87
|
-
|
88
|
-
namespace(:plugins) {
|
89
|
-
desc("Update rbenv plugins.")
|
90
|
-
task(:update, :except => { :no_release => true }) {
|
91
|
-
rbenv_plugins.each do |name, repository|
|
92
|
-
# for backward compatibility, obtain plugin options from :rbenv_plugins_options first
|
93
|
-
options = rbenv_plugins_options.fetch(name, {})
|
94
|
-
options = options.merge(Hash === repository ? repository : {:repository => repository})
|
95
|
-
rbenv_update_repository(File.join(rbenv_plugins_path, name), options.merge(:scm => :git))
|
96
|
-
end
|
97
|
-
}
|
98
|
-
}
|
99
|
-
|
100
|
-
_cset(:rbenv_configure_home) { capture("echo $HOME").chomp }
|
101
|
-
_cset(:rbenv_configure_shell) { capture("echo $SHELL").chomp }
|
102
|
-
_cset(:rbenv_configure_files) {
|
103
|
-
if fetch(:rbenv_configure_basenames, nil)
|
104
|
-
[ rbenv_configure_basenames ].flatten.map { |basename|
|
105
|
-
File.join(rbenv_configure_home, basename)
|
106
|
-
}
|
107
|
-
else
|
108
|
-
bash_profile = File.join(rbenv_configure_home, '.bash_profile')
|
109
|
-
profile = File.join(rbenv_configure_home, '.profile')
|
110
|
-
case File.basename(rbenv_configure_shell)
|
111
|
-
when /bash/
|
112
|
-
[ capture("test -f #{profile.dump} && echo #{profile.dump} || echo #{bash_profile.dump}") ]
|
113
|
-
when /zsh/
|
114
|
-
[ File.join(rbenv_configure_home, '.zshenv') ]
|
115
|
-
else # other sh compatible shell such like dash
|
116
|
-
[ profile ]
|
117
|
-
end
|
118
|
-
end
|
119
|
-
}
|
120
|
-
_cset(:rbenv_configure_script) {
|
121
|
-
(<<-EOS).gsub(/^\s*/, '')
|
122
|
-
# Configured by capistrano-rbenv. Do not edit directly.
|
123
|
-
export PATH="#{rbenv_path}/bin:$PATH"
|
124
|
-
eval "$(rbenv init -)"
|
125
|
-
EOS
|
126
|
-
}
|
127
|
-
_cset(:rbenv_configure_signature, '##rbenv:configure')
|
128
|
-
task(:configure, :except => { :no_release => true }) {
|
129
|
-
if fetch(:rbenv_use_configure, true)
|
130
|
-
script = File.join('/tmp', "rbenv.#{$$}")
|
131
|
-
config = [ rbenv_configure_files ].flatten
|
132
|
-
config_map = Hash[ config.map { |f| [f, File.join('/tmp', "#{File.basename(f)}.#{$$}")] } ]
|
133
|
-
begin
|
134
|
-
execute = []
|
135
|
-
put(rbenv_configure_script, script)
|
136
|
-
config_map.each { |file, temp|
|
137
|
-
## (1) copy original config to temporaly file and then modify
|
138
|
-
execute << "( test -f #{file} || touch #{file} )"
|
139
|
-
execute << "cp -fp #{file} #{temp}"
|
140
|
-
execute << "sed -i -e '/^#{Regexp.escape(rbenv_configure_signature)}/,/^#{Regexp.escape(rbenv_configure_signature)}/d' #{temp}"
|
141
|
-
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
142
|
-
execute << "cat #{script} >> #{temp}"
|
143
|
-
execute << "echo #{rbenv_configure_signature.dump} >> #{temp}"
|
144
|
-
## (2) update config only if it is needed
|
145
|
-
execute << "cp -fp #{file} #{file}.orig"
|
146
|
-
execute << "( diff -u #{file} #{temp} || mv -f #{temp} #{file} )"
|
147
|
-
}
|
148
|
-
run(execute.join(' && '))
|
149
|
-
ensure
|
150
|
-
remove = [ script ] + config_map.values
|
151
|
-
run("rm -f #{remove.join(' ')}") rescue nil
|
152
|
-
end
|
153
|
-
end
|
154
|
-
}
|
155
|
-
|
156
|
-
_cset(:rbenv_platform) {
|
157
|
-
capture((<<-EOS).gsub(/\s+/, ' ')).strip
|
158
|
-
if test -f /etc/debian_version; then
|
159
|
-
if test -f /etc/lsb-release && grep -i -q DISTRIB_ID=Ubuntu /etc/lsb-release; then
|
160
|
-
echo ubuntu;
|
161
|
-
else
|
162
|
-
echo debian;
|
163
|
-
fi;
|
164
|
-
elif test -f /etc/redhat-release; then
|
165
|
-
echo redhat;
|
166
|
-
else
|
167
|
-
echo unknown;
|
168
|
-
fi;
|
169
|
-
EOS
|
170
|
-
}
|
171
|
-
_cset(:rbenv_ruby_dependencies) {
|
172
|
-
case rbenv_platform
|
173
|
-
when /(debian|ubuntu)/i
|
174
|
-
%w(git-core build-essential libreadline6-dev zlib1g-dev libssl-dev bison)
|
175
|
-
when /redhat/i
|
176
|
-
%w(git-core autoconf glibc-devel patch readline readline-devel zlib zlib-devel openssl bison)
|
177
|
-
else
|
178
|
-
[]
|
179
|
-
end
|
180
|
-
}
|
181
|
-
task(:dependencies, :except => { :no_release => true }) {
|
182
|
-
unless rbenv_ruby_dependencies.empty?
|
183
|
-
case rbenv_platform
|
184
|
-
when /(debian|ubuntu)/i
|
185
|
-
run("#{sudo} apt-get install -q -y #{rbenv_ruby_dependencies.join(' ')}")
|
186
|
-
when /redhat/i
|
187
|
-
run("#{sudo} yum install -q -y #{rbenv_ruby_dependencies.join(' ')}")
|
188
|
-
else
|
189
|
-
# nop
|
190
|
-
end
|
191
|
-
end
|
192
|
-
}
|
193
|
-
|
194
|
-
desc("Build ruby within rbenv.")
|
195
|
-
task(:build, :except => { :no_release => true }) {
|
196
|
-
ruby = fetch(:rbenv_ruby_cmd, 'ruby')
|
197
|
-
if rbenv_ruby_version != 'system'
|
198
|
-
run("#{rbenv_bin} whence #{ruby} | fgrep -q #{rbenv_ruby_version} || #{rbenv_bin} install #{rbenv_ruby_version}")
|
199
|
-
end
|
200
|
-
run("#{rbenv_cmd} exec #{ruby} --version && #{rbenv_cmd} global #{rbenv_ruby_version}")
|
201
|
-
}
|
202
|
-
|
203
|
-
_cset(:rbenv_bundler_gem, 'bundler')
|
204
|
-
task(:setup_bundler, :except => { :no_release => true }) {
|
205
|
-
gem = "#{rbenv_cmd} exec gem"
|
206
|
-
if v = fetch(:rbenv_bundler_version, nil)
|
207
|
-
q = "-n #{rbenv_bundler_gem} -v #{v}"
|
208
|
-
f = "fgrep #{rbenv_bundler_gem} | fgrep #{v}"
|
209
|
-
i = "-v #{v} #{rbenv_bundler_gem}"
|
210
|
-
else
|
211
|
-
q = "-n #{rbenv_bundler_gem}"
|
212
|
-
f = "fgrep #{rbenv_bundler_gem}"
|
213
|
-
i = "#{rbenv_bundler_gem}"
|
214
|
-
end
|
215
|
-
run("unset -v GEM_HOME; #{gem} query #{q} 2>/dev/null | #{f} || #{gem} install -q #{i}")
|
216
|
-
run("#{rbenv_cmd} rehash && #{bundle_cmd} version")
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
if Capistrano::Configuration.instance
|
225
|
-
Capistrano::Configuration.instance.extend(Capistrano::RbEnv)
|
226
|
-
end
|
227
|
-
|
228
|
-
# vim:set ft=ruby ts=2 sw=2 :
|