rconf 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/rconf +8 -0
- data/lib/patches/ree-1.8.7-2012.02-rs-custom +4 -0
- data/lib/rconf/configurator.rb +15 -0
- data/lib/rconf/configurators/bundler_configurator.rb +1 -0
- data/lib/rconf/configurators/ruby_configurator.rb +103 -14
- data/lib/rconf/version.rb +1 -1
- data/spec/configurators/bundler_configurator_spec.rb +1 -1
- data/spec/configurators/ruby_configurator_spec.rb +9 -4
- metadata +3 -2
data/bin/rconf
CHANGED
@@ -153,6 +153,14 @@ where [options] are:
|
|
153
153
|
report_success
|
154
154
|
report('Latest rconf version is ' + version.blue)
|
155
155
|
update_rconf(version)
|
156
|
+
ConfiguratorRegistry.each do |_, configurator|
|
157
|
+
updater = configurator.updater
|
158
|
+
|
159
|
+
if updater
|
160
|
+
# Do not invoke "call" when no updater is available
|
161
|
+
updater.call
|
162
|
+
end
|
163
|
+
end
|
156
164
|
end
|
157
165
|
|
158
166
|
# Calls given block with all combination of installed rubies
|
data/lib/rconf/configurator.rb
CHANGED
@@ -72,6 +72,21 @@ module RightConf
|
|
72
72
|
true
|
73
73
|
end
|
74
74
|
|
75
|
+
# Define code to be run whenever rconf gets updated. Acts as a getter and setter
|
76
|
+
#
|
77
|
+
# === Parameters
|
78
|
+
# val(Proc):: Code to run when rconf is updated
|
79
|
+
#
|
80
|
+
# === Return
|
81
|
+
# true:: The updater if no parameter is passed, true otherwise
|
82
|
+
def updater(val=nil)
|
83
|
+
if val
|
84
|
+
@updater = val
|
85
|
+
true
|
86
|
+
else
|
87
|
+
@updater
|
88
|
+
end
|
89
|
+
end
|
75
90
|
end
|
76
91
|
|
77
92
|
# Extend base class with ClassMethods module methods
|
@@ -111,6 +111,7 @@ module RightConf
|
|
111
111
|
options += [ '--no-ri', '--no-rdoc', { :abort_on_failure => 'Failed to install bundler' } ]
|
112
112
|
Command.execute(*options)
|
113
113
|
report_success
|
114
|
+
Command.execute('rbenv', 'rehash') # this is optional; don't bother to report failures
|
114
115
|
true
|
115
116
|
end
|
116
117
|
|
@@ -11,6 +11,18 @@
|
|
11
11
|
|
12
12
|
module RightConf
|
13
13
|
|
14
|
+
# Specify rbenv and ruby-build git revision for installation
|
15
|
+
RBENV_GIT_REPO = 'git://github.com/sstephenson/rbenv.git'
|
16
|
+
RBENV_GIT_REVISION = "9375e99f921f428849f19efe2a2e500b3295d1a7"
|
17
|
+
|
18
|
+
RUBYBUILD_GIT_REPO = 'git://github.com/sstephenson/ruby-build.git'
|
19
|
+
RUBY_BUILD_GIT_REVISION = "28b9bcb6df1bc18fb2b06e25ee65f397ac3d4632"
|
20
|
+
|
21
|
+
# Local installation target folders
|
22
|
+
RBENV_INSTALL_TARGET = "#{ENV['HOME']}/.rbenv"
|
23
|
+
RUBYBUILD_TARGET = "#{RBENV_INSTALL_TARGET}/plugins/ruby-build"
|
24
|
+
|
25
|
+
|
14
26
|
class RubyConfigurator
|
15
27
|
|
16
28
|
include Configurator
|
@@ -22,13 +34,15 @@ module RightConf
|
|
22
34
|
|
23
35
|
setting 'version', 'Ruby version using rbenv notation (see "rbenv versions")', :required => true
|
24
36
|
|
37
|
+
updater lambda { update_rbenv_installation }
|
38
|
+
|
39
|
+
|
25
40
|
# Message to display to the user when rbenv isn't in the path.
|
26
|
-
PATH_ADVICE = "You should add 'eval \"$(rbenv init -)\"' to your .bash_profile / .bashrc etc. " +
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
" echo 'export PATH=\"$HOME/.rbenv/shims:$PATH\" >> ~/.bash_profile'\n"
|
41
|
+
PATH_ADVICE = "You should add rbenv to your path and 'eval \"$(rbenv init -)\"' to your .bash_profile / .bashrc etc. " +
|
42
|
+
"so rbenv is properly initialized in new shells.\n\n" +
|
43
|
+
"If you are a bash user (e.g. Mac OS X), you can add the following to ~/.bash_profile:\n\n" +
|
44
|
+
" echo 'export PATH=\"$HOME/.rbenv/bin:$PATH\"' >> ~/.bash_profile\n" +
|
45
|
+
" echo 'eval \"$(rbenv init -)\"' >> ~/.bash_profile\n\n"
|
32
46
|
|
33
47
|
# Let configurator run, it is idempotent
|
34
48
|
#
|
@@ -90,7 +104,7 @@ module RightConf
|
|
90
104
|
# Bail if rbenv isn't correctly initialized (we can't use it in this state)
|
91
105
|
post_note "rconf detected rbenv is installed in #{rbenv_path} but it is not in the PATH.\n" + PATH_ADVICE
|
92
106
|
aborting(true)
|
93
|
-
elsif
|
107
|
+
elsif rbenv_in_path
|
94
108
|
# rbenv is installed and initialized; make sure we have a suitable version
|
95
109
|
res.output =~ /^rbenv ([0-9]+)\.([0-9]+)\.([0-9]+)$/
|
96
110
|
maj, min, build = [$1.to_i, $2.to_i, $3.to_i]
|
@@ -100,15 +114,92 @@ module RightConf
|
|
100
114
|
end
|
101
115
|
else
|
102
116
|
# No sign of rbenv; try to install it
|
103
|
-
|
104
|
-
PackageInstaller.install('rbenv', opts)
|
105
|
-
opts = { :report => true }.merge(abort_option('Failed to install ruby-build'))
|
106
|
-
PackageInstaller.install('ruby-build', opts)
|
117
|
+
install_rbenv_from_git
|
107
118
|
end
|
108
119
|
|
109
120
|
true
|
110
121
|
end
|
111
122
|
|
123
|
+
|
124
|
+
# Overwrite ruby-build definition file to use our own, patched version of REE and to set certain compile options
|
125
|
+
# so that it REE works with newer versions of GCC as well.
|
126
|
+
#
|
127
|
+
# === Return
|
128
|
+
# true:: Always return true
|
129
|
+
def self.add_custom_ree_definition
|
130
|
+
curr_dir=File.dirname(__FILE__)
|
131
|
+
patched_ree = "#{curr_dir}/../../patches/ree-1.8.7-2012.02-rs-custom"
|
132
|
+
FileUtils.cp patched_ree, "#{RUBYBUILD_TARGET}/share/ruby-build/ree-1.8.7-2012.02"
|
133
|
+
|
134
|
+
true
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# Update rbenv and ruby-build to the version specified through the git commit version constant
|
139
|
+
#
|
140
|
+
# === Return
|
141
|
+
# true:: Always return true
|
142
|
+
def self.update_rbenv_installation
|
143
|
+
puts "Updating rbenv ..."
|
144
|
+
if File.directory?("#{RBENV_INSTALL_TARGET}/.git")
|
145
|
+
# Perform the pull only if rbenv has been installed by using a git pull (and not through a package manager)
|
146
|
+
system("cd #{RBENV_INSTALL_TARGET}; git fetch -q; git checkout -q #{RBENV_GIT_REVISION}")
|
147
|
+
end
|
148
|
+
|
149
|
+
puts "Updating ruby-build ..."
|
150
|
+
if File.directory?("#{RUBYBUILD_TARGET}/.git")
|
151
|
+
# Perform the pull only if ruby-build has been installed by using a git pull (and not through a package manager)
|
152
|
+
# Before checking out the new branch, reset the repository to avoid conflicts
|
153
|
+
system("cd #{RUBYBUILD_TARGET}; git reset -q --hard; git fetch -q; git checkout -q #{RUBY_BUILD_GIT_REVISION}")
|
154
|
+
|
155
|
+
# Add our ree definition again because the repository has been reset
|
156
|
+
RubyConfigurator.add_custom_ree_definition
|
157
|
+
end
|
158
|
+
|
159
|
+
true
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
# Install rbenv
|
164
|
+
# 1. Fetch rbenv from repository and install it
|
165
|
+
# 2. Fetch ruby-build from repository and install it
|
166
|
+
# 3. Install custom ree installation definition into ruby-build so that our patched REE gets installed
|
167
|
+
#
|
168
|
+
# === Return
|
169
|
+
# true:: Always return true
|
170
|
+
def install_rbenv_from_git
|
171
|
+
|
172
|
+
# Require: git
|
173
|
+
res = Command.execute('git', '--version').success?
|
174
|
+
if !res
|
175
|
+
# Install git
|
176
|
+
opts = { :report => true, :post_install => update_msg }.merge(abort_option('Failed to install git, required for rbenv'))
|
177
|
+
PackageInstaller.install('git', opts)
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
# Fetch and install rbenv
|
182
|
+
# ***********************
|
183
|
+
|
184
|
+
# Fetch rbenv from git repo
|
185
|
+
Command.execute('git', 'clone', RBENV_GIT_REPO, RBENV_INSTALL_TARGET, {:abort_on_failure => 'Git clone of rbnev failed - server down?'})
|
186
|
+
Kernel.system("cd #{RBENV_INSTALL_TARGET}; git checkout #{RBENV_GIT_REVISION}")
|
187
|
+
|
188
|
+
# Fetch, install and patch ruby-build
|
189
|
+
# ***********************************
|
190
|
+
|
191
|
+
# Create plugins directory (target for ruby-build)
|
192
|
+
ret = FileUtils.mkdir_p(RUBYBUILD_TARGET)
|
193
|
+
if !ret
|
194
|
+
report_fatal("Could not create directory: #{RUBYBUILD_TARGET}");
|
195
|
+
end
|
196
|
+
|
197
|
+
Command.execute('git', 'clone', RUBYBUILD_GIT_REPO, RUBYBUILD_TARGET, {:abort_on_failure => 'Git clone of ruby-build failed - server down?'})
|
198
|
+
Kernel.system("cd #{RUBYBUILD_TARGET}; git checkout #{RUBY_BUILD_GIT_REVISION}")
|
199
|
+
|
200
|
+
RubyConfigurator.add_custom_ree_definition
|
201
|
+
end
|
202
|
+
|
112
203
|
# Check .ruby-version and its content
|
113
204
|
#
|
114
205
|
# === Return
|
@@ -190,9 +281,7 @@ module RightConf
|
|
190
281
|
def install_ruby_prerequisites_linux_ubuntu(ruby)
|
191
282
|
report_check("Installing required packages, this could take a while")
|
192
283
|
packages = []
|
193
|
-
|
194
|
-
packages = %w(build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev)
|
195
|
-
end # TBD Define packages needed for other rubies
|
284
|
+
packages = %w(build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev)
|
196
285
|
Command.sudo('apt-get', 'install', '-y', *packages)
|
197
286
|
report_success
|
198
287
|
end
|
data/lib/rconf/version.rb
CHANGED
@@ -46,7 +46,7 @@ describe RightConf::BundlerConfigurator do
|
|
46
46
|
{:abort_on_failure=>"Failed to install bundler"}).once.and_return(success_result)
|
47
47
|
should_execute('bundle','_0_', 'install',
|
48
48
|
{:abort_on_failure=>"Failed to install gems"}).once.and_return(success_result)
|
49
|
-
should_execute('rbenv', 'rehash').
|
49
|
+
should_execute('rbenv', 'rehash').times(2).and_return(success_result)
|
50
50
|
@configurator.run_linux
|
51
51
|
end
|
52
52
|
|
@@ -52,22 +52,27 @@ describe RightConf::RubyConfigurator do
|
|
52
52
|
|
53
53
|
context "without rbenv installed" do
|
54
54
|
before(:each) do
|
55
|
+
should_execute("git", "--version").once.and_return(success_result)
|
56
|
+
should_execute("git", "clone", "git://github.com/sstephenson/rbenv.git", "#{ENV['HOME']}/.rbenv", {:abort_on_failure=>"Git clone of rbnev failed - server down?"}).once.and_return(success_result)
|
57
|
+
should_execute("git", "clone", "git://github.com/sstephenson/ruby-build.git", "#{ENV['HOME']}/.rbenv/plugins/ruby-build", {:abort_on_failure=>"Git clone of ruby-build failed - server down?"}).once.and_return(success_result)
|
58
|
+
|
55
59
|
should_execute('rvm').once.and_return(failure_result)
|
56
60
|
should_execute('rbenv').once.and_return(failure_result)
|
57
61
|
flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.rbenv', 'bin', 'rbenv')).and_return(false)
|
62
|
+
|
63
|
+
flexmock(FileUtils).should_receive(:cp).with(/.*\/patches\/ree-1.8.7-2012.02-rs-custom/, "#{ENV['HOME']}/.rbenv/plugins/ruby-build/share/ruby-build/ree-1.8.7-2012.02").and_return(true)
|
64
|
+
flexmock(FileUtils).should_receive(:mkdir_p).with("#{ENV['HOME']}/.rbenv/plugins/ruby-build").and_return(true)
|
65
|
+
flexmock(Kernel).should_receive(:system).and_return(true)
|
58
66
|
should_execute('which', 'ruby').and_return(success_result(File.join(ENV['HOME'], '.rbenv', 'shims', 'ruby')))
|
59
67
|
end
|
60
68
|
|
61
69
|
it 'should install rbenv and ruby-build' do
|
62
|
-
flexmock(RightConf::PackageInstaller).should_receive(:install).with('rbenv', Hash).once
|
63
|
-
flexmock(RightConf::PackageInstaller).should_receive(:install).with('ruby-build', Hash).once
|
64
70
|
should_execute('rbenv', 'local', '42').and_return(success_result)
|
65
71
|
@configurator.run_linux
|
66
72
|
end
|
67
73
|
|
68
74
|
it 'should install ruby if needed' do
|
69
|
-
flexmock(RightConf::
|
70
|
-
flexmock(RightConf::PackageInstaller).should_receive(:install).with('ruby-build', Hash).once
|
75
|
+
flexmock(RightConf::Platform).should_receive(:dispatch).with(Proc)
|
71
76
|
should_execute('rbenv', 'local', '42').and_return(failure_result)
|
72
77
|
flexmock(RightConf::Platform).should_receive(:dispatch).with('42', Proc)
|
73
78
|
should_execute('rbenv', 'local', '42').and_return(success_result)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- Rakefile
|
74
74
|
- bin/rconf
|
75
75
|
- examples/sample.rconf
|
76
|
+
- lib/patches/ree-1.8.7-2012.02-rs-custom
|
76
77
|
- lib/rconf.rb
|
77
78
|
- lib/rconf/command.rb
|
78
79
|
- lib/rconf/configurator.rb
|