DevKit Chocolatey Install

288 views
Skip to first unread message

Fervent Coder

unread,
Jul 28, 2011, 4:06:32 PM7/28/11
to RubyInstaller, ferven...@gmail.com
I created a chocolatey install today for Ruby DevKit.

This will take your system from clean install to ruby, 7zip command
line, and DevKit in one line.

cinst ruby.devkit


Here is the package: http://nuget.org/List/Packages/ruby.devkit

More information about chocolatey: https://github.com/ferventcoder/chocolatey/wiki
How to install chocolatey: https://github.com/ferventcoder/chocolatey/wiki/Installation

For those curious, this is the contents of the installer:
https://github.com/ferventcoder/nugetpackages/blob/master/ruby.devkit/tools/chocolateyInstall.ps1
Please let me know if any of the powershell instructions needs
tweaking.

Jon

unread,
Jul 28, 2011, 4:23:29 PM7/28/11
to rubyin...@googlegroups.com

Whoa, at first glance this looks pretty cool, and the license is likable.

1) What are the client dependencies required to use? Just .NET 4.0, git on the cmd line? Anything else?

2) How do you handle DevKit upgrades? Specifically, how do you prevent blowing away tweaks to existing files and newly created files in the Devkit. I customize etc/profile and add a home/Jon/.bashrc file and would hate to have them clobbered.

3) If I change nothing in the DevKit build recipes, does it make it more difficult for you to maintain your chocolatey install? What upstream changes would make your maintenance and ongoing support easier? If they changes are minor and don't really impact the RubyInstaller project I'd like to make them.

Nice...hoping to take a deeper look a bit later.

Thanks for letting us know about this!

Jon

---
blog: http://jonforums.github.com/
twitter: @jonforums

"Anyone who can only think of one way to spell a word obviously lacks imagination." - Mark Twain

Jon

unread,
Jul 28, 2011, 4:27:27 PM7/28/11
to rubyin...@googlegroups.com
> > I created a chocolatey install today for Ruby DevKit.
> >
> > This will take your system from clean install to ruby, 7zip command
> > line, and DevKit in one line.
> >
> > cinst ruby.devkit
> >
> >
> > Here is the package: http://nuget.org/List/Packages/ruby.devkit
> >
> > More information about chocolatey: https://github.com/ferventcoder/chocolatey/wiki
> > How to install chocolatey: https://github.com/ferventcoder/chocolatey/wiki/Installation
> >
> > For those curious, this is the contents of the installer:
> > https://github.com/ferventcoder/nugetpackages/blob/master/ruby.devkit/tools/chocolateyInstall.ps1
> > Please let me know if any of the powershell instructions needs
> > tweaking.
>
> Whoa, at first glance this looks pretty cool, and the license is likable.
>
> 1) What are the client dependencies required to use? Just .NET 4.0, git on the cmd line? Anything else?
>
> 2) How do you handle DevKit upgrades? Specifically, how do you prevent blowing away tweaks to existing files and newly created files in the Devkit. I customize etc/profile and add a home/Jon/.bashrc file and would hate to have them clobbered.
>
> 3) If I change nothing in the DevKit build recipes, does it make it more difficult for you to maintain your chocolatey install? What upstream changes would make your maintenance and ongoing support easier? If they changes are minor and don't really impact the RubyInstaller project I'd like to make them.

One more...how would chocolatey support the different DevKit flavors I currently implement via the DKVER env var option when building similar to `rake devkit sfx=1 dkver=mingw64-34-4.5.4`?

Fervent Coder

unread,
Jul 28, 2011, 4:33:56 PM7/28/11
to RubyInstaller
1) PowerShell 2.0, .NET Framework 4.0. chocolatey executes from the
command line. The wiki is pretty comprehensive in explaining it all
https://github.com/ferventcoder/chocolatey/wiki
2) Take a look at the powershell script (https://github.com/
ferventcoder/nugetpackages/blob/master/ruby.devkit/tools/
chocolateyInstall.ps1) - it takes the instructions on the wiki and
makes them executable instructions. (the customized stuff is copied
off temporarily, then the archive is extracted, and it puts the
customized stuff back).


