rconf 0.8.21 → 0.8.29

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 CHANGED
@@ -33,6 +33,7 @@ where [options] are:
33
33
  EOS
34
34
 
35
35
  opt :configurators, 'Show available configurators'
36
+ opt :platform, 'Show current platform'
36
37
  opt :update, 'Update rconf to latest version'
37
38
  opt :remove, 'Remove rconf from all gemsets'
38
39
  opt :config, 'Set path to configuration file', :type => :string
@@ -59,6 +60,8 @@ where [options] are:
59
60
  Command.set_verbose if opts[:verbose]
60
61
  if opts[:configurators]
61
62
  new.list_configurators
63
+ elsif opts[:platform]
64
+ new.show_platform
62
65
  elsif opts[:update]
63
66
  new.update
64
67
  elsif opts[:remove]
@@ -93,6 +96,17 @@ where [options] are:
93
96
  end
94
97
  end
95
98
 
99
+ # Show current platform as detected by rconf
100
+ #
101
+ # === Return
102
+ # true:: Always return true
103
+ def show_platform
104
+ puts "rconf detected the following:\n\n"
105
+ puts "Family: #{Platform.family}"
106
+ puts "Flavor: #{Platform.flavor}"
107
+ puts "Release: #{Platform.release}"
108
+ end
109
+
96
110
  # Update rconf to latest in all installed rubies
97
111
  #
98
112
  # === Return
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -27,6 +27,11 @@ module RightConf
27
27
  # command(String):: Command to run
28
28
  # args(Array):: Command arguments
29
29
  #
30
+ # === Options
31
+ # abort_on_failure(bool):: Whether to raise an exception in case command
32
+ # returns an error (false by default)
33
+ # env:: Hash of environment variables keyed by name
34
+ #
30
35
  # === Return
31
36
  # result(CommandResult):: Result of execution (output and exit status)
32
37
  def execute(command, *args)
@@ -35,7 +40,7 @@ module RightConf
35
40
  opts = args[-1]
36
41
  args = args[0..-2]
37
42
  end
38
- res = Platform.dispatch(command, *args) { :execute }
43
+ res = Platform.dispatch(command, opts[:env], *args) { :execute }
39
44
  if @verbose
40
45
  msg = ([command] + args).compact.join(' ') + ' => ' +
41
46
  res.status.to_s + ': ' + res.output
@@ -53,6 +58,11 @@ module RightConf
53
58
  # command(String):: Command to run
54
59
  # args(Array):: Command arguments
55
60
  #
61
+ # === Options
62
+ # abort_on_failure(bool):: Whether to raise an exception in case command
63
+ # returns an error (false by default)
64
+ # env:: Hash of environment variables keyed by name
65
+ #
56
66
  # === Return
57
67
  # result(CommandResult):: Result of execution (output and exit status)
58
68
  # NOTE: This is the result returned by RVM, not the underlying command
@@ -85,12 +95,17 @@ module RightConf
85
95
  #
86
96
  # === Parameters
87
97
  # command(String):: Command name
98
+ # env(Hash):: Hash of environment variables keyed by name
88
99
  # params(Array):: List of parameters to pass to command
89
100
  #
90
101
  # === Return
91
102
  # result(CommandResult):: Result of execution (output and exit status)
92
- def execute_linux(command, *args)
103
+ def execute_linux(command, env, *args)
104
+ env ||= {}
105
+ old_envs = env.keys.inject({}) { |o, k| o[k] = ENV[k]; o }
106
+ env.each { |k, v| ENV[k] = v.to_s }
93
107
  out = `#{Shellwords.join([command, *args])} 2>&1`
108
+ old_envs.each { |k, v| ENV[k] = v }
94
109
  result = CommandResult.new(out, $?.exitstatus)
95
110
  end
96
111
  alias :execute_darwin :execute_linux
@@ -99,11 +114,12 @@ module RightConf
99
114
  #
