Skip to content

Commit

Permalink
Add binary installation to bootstrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
jm committed Apr 16, 2012
1 parent a928d51 commit 1ea0eab
Show file tree
Hide file tree
Showing 6 changed files with 141 additions and 33 deletions.
Binary file not shown.
12 changes: 9 additions & 3 deletions Railcar/RCBootstrapper.rb
Expand Up @@ -4,11 +4,13 @@
class RCBootstrapper
attr_accessor :delegate

def installDependencies
def installDependencies(fromSource = true)
@fromSource = fromSource

puts("starting")
if needsInstall?
begin
checkForCompiler
checkForCompiler if buildFromSource?

if needsBrew?
installBrew
Expand Down Expand Up @@ -84,7 +86,7 @@ def installRuby(version = nil)
puts("installing ruby")

rubyInstaller = RCRubyManager.new
rubyInstaller.install(version || DEFAULT_RUBY_VERSION) ? delegate.rubyInstalled : raise("Ruby install failed!")
rubyInstaller.install((version || DEFAULT_RUBY_VERSION), buildFromSource?) ? delegate.rubyInstalled : raise("Ruby install failed!")
end

def installDefaultGems(version = nil)
Expand All @@ -99,4 +101,8 @@ def installDefaultGems(version = nil)
def needsInstall?
Dir.glob(File.join(NSBundle.mainBundle.bundlePath, "initializers", "rbenv_init_*.sh")).empty?
end

def buildFromSource?
@fromSource
end
end
36 changes: 34 additions & 2 deletions Railcar/RCRubyManager.rb
Expand Up @@ -6,6 +6,8 @@
# Copyright 2012 Arcturo. All rights reserved.
#

require 'fileutils'

class RCRubyManager
attr_accessor :delegate

Expand All @@ -18,7 +20,11 @@ def buildPath
end

def versionPath(version = nil)
File.join(NSBundle.mainBundle.bundlePath, "rbenv", "versions", (version || DEFAULT_RUBY_VERSION))
File.join(versionsPath, (version || DEFAULT_RUBY_VERSION))
end

def versionsPath
File.join(rbenvRoot, "versions")
end

def rbenvRoot
Expand All @@ -28,8 +34,34 @@ def rbenvRoot
def brewPath
File.join(NSBundle.mainBundle.bundlePath, "homebrew", "bin")
end

def install(version = nil, fromSource = true)
fromSource ? installFromSource : installBinary
end

def installBinary(version = nil)
FileUtils.mkdir_p(versionsPath)

Dir.chdir(versionsPath) do
`curl -o rubyBin.zip http://railcar.info/data/rubies/#{version || DEFAULT_RUBY_VERSION}.zip`
downloadSucceeded = ($?.exitstatus == 0)

`unzip rubyBin.zip`
unzipSucceeded = ($?.exitstatus == 0)

if downloadSucceeded && unzipSucceeded
writeShellInitializer(version)
delegate.newVersionInstalled(version || DEFAULT_RUBY_VERSION) if delegate

`rm rubyBin.zip`
else
delegate.rubyInstallError if delegate
return false
end
end
end

def install(version = nil)
def installFromSource(version = nil)
`CC='/usr/bin/gcc' #{buildPath} #{version || DEFAULT_RUBY_VERSION} #{versionPath(version)}`

if ($?.exitstatus == 0)
Expand Down
7 changes: 3 additions & 4 deletions Railcar/RCSetupWindowController.rb
@@ -1,6 +1,5 @@
class RCSetupWindowController < NSWindowController
attr_accessor :label, :errorLabel, :controlButton, :progressBar, :installer
attr_accessor :brewTitle, :brewInfo, :rbenvTitle, :rbenvInfo, :rubyTitle, :rubyInfo, :packagesTitle, :packagesInfo
attr_accessor :label, :errorLabel, :controlButton, :progressBar, :installer, :sourceCheckbox, :brewTitle, :brewInfo, :rbenvTitle, :rbenvInfo, :rubyTitle, :rubyInfo, :packagesTitle, :packagesInfo

def windowDidLoad
super
Expand Down Expand Up @@ -81,7 +80,6 @@ def noInstallNeeded
progressBar.setDoubleValue 100.0
progressBar.stopAnimation self

consoleButton.setEnabled true
controlButton.setEnabled false
end

Expand All @@ -93,9 +91,10 @@ def installEverything
fade(brewTitle, brewInfo, rbenvTitle, rbenvInfo, rubyTitle, rubyInfo, packagesTitle, packagesInfo)

controlButton.setEnabled false
sourceCheckbox.setEnabled false
progressBar.performSelectorOnMainThread("startAnimation:", withObject:self, waitUntilDone:false)

installer.performSelectorInBackground("installDependencies", withObject:nil)
installer.performSelectorInBackground("installDependencies", withObject:(sourceCheckbox.state == 1))
end

def fade(*controls)
Expand Down
20 changes: 9 additions & 11 deletions Railcar/RubyManagementWindow.xib
Expand Up @@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<string key="IBDocument.SystemVersion">11D50d</string>
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1938</string>
<string key="NS.object.0">2182</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -65,7 +65,6 @@
<string key="NSFrame">{{13, 10}, {704, 349}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="314901568"/>
<string key="NSReuseIdentifierKey">_NS:608</string>
<object class="NSMutableArray" key="NSTabViewItems">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -764,7 +763,6 @@
<string key="NSFrame">{{59, 40}, {457, 14}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:3944</string>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="974409936">
Expand Down Expand Up @@ -1441,7 +1439,7 @@
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down Expand Up @@ -1551,7 +1549,7 @@
<string>rbxButton</string>
<string>spinner</string>
</object>
<object class="NSMutableArray" key="dict.values">
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
Expand All @@ -1574,7 +1572,7 @@
<string>rbxButton</string>
<string>spinner</string>
</object>
<object class="NSMutableArray" key="dict.values">
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">jrubyButton</string>
Expand Down Expand Up @@ -1630,7 +1628,7 @@
<string>maglev</string>
<string>rbx</string>
</object>
<object class="NSMutableArray" key="dict.values">
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{198, 198}</string>
<string>{356.09889975826115, 95}</string>
Expand Down

0 comments on commit 1ea0eab

Please sign in to comment.