try {
$devKitInstallDir = "$env:SystemDrive\DevKit"
write-host "Chocolatey is installing DevKit to $devKitInstallDir"
write-host "Please wait..."
Start-sleep 3

if (![System.IO.Directory]::Exists($devKitInstallDir))
{[System.IO.Directory]::CreateDirectory($devKitInstallDir)}
$tempDir = "$env:TEMP\chocolatey\ruby.devkit"
if (![System.IO.Directory]::Exists($tempDir))
{[System.IO.Directory]::CreateDirectory($tempDir)}
$file = Join-Path $tempDir "ruby.devkitInstall.exe"
Get-ChocolateyWebFile 'ruby.devkit' "$file" 'http://github.com/
downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20110712-1620-
sfx.exe'

# Preparation
#If you previously installed the legacy DevKit
devkit-3.4.5r3-20091110.7z, its artifacts were extracted into each
Ruby installation and need to be manually removed. Remove the gcc.bat,
make.bat, and sh.bat stub batch files in <RUBY_INSTALL_DIR>\bin and
the <RUBY_INSTALL_DIR>\devkit subdirectory for each Ruby installation
using the legacy DevKit.
$pathItems = $env:Path
foreach($pathItem in $pathItems -split ";") {
if ($pathItem -ilike "*ruby*bin") {
Write-Host "Removing legacy install devkit items from $pathItem
if they exist"
if ([System.IO.File]::Exists("$($pathItem)\gcc.bat")) { Remove-
Item "$($pathItem)\gcc.bat" -force}
if ([System.IO.File]::Exists("$($pathItem)\make.bat")) { Remove-
Item "$($pathItem)\make.bat" -force}
if ([System.IO.File]::Exists("$($pathItem)\sh.bat")) { Remove-
Item "$($pathItem)\sh.bat" -force}
$oldDevKit = Join-Path (Split-Path -Parent $pathItem) 'devkit'
if ([System.IO.Directory]::Exists("$oldDevKit"))
{[System.IO.Directory]::Delete($oldDevKit,$true)}
}
}

# clean out the recommended directories
# 2. Delete all the <DEVKIT_INSTALL_DIR> subdirectories and files
except for config.yml. If you've made any customizations to the MSYS
shell you may also want to keep files in the etc and home
subdirectories.
if ([System.IO.File]::Exists("$($devKitInstallDir)\config.yml")) {
Write-Host "Moving config.yml to a holding location prior to
extraction"
Copy-Item "$($devKitInstallDir)\config.yml" "$tempDir" -Force
}

if ([System.IO.Directory]::Exists("$($devKitInstallDir)\etc")) {
Write-Host "Moving etc dir to a holding location prior to
extraction"
if (![System.IO.Directory]::Exists("$($tempDir)\etc"))
{[System.IO.Directory]::CreateDirectory("$($tempDir)\etc")}
Copy-Item "$($devKitInstallDir)\etc\*" "$($tempDir)\etc" -Force -
Recurse
}

if ([System.IO.Directory]::Exists("$($devKitInstallDir)\home")) {
Write-Host "Moving home dir to a holding location prior to
extraction"
if (![System.IO.Directory]::Exists("$($tempDir)\home"))
{[System.IO.Directory]::CreateDirectory("$($tempDir)\home")}
Copy-Item "$($devKitInstallDir)\home\*" "$($tempDir)\home" -Force -
Recurse
}

write-host "Cleaning out the contents of $devKitInstallDir"
start-sleep 1
Remove-Item "$($devKitInstallDir)\*" -recurse -force

# 3. Extract the new SFX DevKit into the same <DEVKIT_INSTALL_DIR>
that you just cleaned up.
write-host "Extracting the contents of $file to $devKitInstallDir"
start-sleep 3
#& 7za x -o"$devKitInstallDir" -y "$file"
Start-Process "7za" -ArgumentList "x -o`"$devKitInstallDir`" -y
`"$file`"" -Wait

if ([System.IO.File]::Exists("$($tempDir)\config.yml")) {
Write-Host "Moving config.yml back after extraction"
Copy-Item "$($tempDir)\config.yml" "$devKitInstallDir" -Force
}

if ([System.IO.Directory]::Exists("$($tempDir)\etc")) {
Write-Host "Moving etc dir back after extraction"
Copy-Item "$($tempDir)\etc\*" "$($devKitInstallDir)\etc" -Force -
Recurse
}

if ([System.IO.Directory]::Exists("$($tempDir)\home")) {
Write-Host "Moving home dir back after extraction"
Copy-Item "$($tempDir)\home\*" "$($devKitInstallDir)\home" -Force -
Recurse
}

# 4. Review your config.yml file to ensure it contains the root
directories of all the installed Rubies you want enhanced to use the
DevKit.
Write-Host "You may want to configure your config.yml after this
installation and rerun 'cinst ruby.devkit' if the defaults do not meet
your needs"
Start-Sleep 5
# 5. From a Command Prompt, cd into the <DEVKIT_INSTALL_DIR>
directory and run ruby dk.rb install --force. This will cause all your
installed Rubies listed in config.yml to use the updated SFX DevKit
when building native gems and update the DevKit's helper scripts
(devkit.rb and operating_system.rb) with any new functionality. For
safety, the original helper scripts are timestamp archived beside the
new helper scripts. It's always a good idea to review the two versions
(and potentially make modifications) to ensure configuration specific
to your system still works as expected.
Write-Host "Initializing and installing DevKit into Ruby."
cd $devKitInstallDir
& ruby dk.rb init
& ruby dk.rb install --force

start-sleep 3

Write-ChocolateySuccess 'ruby.devkit'
} catch {
Write-ChocolateyFailure 'ruby.devkit' "$($_.Exception.Message)"
throw
}


