rconf 0.7.10 → 0.7.11
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/lib/rconf/configurator.rb +14 -10
- data/lib/rconf/configurators/build_configurator.rb +39 -14
- data/lib/rconf/language.rb +1 -1
- data/lib/rconf/support/environment_updater.rb +5 -1
- data/lib/rconf/version.rb +1 -1
- data/spec/configurator_spec.rb +2 -2
- data/spec/configurators/build_configurator_spec.rb +2 -1
- data/spec/configurators/ruby_configurator_spec.rb +1 -1
- metadata +2 -2
data/lib/rconf/configurator.rb
CHANGED
@@ -65,7 +65,8 @@ module RightConf
|
|
65
65
|
# === Return
|
66
66
|
# true:: Always return true
|
67
67
|
def settings(settings)
|
68
|
-
|
68
|
+
default_settings = { :only_if => 'Ruby code that should return true for configurator to proceed' }
|
69
|
+
@all_settings = settings.merge(default_settings)
|
69
70
|
true
|
70
71
|
end
|
71
72
|
|
@@ -97,7 +98,6 @@ module RightConf
|
|
97
98
|
# nil:: If settings are valid for this configurator
|
98
99
|
# error(String):: Error message otherwise
|
99
100
|
def validate
|
100
|
-
init
|
101
101
|
required = self.class.required_settings
|
102
102
|
return nil unless required
|
103
103
|
missing = required.flatten.select { |s| !@settings_values.include?(s) }
|
@@ -119,12 +119,14 @@ module RightConf
|
|
119
119
|
# === Return
|
120
120
|
# true:: Always return true
|
121
121
|
def run(*args)
|
122
|
-
|
123
|
-
sha = Profile.configurator_signature(
|
122
|
+
key = "#{self.class.key}-#{@index}"
|
123
|
+
sha = Profile.configurator_signature(key)
|
124
124
|
sig = signature
|
125
125
|
if sha != sig
|
126
|
-
|
127
|
-
|
126
|
+
if only_if.nil? || instance_eval(only_if)
|
127
|
+
Platform.dispatch(*args) { :run }
|
128
|
+
Profile.set_configurator_signature(key, sig)
|
129
|
+
end
|
128
130
|
end
|
129
131
|
true
|
130
132
|
end
|
@@ -157,7 +159,6 @@ module RightConf
|
|
157
159
|
# value:: Value of configuration option if there is one
|
158
160
|
# nil:: Otherwise
|
159
161
|
def [](config_option)
|
160
|
-
init
|
161
162
|
@settings_values[config_option]
|
162
163
|
end
|
163
164
|
|
@@ -173,7 +174,6 @@ module RightConf
|
|
173
174
|
# res(Object):: Configuration setting value or setter return value if
|
174
175
|
# arguments
|
175
176
|
def method_missing(meth, *args)
|
176
|
-
init
|
177
177
|
num_args = args.length
|
178
178
|
res = nil
|
179
179
|
if num_args > 0
|
@@ -189,11 +189,15 @@ module RightConf
|
|
189
189
|
res || @settings_values[meth]
|
190
190
|
end
|
191
191
|
|
192
|
-
# Initialize configuration settings hash
|
192
|
+
# Initialize configuration settings hash and index
|
193
|
+
#
|
194
|
+
# === Parameters
|
195
|
+
# index(Fixnum):: Unique index of configurators in rconf file
|
193
196
|
#
|
194
197
|
# === Return
|
195
198
|
# true:: Always return true
|
196
|
-
def
|
199
|
+
def initialize(index)
|
200
|
+
@index = index
|
197
201
|
@settings_values ||= Hash.new
|
198
202
|
true
|
199
203
|
end
|
@@ -20,11 +20,12 @@ module RightConf
|
|
20
20
|
description 'Builds a repository using the ./configure, make, make install commands'
|
21
21
|
|
22
22
|
settings :path => 'Path to source files',
|
23
|
+
:tarball_url => 'URL to source code tarball to be downloaded, supports .tgz and .zip',
|
24
|
+
:tarball_dir => 'Name of directory created when untaring tarball, required if "tarball_url" is set',
|
23
25
|
:pre_step => 'Command ran prior to ./configure',
|
24
26
|
:message => 'Progress message to display if any while building',
|
25
27
|
:configure_opts => 'Hash of options to be given to the configure script. ' +
|
26
|
-
'The keys are the platform families (:darwin, :linux or :windows)'
|
27
|
-
:only_if => 'Ruby code that should return true for build to proceed'
|
28
|
+
'The keys are the platform families (:darwin, :linux or :windows)'
|
28
29
|
|
29
30
|
validate_has_settings :path
|
30
31
|
|
@@ -33,22 +34,46 @@ module RightConf
|
|
33
34
|
# === Return
|
34
35
|
# true:: Always return true
|
35
36
|
def run_linux
|
36
|
-
if
|
37
|
-
|
38
|
-
|
37
|
+
if tarball_url && tarball_dir.nil?
|
38
|
+
report_fatal("tarball_url is specified (#{tarball_url.inspect}) but tarball_dir is missing")
|
39
|
+
end
|
40
|
+
report_check message if message
|
41
|
+
Command.execute('mkdir', '-p', path, :abort_on_failure => "Failed to create #{path}")
|
42
|
+
if tarball_url
|
39
43
|
Dir.chdir(path) do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
filename = File.basename(tarball_url)
|
45
|
+
unless File.exists?(File.join(Dir.pwd, filename))
|
46
|
+
Command.execute('curl', '-O', '-f', tarball_url, :abort_on_failure => "Failed to curl #{tarball_url}")
|
47
|
+
end
|
48
|
+
abf = { :abort_on_failure => "Failed to uncompress #{filename}" }
|
49
|
+
case filename
|
50
|
+
when /\.tar\.gz$|\.tgz$/ then
|
51
|
+
Command.execute('tar', '-xzvf', filename, abf)
|
52
|
+
when /\.zip$/ then
|
53
|
+
Command.execute('unzip', filename, abf)
|
54
|
+
when /\.gzip$/ then
|
55
|
+
Command.execute('gunzip', filename, abf)
|
56
|
+
else
|
57
|
+
report_fatal("Unknown file extension #{File.extname(filename)}")
|
58
|
+
end
|
59
|
+
path File.join(path, tarball_dir)
|
60
|
+
if !File.directory?(path)
|
61
|
+
report_fatal("Could not find tarball dir #{tarball_dir.inspect} after untaring #{filename}")
|
62
|
+
end
|
49
63
|
end
|
64
|
+
end
|
65
|
+
Dir.chdir(path) do
|
66
|
+
Command.execute(*command_args(pre_step)) if pre_step
|
67
|
+
opts = configure_opts && configure_opts[Platform.family]
|
68
|
+
Command.execute(*command_args("./configure #{opts}"))
|
69
|
+
Command.execute(*command_args('make'))
|
50
70
|
report_success
|
71
|
+
report("Please enter you password to run the install step")
|
72
|
+
Command.sudo('echo')
|
73
|
+
report_check 'Installing'
|
74
|
+
Command.sudo(*command_args('make install'))
|
51
75
|
end
|
76
|
+
report_success if message
|
52
77
|
true
|
53
78
|
end
|
54
79
|
alias :run_darwin :run_linux
|
data/lib/rconf/language.rb
CHANGED
@@ -77,7 +77,7 @@ module RightConf
|
|
77
77
|
if blk
|
78
78
|
klass = ConfiguratorRegistry[meth]
|
79
79
|
if klass
|
80
|
-
configurator = klass.new(
|
80
|
+
configurator = klass.new(@configurators.size)
|
81
81
|
configurator.instance_eval(&blk)
|
82
82
|
error = configurator.validate
|
83
83
|
@validation_errors << error if error
|
@@ -28,7 +28,11 @@ module RightConf
|
|
28
28
|
# true:: If bash resource or profile file was updated
|
29
29
|
# false:: Otherwise
|
30
30
|
def self.update(code, dependencies=[])
|
31
|
-
|
31
|
+
if Platform.darwin?
|
32
|
+
candidates = [ '.bash_profile' ]
|
33
|
+
else
|
34
|
+
candidates = ['.bash_profile', '.bashrc']
|
35
|
+
end
|
32
36
|
candidates.map! { |c| File.join(ENV['HOME'], c) }
|
33
37
|
bashrc_path = candidates.detect { |c| File.exist?(c) }
|
34
38
|
updated = false
|
data/lib/rconf/version.rb
CHANGED
data/spec/configurator_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe RightConf::Configurator do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
before(:each) do
|
35
|
-
@configurator = TestConfigurator.new
|
35
|
+
@configurator = TestConfigurator.new(1)
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should register configurators' do
|
@@ -67,7 +67,7 @@ describe RightConf::Configurator do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should skip configurators that have already run' do
|
70
|
-
flexmock(RightConf::Profile.instance).should_receive(:configurator_signature).with(
|
70
|
+
flexmock(RightConf::Profile.instance).should_receive(:configurator_signature).with('test-1').and_return('42')
|
71
71
|
flexmock(@configurator).should_receive(:signature).and_return('42')
|
72
72
|
flexmock(RightConf::Platform.instance).should_receive(:dispatch).never
|
73
73
|
@configurator.run
|
@@ -18,12 +18,13 @@ describe RightConf::BuildConfigurator do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should build' do
|
21
|
+
should_execute('mkdir', '-p', '../source', {:abort_on_failure=>"Failed to create ../source"}).once.ordered
|
21
22
|
flexmock(Dir).should_receive(:chdir).with('../source', Proc).once.and_yield
|
22
23
|
should_execute('./configure', {:abort_on_failure=>"Failed to run ./configure"}).once.ordered
|
23
24
|
should_execute('make', {:abort_on_failure=>"Failed to run make"}).once.ordered
|
24
25
|
should_sudo('echo').once.ordered
|
25
26
|
should_sudo('make', 'install', {:abort_on_failure=>"Failed to run make install"}).once.ordered
|
26
|
-
@configurator.
|
27
|
+
@configurator.run_linux
|
27
28
|
end
|
28
29
|
|
29
30
|
it 'should honor only_if' do
|
@@ -62,7 +62,7 @@ end
|
|
62
62
|
describe 'bashrc update' do
|
63
63
|
|
64
64
|
before(:each) do
|
65
|
-
flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.
|
65
|
+
flexmock(File).should_receive(:exist?).with(File.join(ENV['HOME'], '.bash_profile')).once.and_return(true)
|
66
66
|
flexmock(File).should_receive(:exist?).with('.rvmrc').and_return(true)
|
67
67
|
flexmock(FileUtils).should_receive(:mv).and_return(true)
|
68
68
|
f = flexmock('f')
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rconf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.11
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Raphael Simon
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-04-05 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|