100
115
  # === Parameters
101
116
  # command(String):: Command name
117
+ # env(Hash):: Hash of environment variables keyed by name
102
118
  # params(Array):: List of parameters to pass to command
103
119
  #
104
120
  # === Return
105
121
  # result(CommandResult):: Result of execution (output and exit status)
106
- def execute_windows(command, *args)
122
+ def execute_windows(command, env, *args)
107
123
  raise 'TBD!'
108
124
  end
109
125
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -136,7 +136,7 @@ module RightConf
136
136
  must_configure = (Profile.force_check? || sha != sig) && !check
137
137
  end
138
138
  Platform.dispatch(*args) { :run } if must_configure
139
- Profile.set_configurator_signature(key, sig)
139
+ Profile.set_configurator_signature(key, sig) unless aborting
140
140
  true
141
141
  end
142
142
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -14,7 +14,9 @@ module RightConf
14
14
  class MercurialConfigurator
15
15
 
16
16
  MAC_MERCURIAL_URL = 'http://mercurial.berkwood.com/binaries/Mercurial-1.8.1-py2.6-macosx10.6.zip'
17
+ MAC_10_7_MERCURIAL_URL = 'http://mercurial.berkwood.com/binaries/Mercurial-2.0.2-py2.7-macosx10.7.zip'
17
18
  MAC_MERCURIAL_FILE = 'mercurial-1.8.1_20110310-py2.6-macosx10.6'
19
+ MAC_10_7_MERCURIAL_FILE = 'mercurial-2.0.2_20120104-py2.7-macosx10.7'
18
20
 
19
21
  include Configurator
20
22
 
@@ -43,10 +45,8 @@ module RightConf
43
45
  # === Return
44
46
  # true:: Always return true
45
47
  def run_linux
46
- unless mercurial_installed
47
- opts = { :report => true }.merge(abort_option('Failed to install Mercurial'))
48
- PackageInstaller.install('mercurial', opts) { !mercurial_installed }
49
- end
48
+ opts = { :report => true }.merge(abort_option('Failed to install Mercurial'))
49
+ PackageInstaller.install('mercurial', opts)
50
50
  end
51
51
 
52
52
  # Brew does not have a package for mercurial :(
@@ -54,26 +54,54 @@ module RightConf
54
54
  # === Return
55
55
  # true:: Always return true
56
56
  def run_darwin
57
- unless mercurial_installed
58
- report_check('Installing Mercurial')
59
- tempdir = File.join(ENV['HOME'], '.rconf_temp')
60
- FileUtils.mkdir_p(tempdir)
61
- begin
62
- Dir.chdir(tempdir) do
63
- Command.execute('curl', '-O', '-f', MAC_MERCURIAL_URL,
64
- abort_option('Failed to download Mercurial'))
65
- Command.execute('unzip', File.basename(MAC_MERCURIAL_URL),
66
- abort_option('Failed to unzip Mercurial'))
67
- end
68
- Dir.chdir(File.join(tempdir, MAC_MERCURIAL_FILE)) do
69
- Command.sudo('installer', '-pkg', MAC_MERCURIAL_FILE.gsub('_', '+') + '.mpkg', '-target', '/',
70
- abort_option('Failed to install Mercurial'))
71
- end
72
- ensure
73
- FileUtils.rm_rf(tempdir)
57
+ report_check('Installing Mercurial')
58
+ tempdir = File.join(ENV['HOME'], '.rconf_temp')
59
+ FileUtils.mkdir_p(tempdir)
60
+ begin
61
+ Dir.chdir(tempdir) do
62
+ Command.execute('curl', '-O', '-f', mac_mercurial_url,
63
+ abort_option('Failed to download Mercurial'))
64
+ Command.execute('unzip', File.basename(mac_mercurial_url),
65
+ abort_option('Failed to unzip Mercurial'))
66
+ end
67
+ Dir.chdir(File.join(tempdir, mac_mercurial_file)) do
68
+ Command.sudo('installer', '-pkg', mac_mercurial_file.gsub('_', '+') + '.mpkg', '-target', '/',
69
+ abort_option('Failed to install Mercurial'))
74
70
  end