On Jul 28, 3:23 pm, Jon <jon.for...@gmail.com> wrote:
> > I created a chocolatey install today for Ruby DevKit.
>
> > This will take your system from clean install to ruby, 7zip command
> > line, and DevKit in one line.
>
> >     cinst ruby.devkit
>
> > Here is the package:http://nuget.org/List/Packages/ruby.devkit
>
> > More information about chocolatey:https://github.com/ferventcoder/chocolatey/wiki
> > How to install chocolatey:https://github.com/ferventcoder/chocolatey/wiki/Installation
>
> > For those curious, this is the contents of the installer:
> >https://github.com/ferventcoder/nugetpackages/blob/master/ruby.devkit...

Fervent Coder

unread,
Jul 28, 2011, 4:36:38 PM7/28/11
to RubyInstaller
3) chocolatey itself is taking your instructions for downloading and
installing and making them executable. As long as you continue to
provide the 7zip archive file, chocolatey will continue to work.

As you version devkit, new versions of the choco package will be
created with tweaked instructions.

On Jul 28, 3:23 pm, Jon <jon.for...@gmail.com> wrote:
> > I created a chocolatey install today for Ruby DevKit.
>
> > This will take your system from clean install to ruby, 7zip command
> > line, and DevKit in one line.
>
> >     cinst ruby.devkit
>
> > Here is the package:http://nuget.org/List/Packages/ruby.devkit
>
> > More information about chocolatey:https://github.com/ferventcoder/chocolatey/wiki
> > How to install chocolatey:https://github.com/ferventcoder/chocolatey/wiki/Installation
>
> > For those curious, this is the contents of the installer:
> >https://github.com/ferventcoder/nugetpackages/blob/master/ruby.devkit...

Fervent Coder

unread,
Jul 28, 2011, 4:45:02 PM7/28/11
to RubyInstaller
chocolatey technically could start at source and work from there...but
that could take quite awhile to do. It starts at the point of a
released version of a tool/application.

to do that you could create a package that takes a dependency on
msysgit and then run to build the application. You may want to look at
something like this: https://github.com/ferventcoder/chocolatey/wiki/DevelopmentEnvironmentSetup

Jon

unread,
Jul 28, 2011, 5:07:24 PM7/28/11
to rubyin...@googlegroups.com
> chocolatey technically could start at source and work from there...but
> that could take quite awhile to do. It starts at the point of a
> released version of a tool/application.

Makes sense. In this case source is really just binary downloads readily available. Basically the DevKit build recipe is an assembler/templater that does:

1) Download msys artifacts specified in

https://github.com/oneclick/rubyinstaller/blob/master/config/devkit.rb#L27-61

2) Download mingw artifacts specified by

https://github.com/oneclick/rubyinstaller/blob/master/config/devkit.rb#L11
https://github.com/oneclick/rubyinstaller/blob/master/config/compilers/tdm_mingw.rb

3) Create the ruby install script (ie `ruby dk.rb install`) from a template

https://github.com/oneclick/rubyinstaller/blob/master/recipes/devkit/devkit.rake#L8-22
https://github.com/oneclick/rubyinstaller/blob/master/resources/devkit/dk.rb.erb

4) Assemble the pieces and package as 7z and SFX


While the tweaker in me thinks it would be cool if chocolatey could do something similar and then download and install, I don't think it's needed for mainstream users. From a maintenance and support standpoint we only support the DevKit that's currently available for download http://rubyinstaller.org/downloads/ and I don't see this changing. Anyone wanting to hack with a different DevKit flavor should have no problem building it via `rake devkit 7z=1 dkver=????`

Looks great and I look forward to trying it out.

Reply all
Reply to author
Forward
0 new messages