75
- report_success
71
+ ensure
72
+ FileUtils.rm_rf(tempdir)
76
73
  end
74
+ report_success
75
+ end
76
+
77
+ # URL to mercurial installer for Mac OS X
78
+ def mac_mercurial_url
79
+ Platform.dispatch { :mac_mercurial_url }
80
+ end
81
+
82
+ # URL to mercurial installer for Mac OS X < 10.7
83
+ def mac_mercurial_url_darwin
84
+ MAC_MERCURIAL_URL
85
+ end
86
+
87
+ # URL to mercurial installer for Mac OS X >= 10.7
88
+ def mac_mercurial_url_darwin_lion
89
+ MAC_10_7_MERCURIAL_URL
90
+ end
91
+
92
+ # File name of mercurial installer for Mac OS X
93
+ def mac_mercurial_file
94
+ Platform.dispatch { :mac_mercurial_file }
95
+ end
96
+
97
+ # File name of mercurial installer for Mac OS X < 10.7
98
+ def mac_mercurial_file_darwin
99
+ MAC_MERCURIAL_FILE
100
+ end
101
+
102
+ # File name of mercurial installer for Mac OS X >= 10.7
103
+ def mac_mercurial_file_darwin_lion
104
+ MAC_10_7_MERCURIAL_FILE
77
105
  end
78
106
 
79
107
  # Install Windows software
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -64,7 +64,7 @@ module RightConf
64
64
  when /is not installed\./
65
65
  report_failure
66
66
  report_fatal "Failed to install #{ruby}" if @tried
67
- install_ruby(version)
67
+ Platform.dispatch(version) { :install_ruby }
68
68
  @tried = true
69
69
  Command.execute_in_ruby('gem', 'install', 'rconf') unless gemset
70
70
  run
@@ -185,6 +185,30 @@ module RightConf
185
185
  true
186
186
  end
187
187
 
188
+ # Install given ruby version using rvm
189
+ # On Lion, need to setup CC env var before running rvm install
190
+ #
191
+ # === Parameters
192
+ # ruby(String):: Ruby version compatible with rvm
193
+ #
194
+ # === Return
195
+ # true:: Always return true
196
+ def install_ruby_darwin(ruby)
197
+ report_check("Installing #{ruby} (this will take a while, please be patient)")
198
+ xml = Command.execute('system_profiler', 'SPDeveloperToolsDataType', '-xml')
199
+ version = Command.execute('xpath', '"//*[text()=\'_items\']/following-sibling::array/dict/child::key[text()=\'spdevtools_version\']/following-sibling::string/text()"')
200
+ env = {}
201
+ if version =~ /^4\.2\./
202
+ if !File.executable?('/usr/bin/gcc-4.2')
203
+ report_fatal("The C compiler included with Xcode #{version} produces buggy ruby interpreters, please install the C compilers from https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg and re-run rconf")
204
+ else
205
+ env['CC'] = '/usr/bin/gcc-4.2'
206
+ end
207
+ end
208
+ Command.execute('rvm', 'install', ruby, :abort_on_failure => 'Failed to install ruby', :env => env)
209
+ report_success
210
+ end
211
+
188
212
  # Make sure to install all required linux packages first
189
213
  #
190
214
  # === Return
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -106,7 +106,8 @@ module RightConf
106
106
  def dispatch_candidates(prefix)
107
107
  candidates = ["#{prefix}_#{family}_#{flavor}_#{release}",
108
108
  "#{prefix}_#{family}_#{flavor}",
109
- "#{prefix}_#{family}"]
109
+ "#{prefix}_#{family}",
110
+ "#{prefix}"]
110
111
  candidates.map(&:to_sym)
111
112
  end
112
113
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -20,8 +20,22 @@ module RightConf
20
20
  def init
21
21
  @flavor = 'mac_os_x'
22
22
  @release = `sw_vers -productVersion`
23
+ distros.keys.each do |k|
24
+ if @release =~ /^10\.#{k}\.[0-9]+/
25
+ @flavor = distros[k]
26
+ return
27
+ end
28
+ end
23
29
  end
24
30
 
31
+ # Mac OS X distros used to setup 'flavor'
32
+ def distros
33
+ { 5 => 'leopard',
34
+ 6 => 'snow leopard',
35
+ 7 => 'lion' }
36
+ end
37
+
38
+
25
39
  end
26
40
 
27
41
  end
@@ -13,7 +13,7 @@ module RightConf
13
13
 
14
14
  MAJOR = 0
15
15
  MINOR = 8
16
- BUILD = 21
16
+ BUILD = 29
17
17
 
18
18
  VERSION = [MAJOR, MINOR, BUILD].map(&:to_s).join('.')
19
19
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -22,16 +22,23 @@ describe RightConf::Command do
22
22
  end
23
23
 
24
24
  it 'should execute' do
25
- flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', '42', Proc).once.and_return(success_result)
25
+ flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', nil, '42', Proc).once.and_return(success_result)
26
26
  RightConf::Command.execute('test', '42')
27
27
  end
28
28
 
29
29
  it 'should report fatal errors when required to' do
30
- flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', '42',
30
+ flexmock(RightConf::Platform.instance).should_receive(:dispatch).with('test', nil, '42',
31
31
  Proc).once.and_return(failed_result)
32
32
  flexmock(RightConf::Command.instance).should_receive(:report_fatal).once.with("FAILED: 'test 42' returned\n1")
33
33
  RightConf::Command.execute('test', '42', :abort_on_failure => 'FAILED')
34
34
  end
35
+
36
+ it 'should setup environment variables' do
37
+ ENV['THIS_IS_A_TEST_ENV_VALUE'].should be_nil
38
+ res = RightConf::Command.execute('env', :env => { 'THIS_IS_A_TEST_ENV_VALUE' => '42' })
39
+ ENV['THIS_IS_A_TEST_ENV_VALUE'].should be_nil
40
+ res.output.should =~ /^THIS_IS_A_TEST_ENV_VALUE=42$/
41
+ end
35
42
 
36
43
  end
37
44
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -13,20 +13,20 @@ require File.join(File.dirname(__FILE__), 'spec_helper')
13
13
 
14
14
  describe RightConf::Platform do
15
15
 
16
- it 'should try to dispatch using platform family' do
16
+ it 'should try to dispatch using platform family' do
17
17
  def test_amiga(val); val; end
18
18
  flexmock(RightConf::Platform.instance).should_receive(:family).and_return('amiga')
19
19
  RightConf::Platform.dispatch(44) { :test }.should == 44
20
20
  end
21
21
 
22
- it 'should try to dispatch using platform family and flavor' do
22
+ it 'should try to dispatch using platform family and flavor' do
23
23
  def test_atari_st(val); val; end
24
24
  flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('st')
25
25
  flexmock(RightConf::Platform.instance).should_receive(:family).and_return('atari')
26
26
  RightConf::Platform.dispatch(43) { :test }.should == 43
27
27
  end
28
28
 
29
- it 'should try to dispatch using platform family, flavor and release' do
29
+ it 'should try to dispatch using platform family, flavor and release' do
30
30
  def test_commodore_c_64(val); val; end
31
31
  flexmock(RightConf::Platform.instance).should_receive(:release).and_return('64')
32
32
  flexmock(RightConf::Platform.instance).should_receive(:flavor).and_return('c')
@@ -34,4 +34,10 @@ it 'should try to dispatch using platform family, flavor and release' do
34
34
  RightConf::Platform.dispatch(42) { :test }.should == 42
35
35
  end
36
36
 
37
+ it 'should default to no suffix' do
38
+ def test(val); val; end
39
+ flexmock(RightConf::Platform.instance).should_receive(:family).and_return('non-existent')
40
+ RightConf::Platform.dispatch(41) { :test }.should == 41
41
+ end
42
+
37
43
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2011 RightScale, Inc, All Rights Reserved Worldwide.
1
+ # Copyright (C) 2011-2012 RightScale, Inc, All Rights Reserved Worldwide.
2
2
  #
3
3
  # THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE
4
4
  # AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use,
@@ -20,14 +20,18 @@ describe RightConf::Profile do
20
20
 
21
21
  it 'should reset when forcing checks' do
22
22
  flexmock(RightConf::Profile.instance).should_receive(:reset).once
23
+ old_check = RightConf::Profile.instance.instance_variable_get(:@force_check)
23
24
  RightConf::Profile.force_check
24
25
  RightConf::Profile.force_check?.should be_true
26
+ RightConf::Profile.instance.instance_variable_set(:@force_check, old_check)
25
27
  end
26
28
 
27
29
  it 'should reset when forcing re-configuration' do
28
30
  flexmock(RightConf::Profile.instance).should_receive(:reset).once
31
+ old_reconfigure = RightConf::Profile.instance.instance_variable_get(:@force_reconfigure)
29
32
  RightConf::Profile.force_reconfigure
30
33
  RightConf::Profile.force_reconfigure?.should be_true
34
+ RightConf::Profile.instance.instance_variable_set(:@force_reconfigure, old_reconfigure)
31
35
  end
32
36
 
33
37
  end
metadata CHANGED
@@ -5,8 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 8
8
- - 21
9
- version: 0.8.21
8
+ - 29
9
+ segments_generated: true
10
+ version: 0.8.29
10
11
  platform: ruby
11
12
  authors:
12
13
  - Raphael Simon
@@ -14,37 +15,37 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2012-01-09 00:00:00 -08:00
18
+ date: 2012-01-29 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
23
  requirements:
26
24
  - - ~>
27
25
  - !ruby/object:Gem::Version
28
26
  segments:
29
27
  - 2
30
28
  - 5
29
+ segments_generated: true
31
30
  version: "2.5"
31
+ requirement: *id001
32
+ name: rspec
33
+ prerelease: false
32
34
  type: :development
33
- version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency
35
- name: flexmock
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
37
  requirements:
40
38
  - - ~>
41
39
  - !ruby/object:Gem::Version
42
40
  segments:
43
41
  - 0
44
42
  - 9
43
+ segments_generated: true
45
44
  version: "0.9"
45
+ requirement: *id002
46
+ name: flexmock
47
+ prerelease: false
46
48
  type: :development
47
- version_requirements: *id002
48
49
  description: |
49
50
  rconf configures the environment for a given application. rconf reads
50
51
  the content of an application configuration file and installs and/or
@@ -127,25 +128,25 @@ rdoc_options: []
127
128
  require_paths:
128
129
  - lib
129
130
  required_ruby_version: !ruby/object:Gem::Requirement
130
- none: false
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  segments:
135
135
  - 0
136
+ segments_generated: true
136
137
  version: "0"
137
138
  required_rubygems_version: !ruby/object:Gem::Requirement
138
- none: false
139
139
  requirements:
140
140
  - - ">="
141
141
  - !ruby/object:Gem::Version
142
142
  segments:
143
143
  - 0
144
+ segments_generated: true
144
145
  version: "0"
145
146
  requirements: []
146
147
 
147
148
  rubyforge_project: rconf
148
- rubygems_version: 1.3.7
149
+ rubygems_version: 1.3.6
149
150
  signing_key:
150
151
  specification_version: 3
151
152
  summary: Cross platform environment configuration