[DRE-commits] [ruby-build] 01/10: Imported Upstream version 20140224.1
Sebastian Boehm
sometimesfood-guest at moszumanska.debian.org
Mon Feb 24 19:44:25 UTC 2014
This is an automated email from the git hooks/post-receive script.
sometimesfood-guest pushed a commit to branch master
in repository ruby-build.
commit a4041f67a72f132203a07d2df57b0af2361de76c
Author: Sebastian Boehm <sebastian at sometimesfood.org>
Date: Mon Feb 24 19:59:16 2014 +0100
Imported Upstream version 20140224.1
---
.travis.yml | 11 +
CHANGELOG.md | 373 ++++++++++++++-------
LICENSE | 33 +-
README.md | 273 ++++++++--------
bin/rbenv-install | 65 +++-
bin/rbenv-uninstall | 24 +-
bin/ruby-build | 352 +++++++++++++++++---
install.sh | 19 +-
script/mirror | 87 +++++
script/s3-put | 63 ++++
script/test | 13 +
share/ruby-build/1.8.6-p383 | 2 +-
share/ruby-build/1.8.6-p420 | 2 +-
share/ruby-build/1.8.7-p249 | 2 +-
share/ruby-build/1.8.7-p302 | 2 +-
share/ruby-build/1.8.7-p334 | 2 +-
share/ruby-build/1.8.7-p352 | 2 +-
share/ruby-build/1.8.7-p357 | 2 +-
share/ruby-build/1.8.7-p358 | 2 +-
share/ruby-build/1.8.7-p370 | 2 +-
share/ruby-build/1.8.7-p371 | 2 +-
share/ruby-build/1.8.7-p374 | 3 +
share/ruby-build/{1.8.7-p334 => 1.8.7-p375} | 2 +-
share/ruby-build/1.9.1-p378 | 4 +-
share/ruby-build/1.9.1-p430 | 4 +
share/ruby-build/1.9.2-p0 | 4 +
share/ruby-build/1.9.2-p180 | 4 +-
share/ruby-build/1.9.2-p290 | 4 +-
share/ruby-build/1.9.2-p318 | 4 +-
share/ruby-build/1.9.2-p320 | 4 +-
share/ruby-build/1.9.2-p326 | 4 +
share/ruby-build/1.9.3-dev | 2 +-
share/ruby-build/1.9.3-p0 | 4 +-
share/ruby-build/1.9.3-p125 | 4 +-
share/ruby-build/1.9.3-p194 | 4 +-
share/ruby-build/1.9.3-p286 | 4 +-
share/ruby-build/1.9.3-p327 | 4 +-
share/ruby-build/1.9.3-p362 | 4 +-
share/ruby-build/1.9.3-p374 | 4 +-
share/ruby-build/1.9.3-p385 | 4 +-
share/ruby-build/1.9.3-p392 | 4 +-
share/ruby-build/1.9.3-p429 | 2 +
share/ruby-build/1.9.3-p448 | 2 +
share/ruby-build/1.9.3-p484 | 2 +
share/ruby-build/1.9.3-p545 | 2 +
share/ruby-build/1.9.3-preview1 | 4 +-
share/ruby-build/1.9.3-rc1 | 4 +-
share/ruby-build/2.0.0-p0 | 3 +-
share/ruby-build/2.0.0-p195 | 3 +
share/ruby-build/2.0.0-p247 | 3 +
share/ruby-build/2.0.0-p353 | 3 +
share/ruby-build/{2.0.0-p0 => 2.0.0-p451} | 2 +-
share/ruby-build/2.0.0-preview1 | 4 +-
share/ruby-build/2.0.0-preview2 | 3 +-
share/ruby-build/2.0.0-rc1 | 3 +-
share/ruby-build/2.0.0-rc2 | 3 +-
share/ruby-build/2.1.0 | 3 +
share/ruby-build/2.1.0-dev | 2 +-
share/ruby-build/2.1.0-preview1 | 3 +
share/ruby-build/2.1.0-preview2 | 3 +
share/ruby-build/2.1.0-rc1 | 3 +
share/ruby-build/{2.0.0-p0 => 2.1.1} | 2 +-
share/ruby-build/{2.1.0-dev => 2.2.0-dev} | 2 +-
share/ruby-build/jruby-1.7.10 | 1 +
share/ruby-build/jruby-1.7.4 | 1 +
share/ruby-build/jruby-1.7.5 | 1 +
share/ruby-build/jruby-1.7.6 | 1 +
share/ruby-build/jruby-1.7.7 | 1 +
share/ruby-build/jruby-1.7.8 | 1 +
share/ruby-build/jruby-1.7.9 | 1 +
share/ruby-build/jruby-9000-dev | 2 +
share/ruby-build/maglev-2.0.0-dev | 1 +
share/ruby-build/mruby-1.0.0 | 1 +
share/ruby-build/mruby-dev | 1 +
share/ruby-build/rbx-2.0.0 | 2 +
share/ruby-build/rbx-2.0.0-dev | 2 +-
share/ruby-build/rbx-2.0.0-rc1 | 2 +-
share/ruby-build/rbx-2.1.0 | 2 +
share/ruby-build/rbx-2.1.1 | 2 +
share/ruby-build/rbx-2.2.0 | 2 +
share/ruby-build/rbx-2.2.1 | 2 +
share/ruby-build/rbx-2.2.2 | 2 +
share/ruby-build/rbx-2.2.3 | 2 +
share/ruby-build/rbx-2.2.4 | 2 +
share/ruby-build/rbx-2.2.5 | 2 +
share/ruby-build/topaz-dev | 1 +
test/build.bats | 482 ++++++++++++++++++++++++++++
test/cache.bats | 7 +-
test/checksum.bats | 10 +-
test/fetch.bats | 14 +
test/fixtures/definitions/needs-yaml | 2 +
test/fixtures/definitions/vanilla-ruby | 1 +
test/hooks.bats | 56 ++++
test/installer.bats | 61 ++++
test/mirror.bats | 21 +-
test/stubs/curl/curl | 1 -
test/stubs/md5/md5 | 1 -
test/stubs/stub | 14 +-
test/test_helper.bash | 104 +++++-
99 files changed, 1853 insertions(+), 425 deletions(-)
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7deab45
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+install: git clone https://github.com/sstephenson/bats.git
+script: script/test
+language: c
+notifications:
+ email:
+ on_success: never
+env:
+ global:
+ - AMAZON_S3_BUCKET=ruby-build-mirror
+ - AMAZON_ACCESS_KEY_ID=AKIAJKAUQVHU6X4CODDQ
+ - secure: LTSvDP2o72nbECDwWsfwnsiETF4VpqrYN3y/ve68AZIMzfNWDB5vhqzMLU1ltFnSNxd71gTCGX2OEcsxdrfnG+Msu52v8FtJ7lz/b9xn83gGYrGnmEMzARtd1fnuzlWQh/1eNL9jrNl8FDhgjoTqKl2gF6fZBsQxcHRnvRSXcqE=
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 740f38a..972561d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,209 +1,348 @@
## Version History
+#### 20140224.1
+* Add Ruby 2.0.0-p451
+* Add Ruby 2.1.1
+
+#### 20140224
+* Add Ruby 1.9.3-p545
+* Add mruby 1.0.0
+* Improve Java 7 detection
+
+#### 20140214
+* Install libyaml 0.1.5 for Ruby 2.x
+* Require Java 7 for jruby-9000-dev
+* Update MagLev branch from master-1.9 to master
+
+#### 20140210
+* Add Rubinius 2.2.4
+* Add JRuby 9000-dev
+
+#### 20140204
+* Add Rubinius 2.2.4
+* Update libyaml to version 0.1.5
+
+Note: If Psych::LIBYAML_VERSION < '0.1.5' you should update and rebuild Ruby.
+For more informaton see CVE-2013-6393.
+
+#### 20140110.1
+* Fix bug in JRuby 1.7.10 definition
+
+#### 20140110
+* Add JRuby 1.7.10
+* Add Rubinius 2.2.2
+* Add Rubinius 2.2.3
+
+#### 20131225.1
+* Fix typos in Ruby 2.1.0, 2.1.0-dev, and 2.2.0-dev definitions
+
+#### 20131225
+* Add Ruby 1.8.7-p375
+* Add Ruby 1.9.2-p326
+* Update Ruby 2.1.0-dev git branch
+* Add Ruby 2.1.0
+* Add Ruby 2.2.0-dev
+
+#### 20131220.1
+* Fix JRuby installation on non-BSD systems
+
+#### 20131220
+* Transform JRuby shebangs to absolute paths, fixing edge-case recursion in rbenv
+* Add `--patch` command-line option to patch Ruby from stdin before building
+* Add Ruby 2.1.0-rc1
+
+#### 20131211
+* Fix extracting topaz-dev archive
+* Auto-detect and link to Homebrew's readline
+* Fix irb, rake, rdoc, ri for rbx-2.2.1
+
+#### 20131206
+* Add JRuby 1.7.9
+
+#### 20131122.1
+* Fix typo in 2.1.0-preview2 definition
+
+#### 20131122
+* Add Ruby 1.9.3-p484
+* Add Ruby 2.0.0-p353
+* Add Ruby 2.1.0-preview2
+* Add Rubinius 2.2.0
+* Add Rubinius 2.2.1
+
+#### 20131115
+* Add JRuby 1.7.7
+* Add JRuby 1.7.8
+
+#### 20131030
+* Install the Rubinius bundle in isolation
+* Fix false "BUILD FAILED" message when installing Rubinius
+* Fix installing REE on OS X 10.8+ with no XQuartz
+
+#### 20131028
+* Abort early for invalid TMPDIR
+* Enable compiling Ruby 1.8 on OS X 10.8+ without extra flags
+* Detect number of CPU cores used for `make`
+* Fix installing Ruby 2.1.0 from trunk
+* Install Rake and Bundler in isolation when required
+* Clearer error message when HTTP download fails
+* Set default MAKE=gmake on FreeBSD
+* Support relative path as install prefix
+* Use libyaml from Homebrew if available
+
+#### 20131024
+* Add JRuby 1.7.6
+* Add Rubinius 2.1.0
+* Add Rubinius 2.1.1
+
+#### 20131008
+* Add JRuby 1.7.5
+* Add Rubinius 2.0.0
+
+#### 20130923
+* Add Ruby 2.1.0-preview1
+
+#### 20130907
+* Revert using mirror site
+
+#### 20130901
+* Use www.dnsbalance.ring.gr.jp
+* Do not set the Rubinius gems directory to the prefix
+
+#### 20130806
+* Change protocol of the ruby-lang.org server from HTTP to FTP
+
+#### 20130628
+* Add Ruby 2.0.0-p247
+* Add Ruby 1.9.3-p448
+* Add Ruby 1.8.7-p374
+* Add MagLev 2.0.0-dev from git
+* Use Homebrew openssl if available
+
+#### 20130518
+* Add JRuby 1.7.4
+
+#### 20130514
+* Add Ruby 2.0.0-p195
+* Add Ruby 1.9.3-p429
+* Add Ruby 1.9.2-p0
+* Add Ruby 1.9.1-p430
+
+#### 20130501
+* Cache git clone directory
+* Restore -O3 default when building with clang
+* Build REE --without-tk on Darwin if X11 is missing
+* Pass $RUBY_CONFIGURE_OPTS to REE installer with -c
+* Default RBENV_VERSION to the globally-specified Ruby
+
+#### 20130408
+* Add mruby-dev
+* Add topaz-dev :gem:
+* List matching definitions on ambiguous version specification
+* Use `--continue` when downloading tarball
+* Keep source tarball if `--keep` or `tar xf` fails
+
#### 20130227
-* Default Ruby CFLAGS to `-Wno-error=shorten-64-to-32`; don't set `CC
+* Default Ruby CFLAGS to `-Wno-error=shorten-64-to-32`; don't set `CC`
* Upgrades rubygems for 1.9.1: 1.3.5 -> 1.3.7
#### 20130226
* Build a shared openssl to link to Ruby 2.0.0
#### 20130225
-* Added a definition for 2.1.0-dev
+* Add Ruby 2.1.0-dev
* Rename the CAfile to cert.pem
* Fix exit status of install with verbose
#### 20130224
-* Added a definition for 2.0.0-p0 (Happy 20th Birthday, Ruby! :birthday:)
+* Happy 20th :birthday:, Ruby!
+* Add Ruby 2.0.0-p0
* Autoclean on unsuccessful installation
#### 20130222
-* Upgraded to OpenSSL 1.0.1e
-* Added a definition for JRuby 1.7.3
-* Added a definition for 1.9.3-p392
+* Upgrade to OpenSSL 1.0.1e
+* Add JRuby 1.7.3
+* Add Ruby 1.9.3-p392
#### 20130208
-* Added a definition for 2.0.0-rc2
+* Add Ruby 2.0.0-rc2
* Build OpenSSL for Ruby 2.0 on OS X
#### 20130206
-* Added a definition for 1.9.3-p385
+* Add Ruby 1.9.3-p385
#### 20130129
-* Changed `rbenv install` to attempt to install the local app-specific
- version when it is invoked without any arguments.
-* Added interactive confirmation to `rbenv install` when the
- destination prefix exists. Pass `-f` or `--force` to force
- installation of versions that are already installed.
-* Added support for specifying which program to use for `make` via the
- `$MAKE` environment variable. FreeBSD users can now instruct
- ruby-build to use GNU make by setting `MAKE=gmake`.
-* Modified the post-install process to invoke `chmod` only for group-
- or world-writable directories.
-* Added `before_install` and `after_install` hooks for `rbenv install`
- plugins to facilitate post-installation automation.
+* Change `rbenv install` to attempt to install the local app-specific
+ version when it is invoked without any arguments
+* Add interactive confirmation to `rbenv install` when the destination prefix
+ exists. Pass `-f` or `--force` to force installation of versions that are
+ already installed
+* Add support for specifying which program to use for `make` via the `$MAKE`
+ environment variable. FreeBSD users can now instruct ruby-build to use GNU
+ make by setting `MAKE=gmake`
+* Modify the post-install process to invoke `chmod` only for group- or
+ world-writable directories
+* Add `before_install` and `after_install` hooks for `rbenv install` plugins to
+ facilitate post-installation automation
#### 20130118
-* Added a definition for 2.0.0-rc1
-* Added a definition for 1.9.3-p374
+* Add Ruby 2.0.0-rc1
+* Add Ruby 1.9.3-p374
#### 20130104
-* Added a definition for JRuby 1.7.2
+* Add JRuby 1.7.2
#### 20121227
-* Added a definition for Ruby 1.9.3-p362
-* Added a definition for Ruby 1.8.7-p371
-* Moved the default ruby-build mirror from GitHub Downloads to Amazon
- CloudFront.
+* Add Ruby 1.9.3-p362
+* Add Ruby 1.8.7-p371
+* Move the default ruby-build mirror from GitHub Downloads to Amazon CloudFront
#### 20121204
-* Added a definition for JRuby 1.7.1
+* Add JRuby 1.7.1
#### 20121201
-* Added a definition for Ruby 2.0.0-preview2
+* Add Ruby 2.0.0-preview2
#### 20121120
-* Added optional package checksum support. When a package URL is
- annotated with an MD5 checksum, ruby-build will use it to verify
- the contents of the downloaded file. Package URLs in all existing
- definitions have been updated with checksum annotations.
-* Added an optional package download cache. When the
- `RUBY_BUILD_CACHE_PATH` environment variable is set to a directory
- of your choice, ruby-build will store downloaded packages there and
- reuse them for future installations.
-* Added mirror support for faster package downloads. Packages on the
- official ruby-build mirror will be served via S3. You can point
- ruby-build to your own local package mirror by setting the
- `RUBY_BUILD_MIRROR_URL` environment variable.
+* Add optional package checksum support. When a package URL is annotated with
+ an MD5 checksum, ruby-build will use it to verify the contents of the
+ downloaded file. Package URLs in all existing definitions have been updated
+ with checksum annotations
+* Add an optional package download cache. When the `RUBY_BUILD_CACHE_PATH`
+ environment variable is set to a directory of your choice, ruby-build will
+ store downloaded packages there and reuse them for future installations
+* Add mirror support for faster package downloads. Packages on the official
+ ruby-build mirror will be served via S3. You can point ruby-build to your own
+ local package mirror by setting the `RUBY_BUILD_MIRROR_URL` environment
+ variable
#### 20121110
-* Added a definition for Ruby 1.9.3-p327
+* Add Ruby 1.9.3-p327
* Fetch Ruby 2.0.0.dev and 1.9.3.dev via Git instead of Subversion
#### 20121104
-* Added a definition for Ruby 2.0.0-preview1
-* Added a definition for Rubinius 2.0.0-rc1
+* Add Ruby 2.0.0-preview1
+* Add Rubinius 2.0.0-rc1
#### 20121022
-* Added a definition for JRuby 1.7.0
+* Add JRuby 1.7.0
#### 20121020
-* Added a definition for Ruby 1.9.3-p286
-* Added a definition for JRuby 1.7.0-rc2
-* Added a definition for JRuby 1.7.0-rc1
-* Added a definition for JRuby 1.6.8
-* Added a definition for JRuby 1.5.6
+* Add Ruby 1.9.3-p286
+* Add JRuby 1.7.0-rc2
+* Add JRuby 1.7.0-rc1
+* Add JRuby 1.6.8
+* Add JRuby 1.5.6
* Fetch Ruby 2.0.0.dev via Subversion instead of Git
* Allow hooks to be defined for `rbenv-install`
#### 20120815
-* Added a definition for MagLev 1.1.0-dev from git.
-* Added a definition for Ruby 1.8.7-p370. (For those having trouble
+* Add MagLev 1.1.0-dev from git
+* Add Ruby 1.8.7-p370 (for those having trouble
installing 1.8.7 with newer versions of glibc, please see
- https://github.com/sstephenson/ruby-build/pull/195#issuecomment-7743664.)
-* Updated the package URL in the definition for JRuby 1.7.0-preview1.
-* Added a definition for JRuby 1.7.0-preview2.
-* Updated the Rubinius 2.0.0-dev definition to use the bundled
- RubyGems version instead of installing its own.
-* Added an `rbenv uninstall` command for removing installed versions.
+ https://github.com/sstephenson/ruby-build/pull/195#issuecomment-7743664)
+* Update the package URL in the definition for JRuby 1.7.0-preview1
+* Add JRuby 1.7.0-preview2
+* Update the Rubinius 2.0.0-dev definition to use the bundled RubyGems version
+ instead of installing its own
+* Add an `rbenv uninstall` command for removing installed versions
* Improved the option parsing for `ruby-build` and `rbenv-install` so
options may be placed in any order, and short options may be
- combined (e.g. `-kv`).
-* Added a `-l`/`--list` option to `rbenv install` to list all
- available definitions.
-* Added a `-v`/`--verbose` option to `rbenv install` to invoke
- `ruby-build` in verbose mode.
+ combined (e.g. `-kv`)
+* Add a `-l`/`--list` option to `rbenv install` to list all available
+ definitions
+* Add a `-v`/`--verbose` option to `rbenv install` to invoke `ruby-build` in
+ verbose mode
* Documented the `-k`/`--keep` flag in the command-line help for
- `ruby-build` and `rbenv install`.
+ `ruby-build` and `rbenv install`
#### 20120524
-* Added definitions for JRuby 1.6.7.2 and 1.7.0-preview1.
-* Removed the definition for JRuby 1.7.0-dev. (In general we do not
+* Add JRuby 1.6.7.2 and 1.7.0-preview1
+* Removed the definition for JRuby 1.7.0-dev (in general we do not
like to remove definitions, but the JRuby team has deleted the
- 1.7.0-dev package from their servers -- caveat emptor.)
+ 1.7.0-dev package from their servers -- caveat emptor)
* Added support for specifying the build location with the
- `RUBY_BUILD_BUILD_PATH` environment variable.
-* Added a `-k`/`--keep` flag to `ruby-build` and `rbenv install` for
- keeping the source code around after installation.
-* Updated the readme to emphasize installation as an rbenv plugin.
+ `RUBY_BUILD_BUILD_PATH` environment variable
+* Add a `-k`/`--keep` flag to `ruby-build` and `rbenv install` for
+ keeping the source code around after installation
+* Update the README to emphasize installation as an rbenv plugin
#### 20120423
-* Improved error messages when dependencies are missing.
-* XCode 4.3+ may be used to build 1.9.3-p125 and later.
-* Updated all Ruby 1.9.2 and 1.9.3 definitions to RubyGems 1.8.23.
-* Added definitions for REE 1.8.7-2012.02 and 1.8.7-2009.10.
-* Added definitions for JRuby 1.6.7.
-* Added definitions for Ruby 1.9.2-p318, 1.9.2-p320, and 1.9.3-p194.
+* Improved error messages when dependencies are missing
+* XCode 4.3+ may be used to build 1.9.3-p125 and later
+* Update all Ruby 1.9.2 and 1.9.3 definitions to RubyGems 1.8.23
+* Add REE 1.8.7-2012.02 and 1.8.7-2009.10
+* Add JRuby 1.6.7
+* Add Ruby 1.9.2-p318, 1.9.2-p320, and 1.9.3-p194
#### 20120216
-* Added definitions for REE 1.8.7-2011.12 and 1.8.7-2012.01.
-* Added definitions for JRuby 1.6.5.1 and 1.6.6.
-* Added definitions for Ruby 1.8.7-p358 and 1.9.3-p125.
-* Updated the readme with instructions for installing ruby-build as an
- rbenv plugin.
+* Add REE 1.8.7-2011.12 and 1.8.7-2012.01
+* Add JRuby 1.6.5.1 and 1.6.6
+* Add Ruby 1.8.7-p358 and 1.9.3-p125
+* Update the README with instructions for installing ruby-build as an rbenv
+ plugin
#### 20111230
-* Added a definition for MagLev 1.0.0.
+* Add MagLev 1.0.0
* Added support for overriding `make` options with the
- `$MAKEOPTS`/`$MAKE_OPTS` environment variable.
+ `$MAKEOPTS`/`$MAKE_OPTS` environment variable
* Removed RubyGems installations from JRuby definitions in favor of
- the bundled RubyGems versions.
-* Added a `before_install_package` hook.
-* Added definitions for REE 1.8.7-2009.09 and 1.8.7-2010.01.
-* Added definitions for Ruby 1.8.6-p383, 1.8.7-p302 and 1.8.7-p357.
-* Updated the JRuby 1.7.0-dev snapshot URL.
+ the bundled RubyGems versions
+* Add a `before_install_package` hook
+* Add REE 1.8.7-2009.09 and 1.8.7-2010.01
+* Add Ruby 1.8.6-p383, 1.8.7-p302 and 1.8.7-p357
+* Update the JRuby 1.7.0-dev snapshot URL
* Changed the GCC detector to look for `gcc-*` anywhere in the
- `$PATH`, not just `/usr/bin`.
+ `$PATH`, not just `/usr/bin`
#### 20111030
-* Added a Ruby 1.8.7-p334 definition.
+* Add Ruby 1.8.7-p334
* Renamed the 1.9.4-dev definition to 2.0.0-dev to reflect the new
- version numbering scheme.
+ version numbering scheme
* ruby-build now automatically displays the last 10 lines of the error
- log, if any, when a build fails.
-* Improved the GCC detection routines and added a more helpful error
- message for Xcode 4.2 users.
+ log, if any, when a build fails
+* Improve the GCC detection routines and add a more helpful error message for
+ Xcode 4.2 users
* JRuby installation no longer requires the install prefix to exist
- first.
-* You can now pass `$CONFIGURE_OPTS` to the REE definitions.
-* Added a JRuby 1.6.5 definition.
-* Added a Ruby 1.9.2-p180 definition.
-* Added a Ruby 1.9.3-p0 definition.
+ first
+* You can now pass `$CONFIGURE_OPTS` to the REE definitions
+* Add JRuby 1.6.5
+* Add Ruby 1.9.2-p180
+* Add Ruby 1.9.3-p0
#### 20110928
-* ruby-build now uses the `--with-gcc` configure flag on OS X Lion.
-* Added definitions for REE 1.8.7-2010.02 and 1.8.6-2009.06.
-* Modified `rbenv-install` to run `rbenv rehash` after installation.
-* Added a Ruby 1.9.3-rc1 definition.
-* Updated the JRuby defintions to install the `jruby-launcher` gem.
-* Updated the rbx-2.0.0 definition to point to the master branch.
-* Added a jruby-1.7.0-dev definition.
-* Added a Ruby 1.9.4-dev definition.
+* ruby-build now uses the `--with-gcc` configure flag on OS X Lion
+* Add REE 1.8.7-2010.02 and 1.8.6-2009.06
+* Modified `rbenv-install` to run `rbenv rehash` after installation
+* Add Ruby 1.9.3-rc1
+* Update the JRuby defintions to install the `jruby-launcher` gem
+* Update the Rubinius 2.0.0 definition to point to the master branch
+* Add JRuby 1.7.0-dev
+* Add Ruby 1.9.4-dev
#### 20110914
-* Added an rbx-2.0.0-dev definition for Rubinius 2.0.0 from git.
+* Add Rubinius 2.0.0-dev for Rubinius 2.0.0 from git
* Added support for setting `./configure` options with the
- `CONFIGURE_OPTS` environment variable.
-* Added a 1.9.3-dev definition for Ruby 1.9.3 from Git.
-* Added support for fetching package sources via Git.
-* Added an `rbenv-install` script which provides an `install` command
- for rbenv users.
+ `CONFIGURE_OPTS` environment variable
+* Add Ruby 1.9.3-dev from git
+* Add support for fetching package sources via git
+* Add an `rbenv-install` script which provides an `install` command for rbenv users
#### 20110906.1
* Changed the REE definition not to install its default gem
- collection.
+ collection
* Reverted a poorly-tested change that intended to enable support for
- relative installation paths.
+ relative installation paths
#### 20110906
- * Initial public release.
+ * Initial public release
diff --git a/LICENSE b/LICENSE
index c0507fd..f272008 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,20 +1,19 @@
-Copyright (c) 2012 Sam Stephenson
+Copyright (c) 2012-2013 Sam Stephenson
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 0dd2dfa..0cc568b 100644
--- a/README.md
+++ b/README.md
@@ -1,55 +1,53 @@
# ruby-build
-ruby-build is an [rbenv](https://github.com/sstephenson/rbenv) plugin
-that provides an `rbenv install` command to compile and install
-different versions of Ruby on UNIX-like systems.
+ruby-build is an [rbenv](https://github.com/sstephenson/rbenv) plugin that
+provides an `rbenv install` command to compile and install different versions
+of Ruby on UNIX-like systems.
-You can also use ruby-build without rbenv in environments where you
-need precise control over Ruby version installation.
+You can also use ruby-build without rbenv in environments where you need
+precise control over Ruby version installation.
## Installation
### Installing as an rbenv plugin (recommended)
-Installing ruby-build as an rbenv plugin will give you access to the
-`rbenv install` command.
+Installing ruby-build as an rbenv plugin will give you access to the `rbenv
+install` command.
- git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
+ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
-This will install the latest development version of ruby-build into
-the `~/.rbenv/plugins/ruby-build` directory. From that directory, you
-can check out a specific release tag. To update ruby-build, run `git
-pull` to download the latest changes.
+This will install the latest development version of ruby-build into the
+`~/.rbenv/plugins/ruby-build` directory. From that directory, you can check out
+a specific release tag. To update ruby-build, run `git pull` to download the
+latest changes.
### Installing as a standalone program (advanced)
-Installing ruby-build as a standalone program will give you access to
-the `ruby-build` command for precise control over Ruby version
-installation. If you have rbenv installed, you will also be able to
-use the `rbenv install` command.
+Installing ruby-build as a standalone program will give you access to the
+`ruby-build` command for precise control over Ruby version installation. If you
+have rbenv installed, you will also be able to use the `rbenv install` command.
- git clone git://github.com/sstephenson/ruby-build.git
+ git clone https://github.com/sstephenson/ruby-build.git
cd ruby-build
./install.sh
-This will install ruby-build into `/usr/local`. If you do not have
-write permission to `/usr/local`, you will need to run `sudo
-./install.sh` instead. You can install to a different prefix by
-setting the `PREFIX` environment variable.
+This will install ruby-build into `/usr/local`. If you do not have write
+permission to `/usr/local`, you will need to run `sudo ./install.sh` instead.
+You can install to a different prefix by setting the `PREFIX` environment
+variable.
-To update ruby-build after it has been installed, run `git pull` in
-your cloned copy of the repository, then re-run the install script.
+To update ruby-build after it has been installed, run `git pull` in your cloned
+copy of the repository, then re-run the install script.
### Installing with Homebrew (for OS X users)
-Mac OS X users can install ruby-build with the
-[Homebrew](http://mxcl.github.com/homebrew/) package manager. This
-will give you access to the `ruby-build` command. If you have rbenv
-installed, you will also be able to use the `rbenv install` command.
+Mac OS X users can install ruby-build with the [Homebrew](http://brew.sh)
+package manager. This will give you access to the `ruby-build` command. If you
+have rbenv installed, you will also be able to use the `rbenv install` command.
-*This is the recommended method of installation if you installed rbenv
- with Homebrew.*
+*This is the recommended method of installation if you installed rbenv with
+Homebrew.*
brew install ruby-build
@@ -62,161 +60,170 @@ Or, if you would like to install the latest development release:
### Using `rbenv install` with rbenv
-To install a Ruby version for use with rbenv, run `rbenv install` with
-the exact name of the version you want to install. For example,
+To install a Ruby version for use with rbenv, run `rbenv install` with the
+exact name of the version you want to install. For example,
- rbenv install 1.9.3-p392
+ rbenv install 2.1.0
-Ruby versions will be installed into a directory of the same name
-under `~/.rbenv/versions`.
+Ruby versions will be installed into a directory of the same name under
+`~/.rbenv/versions`.
-To see a list of all available Ruby versions, run `rbenv install --list`.
-You may also tab-complete available Ruby
-versions if your rbenv installation is properly configured.
+To see a list of all available Ruby versions, run `rbenv install --list`. You
+may also tab-complete available Ruby versions if your rbenv installation is
+properly configured.
### Using `ruby-build` standalone
-If you have installed ruby-build as a standalone program, you can use
-the `ruby-build` command to compile and install Ruby versions into
-specific locations.
+If you have installed ruby-build as a standalone program, you can use the
+`ruby-build` command to compile and install Ruby versions into specific
+locations.
-Run the `ruby-build` command with the exact name of the version you
-want to install and the full path where you want to install it. For
-example,
+Run the `ruby-build` command with the exact name of the version you want to
+install and the full path where you want to install it. For example,
- ruby-build 1.9.3-p392 ~/local/ruby-1.9.3-p392
+ ruby-build 2.1.0 ~/local/ruby-2.1.0
-To see a list of all available Ruby versions, run `ruby-build
---definitions`.
+To see a list of all available Ruby versions, run `ruby-build --definitions`.
-Pass the `-v` or `--verbose` flag to `ruby-build` as the first
-argument to see what's happening under the hood.
+Pass the `-v` or `--verbose` flag to `ruby-build` as the first argument to see
+what's happening under the hood.
### Custom definitions
-Both `rbenv install` and `ruby-build` accept a path to a custom
-definition file in place of a version name. Custom definitions let you
-develop and install versions of Ruby that are not yet supported by
-ruby-build.
+Both `rbenv install` and `ruby-build` accept a path to a custom definition file
+in place of a version name. Custom definitions let you develop and install
+versions of Ruby that are not yet supported by ruby-build.
-See the [ruby-build built-in
-definitions](https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build)
-as a starting point for custom definition files.
+See the [ruby-build built-in definitions][definitions] as a starting point for
+custom definition files.
+
+[definitions]: https://github.com/sstephenson/ruby-build/tree/master/share/ruby-build
### Special environment variables
-You can set certain environment variables to control the build
-process.
+You can set certain environment variables to control the build process.
* `TMPDIR` sets the location where ruby-build stores temporary files.
-* `RUBY_BUILD_BUILD_PATH` sets the location in which sources are
- downloaded and built. By default, this is a subdirectory of
- `TMPDIR`.
-* `RUBY_BUILD_CACHE_PATH`, if set, specifies a directory to use for
- caching downloaded package files.
-* `RUBY_BUILD_MIRROR_URL` overrides the default mirror URL root to one
- of your choosing.
-* `RUBY_BUILD_SKIP_MIRROR`, if set, forces ruby-build to download
- packages from their original source URLs instead of using a mirror.
+* `RUBY_BUILD_BUILD_PATH` sets the location in which sources are downloaded and
+ built. By default, this is a subdirectory of `TMPDIR`.
+* `RUBY_BUILD_CACHE_PATH`, if set, specifies a directory to use for caching
+ downloaded package files.
+* `RUBY_BUILD_MIRROR_URL` overrides the default mirror URL root to one of your
+ choosing.
+* `RUBY_BUILD_SKIP_MIRROR`, if set, forces ruby-build to download packages from
+ their original source URLs instead of using a mirror.
* `CC` sets the path to the C compiler.
+* `RUBY_CFLAGS` lets you pass additional options to the default `CFLAGS`. Use
+ this to override, for instance, the `-O3` option.
* `CONFIGURE_OPTS` lets you pass additional options to `./configure`.
-* `MAKE` lets you override the command to use for `make`. Useful for
- specifying GNU make (`gmake`) on some systems.
-* `MAKE_OPTS` (or `MAKEOPTS`) lets you pass additional options to
- `make`.
-* `RUBY_CONFIGURE_OPTS` and `RUBY_MAKE_OPTS` allow you to specify
- configure and make options for buildling MRI. These variables will
- be passed to Ruby only, not any dependent packages (e.g. libyaml).
+* `MAKE` lets you override the command to use for `make`. Useful for specifying
+ GNU make (`gmake`) on some systems.
+* `MAKE_OPTS` (or `MAKEOPTS`) lets you pass additional options to `make`.
+* `MAKE_INSTALL_OPTS` lets you pass additional options to `make install`.
+* `RUBY_CONFIGURE_OPTS`, `RUBY_MAKE_OPTS` and `RUBY_MAKE_INSTALL_OPTS` allow
+ you to specify configure and make options for buildling MRI. These variables
+ will be passed to Ruby only, not any dependent packages (e.g. libyaml).
+
+### Applying patches to Ruby before compiling
+
+Both `rbenv install` and `ruby-build` support the `--patch` (`-p`) flag that
+signals that a patch from stdin should be applied to Ruby, JRuby, or Rubinius
+source code before the `./configure` and compilation steps.
+
+Example usage:
+
+```sh
+# applying a single patch
+$ rbenv install --patch 1.9.3-p429 < /path/to/ruby.patch
+
+# applying a patch from HTTP
+$ rbenv install --patch 1.9.3-p429 < <(curl -sSL http://git.io/ruby.patch)
+
+# applying multiple patches
+$ cat fix1.patch fix2.patch | rbenv install --patch 1.9.3-p429
+```
### Checksum verification
-If you have the `md5`, `openssl`, or `md5sum` tool installed,
-ruby-build will automatically verify the MD5 checksum of each
-downloaded package before installing it.
+If you have the `md5`, `openssl`, or `md5sum` tool installed, ruby-build will
+automatically verify the MD5 checksum of each downloaded package before
+installing it.
-Checksums are optional and specified as anchors on the package URL in
-each definition. (All bundled definitions include checksums.)
+Checksums are optional and specified as anchors on the package URL in each
+definition. (All bundled definitions include checksums.)
### Package download mirrors
-ruby-build will first attempt to download package files from a mirror
-hosted on Amazon CloudFront. If a package is not available on the
-mirror, if the mirror is down, or if the download is corrupt,
-ruby-build will fall back to the official URL specified in the
-defintion file.
+ruby-build will first attempt to download package files from a mirror hosted on
+Amazon CloudFront. If a package is not available on the mirror, if the mirror
+is down, or if the download is corrupt, ruby-build will fall back to the
+official URL specified in the definition file.
You can point ruby-build to another mirror by specifying the
-`RUBY_BUILD_MIRROR_URL` environment variable--useful if you'd like to
-run your own local mirror, for example. Package mirror URLs are
-constructed by joining this variable with the MD5 checksum of the
-package file.
+`RUBY_BUILD_MIRROR_URL` environment variable--useful if you'd like to run your
+own local mirror, for example. Package mirror URLs are constructed by joining
+this variable with the MD5 checksum of the package file.
-If you don't have an MD5 program installed, ruby-build will skip the
-download mirror and use official URLs instead. You can force
-ruby-build to bypass the mirror by setting the
-`RUBY_BUILD_SKIP_MIRROR` environment variable.
+If you don't have an MD5 program installed, ruby-build will skip the download
+mirror and use official URLs instead. You can force ruby-build to bypass the
+mirror by setting the `RUBY_BUILD_SKIP_MIRROR` environment variable.
The official ruby-build download mirror is sponsored by
[37signals](http://37signals.com/).
### Package download caching
-You can instruct ruby-build to keep a local cache of downloaded
-package files by setting the `RUBY_BUILD_CACHE_PATH` environment
-variable. When set, package files will be kept in this directory after
-the first successful download and reused by subsequent invocations of
-`ruby-build` and `rbenv install`.
+You can instruct ruby-build to keep a local cache of downloaded package files
+by setting the `RUBY_BUILD_CACHE_PATH` environment variable. When set, package
+files will be kept in this directory after the first successful download and
+reused by subsequent invocations of `ruby-build` and `rbenv install`.
-The `rbenv install` command defaults this path to `~/.rbenv/cache`, so
-in most cases you can enable download caching simply by creating that
-directory.
+The `rbenv install` command defaults this path to `~/.rbenv/cache`, so in most
+cases you can enable download caching simply by creating that directory.
### Keeping the build directory after installation
-Both `ruby-build` and `rbenv install` accept the `-k` or `--keep`
-flag, which tells ruby-build to keep the downloaded source after
-installation. This can be useful if you need to use `gdb` and
-`memprof` with Ruby.
+Both `ruby-build` and `rbenv install` accept the `-k` or `--keep` flag, which
+tells ruby-build to keep the downloaded source after installation. This can be
+useful if you need to use `gdb` and `memprof` with Ruby.
-Source code will be kept in a parallel directory tree
-`~/.rbenv/sources` when using `--keep` with the `rbenv install`
-command. You should specify the location of the source code with the
-`RUBY_BUILD_BUILD_PATH` environment variable when using `--keep` with
-`ruby-build`.
+Source code will be kept in a parallel directory tree `~/.rbenv/sources` when
+using `--keep` with the `rbenv install` command. You should specify the
+location of the source code with the `RUBY_BUILD_BUILD_PATH` environment
+variable when using `--keep` with `ruby-build`.
## Getting Help
-Please see the [ruby-build
-wiki](https://github.com/sstephenson/ruby-build/wiki) for solutions to
-common problems.
+Please see the [ruby-build wiki][wiki] for solutions to common problems.
+
+[wiki]: https://github.com/sstephenson/ruby-build/wiki
If you can't find an answer on the wiki, open an issue on the [issue
-tracker](https://github.com/sstephenson/ruby-build/issues). Be sure to
-include the full build log for build failures.
+tracker](https://github.com/sstephenson/ruby-build/issues). Be sure to include
+the full build log for build failures.
### License
(The MIT License)
-Copyright (c) 2012 Sam Stephenson
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+Copyright (c) 2012-2013 Sam Stephenson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/bin/rbenv-install b/bin/rbenv-install
index b35db0e..9b725b7 100755
--- a/bin/rbenv-install
+++ b/bin/rbenv-install
@@ -1,16 +1,20 @@
#!/usr/bin/env bash
#
-# Summary: Install a Ruby version using the ruby-build plugin
+# Summary: Install a Ruby version using ruby-build
#
-# Usage: rbenv install [-f|--force] [-k|--keep] [-v|--verbose] <version>
-# rbenv install [-f|--force] [-k|--keep] [-v|--verbose] <definition-file>
+# Usage: rbenv install [-f] [-kvp] <version>
+# rbenv install [-f] [-kvp] <definition-file>
# rbenv install -l|--list
#
# -l/--list List all available versions
# -f/--force Install even if the version appears to be installed already
+#
+# ruby-build options:
+#
# -k/--keep Keep source tree in $RBENV_BUILD_ROOT after installation
# (defaults to $RBENV_ROOT/sources)
# -v/--verbose Verbose mode: print compilation status to stdout
+# -p/--patch Apply a patch from stdin before building
#
# For detailed information on installing Ruby versions with
# ruby-build, including a list of environment variables for adjusting
@@ -37,9 +41,19 @@ usage() {
[ -z "$1" ] || exit "$1"
}
+definitions() {
+ local query="$1"
+ ruby-build --definitions | grep -F "$query" || true
+}
+
+indent() {
+ sed 's/^/ /'
+}
+
unset FORCE
unset KEEP
unset VERBOSE
+unset HAS_PATCH
parse_options "$@"
for option in "${OPTIONS[@]}"; do
@@ -49,7 +63,7 @@ for option in "${OPTIONS[@]}"; do
;;
"l" | "list" )
echo "Available versions:"
- ruby-build --definitions | sed 's/^/ /'
+ definitions | indent
exit
;;
"f" | "force" )
@@ -61,6 +75,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" )
VERBOSE="-v"
;;
+ "p" | "patch" )
+ HAS_PATCH="-p"
+ ;;
"version" )
exec ruby-build --version
;;
@@ -77,7 +94,7 @@ unset VERSION_NAME
# version is specified by rbenv. Show usage instructions if a local
# version is not specified.
DEFINITION="${ARGUMENTS[0]}"
-[ -n "$DEFINITION" ] || DEFINITION="$(rbenv local 2>/dev/null || true)"
+[ -n "$DEFINITION" ] || DEFINITION="$(rbenv-local 2>/dev/null || true)"
[ -n "$DEFINITION" ] || usage 1
@@ -96,10 +113,10 @@ after_install() {
after_hooks["${#after_hooks[@]}"]="$hook"
}
-# Load plugin hooks.
-for script in $(rbenv-hooks install); do
- source "$script"
-done
+OLDIFS="$IFS"
+IFS=$'\n' scripts=(`rbenv-hooks install`)
+IFS="$OLDIFS"
+for script in "${scripts[@]}"; do source "$script"; done
# Set VERSION_NAME from $DEFINITION, if it is not already set. Then
@@ -133,6 +150,12 @@ if [ -z "${RUBY_BUILD_CACHE_PATH}" ] && [ -d "${RBENV_ROOT}/cache" ]; then
export RUBY_BUILD_CACHE_PATH="${RBENV_ROOT}/cache"
fi
+# Default RBENV_VERSION to the globally-specified Ruby version. (The
+# REE installer requires an existing Ruby installation to run. An
+# unsatisfied local .ruby-version file can cause the installer to
+# fail.)
+export RBENV_VERSION="$(rbenv-global 2>/dev/null || true)"
+
# Execute `before_install` hooks.
for hook in "${before_hooks[@]}"; do eval "$hook"; done
@@ -144,17 +167,33 @@ cleanup() {
trap cleanup SIGINT
-# Invoke `ruby-build` and record the exit status in $STATUS. Run
-# `rbenv rehash` after a successful installation.
+# Invoke `ruby-build` and record the exit status in $STATUS.
STATUS=0
-ruby-build $KEEP $VERBOSE "$DEFINITION" "$PREFIX" || STATUS="$?"
+ruby-build $KEEP $VERBOSE $HAS_PATCH "$DEFINITION" "$PREFIX" || STATUS="$?"
+
+# Display a more helpful message if the definition wasn't found.
+if [ "$STATUS" == "2" ]; then
+ { candidates="$(definitions "$DEFINITION")"
+ if [ -n "$candidates" ]; then
+ echo
+ echo "The following versions contain \`$DEFINITION' in the name:"
+ echo "$candidates" | indent
+ fi
+ echo
+ echo "You can list all available versions with \`rbenv install --list'."
+ echo
+ echo "If the version you're looking for is not present, first try upgrading"
+ echo "ruby-build. If it's still missing, open a request on the ruby-build"
+ echo "issue tracker: https://github.com/sstephenson/ruby-build/issues"
+ } >&2
+fi
# Execute `after_install` hooks.
for hook in "${after_hooks[@]}"; do eval "$hook"; done
# Run `rbenv-rehash` after a successful installation.
if [ "$STATUS" == "0" ]; then
- rbenv rehash
+ rbenv-rehash
else
cleanup
fi
diff --git a/bin/rbenv-uninstall b/bin/rbenv-uninstall
index 91fed82..10aa6e9 100755
--- a/bin/rbenv-uninstall
+++ b/bin/rbenv-uninstall
@@ -38,6 +38,24 @@ case "$DEFINITION" in
;;
esac
+declare -a before_hooks after_hooks
+
+before_uninstall() {
+ local hook="$1"
+ before_hooks["${#before_hooks[@]}"]="$hook"
+}
+
+after_uninstall() {
+ local hook="$1"
+ after_hooks["${#after_hooks[@]}"]="$hook"
+}
+
+OLDIFS="$IFS"
+IFS=$'\n' scripts=(`rbenv-hooks uninstall`)
+IFS="$OLDIFS"
+for script in "${scripts[@]}"; do source "$script"; done
+
+
VERSION_NAME="${DEFINITION##*/}"
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}"
@@ -54,7 +72,11 @@ if [ -z "$FORCE" ]; then
esac
fi
+for hook in "${before_hooks[@]}"; do eval "$hook"; done
+
if [ -d "$PREFIX" ]; then
rm -rf "$PREFIX"
- rbenv rehash
+ rbenv-rehash
fi
+
+for hook in "${after_hooks[@]}"; do eval "$hook"; done
diff --git a/bin/ruby-build b/bin/ruby-build
index 4791421..6a02f8a 100755
--- a/bin/ruby-build
+++ b/bin/ruby-build
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-RUBY_BUILD_VERSION="20130227"
+RUBY_BUILD_VERSION="20140224.1"
set -E
exec 3<&2 # preserve original stderr at fd 3
@@ -61,6 +61,16 @@ capitalize() {
printf "%s" "$1" | tr a-z A-Z
}
+sanitize() {
+ printf "%s" "$1" | sed "s/[^A-Za-z0-9.-]/_/g; s/__*/_/g"
+}
+
+colorize() {
+ if [ -t 1 ]; then printf "\e[%sm%s\e[m" "$1" "$2"
+ else echo -n "$2"
+ fi
+}
+
build_failed() {
{ echo
echo "BUILD FAILED"
@@ -92,6 +102,17 @@ file_is_not_empty() {
fi
}
+num_cpu_cores() {
+ local num=""
+ if [ "Darwin" = "$(uname -s)" ]; then
+ num="$(sysctl -n hw.ncpu 2>/dev/null || true)"
+ elif [ -r /proc/cpuinfo ]; then
+ num="$(grep ^processor /proc/cpuinfo | wc -l)"
+ [ "$num" -gt 0 ] || num=""
+ fi
+ echo "${num:-2}"
+}
+
install_package() {
install_package_using "tarball" 1 "$@"
}
@@ -168,11 +189,11 @@ verify_checksum() {
[ -e "$filename" ] || return 0
# If there's no expected checksum, return success
- local expected_checksum="$2"
+ local expected_checksum=`echo "$2" | tr [A-Z] [a-z]`
[ -n "$expected_checksum" ] || return 0
# If the computed checksum is empty, return failure
- local computed_checksum="$(compute_md5 < "$filename")"
+ local computed_checksum=`echo "$(compute_md5 < "$filename")" | tr [A-Z] [a-z]`
[ -n "$computed_checksum" ] || return 1
if [ "$expected_checksum" != "$computed_checksum" ]; then
@@ -188,12 +209,13 @@ verify_checksum() {
http() {
local method="$1"
local url="$2"
+ local file="$3"
[ -n "$url" ] || return 1
if type curl &>/dev/null; then
- "http_${method}_curl" "$url"
+ "http_${method}_curl" "$url" "$file"
elif type wget &>/dev/null; then
- "http_${method}_wget" "$url"
+ "http_${method}_wget" "$url" "$file"
else
echo "error: please install \`curl\` or \`wget\` and try again" >&2
exit 1
@@ -205,7 +227,7 @@ http_head_curl() {
}
http_get_curl() {
- curl -qsSLf "$1"
+ curl -C - -o "${2:--}" -qsSLf "$1"
}
http_head_wget() {
@@ -213,7 +235,7 @@ http_head_wget() {
}
http_get_wget() {
- wget -nv -O- "$1"
+ wget -nv -c -O "${2:--}" "$1"
}
fetch_tarball() {
@@ -231,17 +253,28 @@ fetch_tarball() {
fi
fi
+ local tar_args="xzvf"
local package_filename="${package_name}.tar.gz"
- symlink_tarball_from_cache "$package_filename" "$checksum" || {
+
+ if [ "$package_url" != "${package_url%bz2}" ]; then
+ package_filename="${package_filename%.gz}.bz2"
+ tar_args="${tar_args/z/j}"
+ fi
+
+ if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
- { http head "$mirror_url" &&
- download_tarball "$mirror_url" "$package_filename" "$checksum"
- } ||
+ http head "$mirror_url" &&
+ download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
- }
+ fi
- { tar xzvf "$package_filename"
- rm -f "$package_filename"
+ { if tar $tar_args "$package_filename"; then
+ if [ -z "$KEEP_BUILD_PATH" ]; then
+ rm -f "$package_filename"
+ else
+ true
+ fi
+ fi
} >&4 2>&1
}
@@ -266,9 +299,12 @@ download_tarball() {
echo "-> $package_url" >&2
- { http get "$package_url" > "$package_filename"
- verify_checksum "$package_filename" "$checksum"
- } >&4 2>&1 || return 1
+ if http get "$package_url" "$package_filename" >&4 2>&1; then
+ verify_checksum "$package_filename" "$checksum" >&4 2>&1 || return 1
+ else
+ echo "error: failed to download $package_filename" >&2
+ return 1
+ fi
if [ -n "$RUBY_BUILD_CACHE_PATH" ]; then
local cached_package_filename="${RUBY_BUILD_CACHE_PATH}/$package_filename"
@@ -286,6 +322,20 @@ fetch_git() {
echo "Cloning ${git_url}..." >&2
if type git &>/dev/null; then
+ if [ -n "$RUBY_BUILD_CACHE_PATH" ]; then
+ pushd "$RUBY_BUILD_CACHE_PATH" >&4
+ local clone_name="$(sanitize "$git_url")"
+ if [ -e "${clone_name}" ]; then
+ { cd "${clone_name}"
+ git fetch --force "$git_url" "+${git_ref}:${git_ref}"
+ } >&4 2>&1
+ else
+ git clone --bare --branch "$git_ref" "$git_url" "${clone_name}" >&4 2>&1
+ fi
+ git_url="$RUBY_BUILD_CACHE_PATH/${clone_name}"
+ popd >&4
+ fi
+
git clone --depth 1 --branch "$git_ref" "$git_url" "${package_name}" >&4 2>&1
else
echo "error: please install \`git\` and try again" >&2
@@ -320,6 +370,8 @@ build_package() {
echo "Installing ${package_name}..." >&2
+ [ -n "$HAS_PATCH" ] && apply_ruby_patch "$package_name"
+
for command in $commands; do
"build_package_${command}" "$package_name"
done
@@ -341,7 +393,7 @@ build_package_standard() {
if [ "${MAKEOPTS+defined}" ]; then
MAKE_OPTS="$MAKEOPTS"
elif [ -z "${MAKE_OPTS+defined}" ]; then
- MAKE_OPTS="-j 2"
+ MAKE_OPTS="-j $(num_cpu_cores)"
fi
# Support YAML_CONFIGURE_OPTS, RUBY_CONFIGURE_OPTS, etc.
@@ -352,11 +404,20 @@ build_package_standard() {
local PACKAGE_CONFIGURE_OPTS_ARRAY="${package_var_name}_CONFIGURE_OPTS_ARRAY[@]"
local PACKAGE_MAKE_OPTS="${package_var_name}_MAKE_OPTS"
local PACKAGE_MAKE_OPTS_ARRAY="${package_var_name}_MAKE_OPTS_ARRAY[@]"
+ local PACKAGE_MAKE_INSTALL_OPTS="${package_var_name}_MAKE_INSTALL_OPTS"
+ local PACKAGE_MAKE_INSTALL_OPTS_ARRAY="${package_var_name}_MAKE_INSTALL_OPTS_ARRAY[@]"
local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"
- { CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}" ${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}"
- "$MAKE" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} "${!PACKAGE_MAKE_OPTS_ARRAY}"
- "$MAKE" install
+ [ "$package_var_name" = "RUBY" ] && use_homebrew_readline || true
+
+ ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
+ export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}"
+ fi
+ ${!PACKAGE_CONFIGURE:-./configure} --prefix="${!PACKAGE_PREFIX_PATH:-$PREFIX_PATH}" $CONFIGURE_OPTS ${!PACKAGE_CONFIGURE_OPTS} "${!PACKAGE_CONFIGURE_OPTS_ARRAY}"
+ ) >&4 2>&1
+
+ { "$MAKE" $MAKE_OPTS ${!PACKAGE_MAKE_OPTS} "${!PACKAGE_MAKE_OPTS_ARRAY}"
+ "$MAKE" install $MAKE_INSTALL_OPTS ${!PACKAGE_MAKE_INSTALL_OPTS} "${!PACKAGE_MAKE_INSTALL_OPTS_ARRAY}"
} >&4 2>&1
}
@@ -373,11 +434,18 @@ build_package_ruby() {
}
build_package_ree_installer() {
+ build_package_auto_tcltk
+
local options=""
if [[ "Darwin" = "$(uname)" ]]; then
options="--no-tcmalloc"
fi
+ local option
+ for option in $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[@]}; do
+ options="$options -c $option"
+ done
+
# Work around install_useful_libraries crash with --dont-install-useful-gems
mkdir -p "$PREFIX_PATH/lib/ruby/gems/1.8/gems"
@@ -388,8 +456,23 @@ build_package_ree_installer() {
build_package_rbx() {
local package_name="$1"
- { ./configure --prefix="$PREFIX_PATH" --gemsdir="$PREFIX_PATH"
+ { bundle --path=vendor/bundle
+ RUBYOPT="-rubygems $RUBYOPT" ./configure --prefix="$PREFIX_PATH" $RUBY_CONFIGURE_OPTS
rake install
+ fix_rbx_gem_binstubs "$PREFIX_PATH"
+ fix_rbx_irb "$PREFIX_PATH"
+ } >&4 2>&1
+}
+
+build_package_mruby() {
+ local package_name="$1"
+
+ { rake
+ mkdir -p "$PREFIX_PATH"
+ cp -fR build/host/* "$PREFIX_PATH"
+ cd "$PREFIX_PATH/bin"
+ ln -fs mruby ruby
+ ln -fs mirb irb
} >&4 2>&1
}
@@ -408,12 +491,32 @@ build_package_maglev() {
echo "Run 'maglev start' to start up the stone before using 'ruby' or 'irb'"
}
+build_package_topaz() {
+ build_package_copy
+ { cd "${PREFIX_PATH}/bin"
+ echo "Creating symlink for ruby*"
+ ln -fs topaz ruby
+ } >&4 2>&1
+}
+
+topaz_architecture() {
+ case "$(uname -s)" in
+ "Darwin") echo "osx64";;
+ "Linux") [[ "$(uname -m)" = "x86_64" ]] && echo "linux64" || echo "linux32";;
+ *)
+ echo "no nightly builds available" >&2
+ exit 1;;
+ esac
+}
+
build_package_jruby() {
build_package_copy
cd "${PREFIX_PATH}/bin"
ln -fs jruby ruby
+ chmod +x ruby
install_jruby_launcher
remove_windows_files
+ fix_jruby_shebangs
}
install_jruby_launcher() {
@@ -422,6 +525,15 @@ install_jruby_launcher() {
} >&4 2>&1
}
+fix_jruby_shebangs() {
+ for file in "${PREFIX_PATH}/bin"/*; do
+ if [ "$(head -c 20 "$file")" = "#!/usr/bin/env jruby" ]; then
+ sed -i.bak "1 s:.*:#\!${PREFIX_PATH}\/bin\/jruby:" "$file"
+ rm "$file".bak
+ fi
+ done
+}
+
remove_windows_files() {
cd "$PREFIX_PATH"
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
@@ -429,7 +541,7 @@ remove_windows_files() {
build_package_copy() {
mkdir -p "$PREFIX_PATH"
- cp -R . "$PREFIX_PATH"
+ cp -fR . "$PREFIX_PATH"
}
before_install_package() {
@@ -445,19 +557,54 @@ fix_directory_permissions() {
find "$PREFIX_PATH" -type d \( -perm -020 -o -perm -002 \) -exec chmod go-w {} \;
}
+fix_rbx_gem_binstubs() {
+ local prefix="$1"
+ local gemdir="${prefix}/gems/bin"
+ local bindir="${prefix}/bin"
+ local file binstub
+ # Symlink Rubinius' `gems/bin/` into `bin/`
+ if [ -d "$gemdir" ]; then
+ for file in "$gemdir"/*; do
+ binstub="${bindir}/${file##*/}"
+ rm -f "$binstub"
+ sed -E "s:^#\!.+:#\!${bindir}/ruby:" < "$file" > "$binstub"
+ chmod +x "$binstub"
+ done
+ rm -rf "$gemdir"
+ ln -s ../bin "$gemdir"
+ fi
+}
+
+fix_rbx_irb() {
+ local prefix="$1"
+ "${prefix}/bin/irb" --version &>/dev/null ||
+ "${prefix}/bin/gem" install rubysl-tracer -v '~> 2.0' --no-rdoc --no-ri &>/dev/null ||
+ true
+}
+
+require_java7() {
+ local version="$(java -version 2>&1 | head -1)"
+ if [[ $version != *1.[789]* ]]; then
+ colorize 1 "ERROR" >&3
+ echo ": Java 7 required. Please install a 1.7-compatible JRE." >&3
+ return 1
+ fi
+}
+
require_gcc() {
local gcc="$(locate_gcc || true)"
if [ -z "$gcc" ]; then
- local esc=$'\033'
{ echo
- echo "${esc}[1mERROR${esc}[0m: This package must be compiled with GCC, but ruby-build couldn't"
+ colorize 1 "ERROR"
+ echo ": This package must be compiled with GCC, but ruby-build couldn't"
echo "find a suitable \`gcc\` executable on your system. Please install GCC"
echo "and try again."
echo
if [ "$(uname -s)" = "Darwin" ]; then
- echo "${esc}[1mDETAILS${esc}[0m: Apple no longer includes the official GCC compiler with Xcode"
+ colorize 1 "DETAILS"
+ echo ": Apple no longer includes the official GCC compiler with Xcode"
echo "as of version 4.2. Instead, the \`gcc\` executable is a symlink to"
echo "\`llvm-gcc\`, a modified version of GCC which outputs LLVM bytecode."
echo
@@ -466,8 +613,19 @@ require_gcc() {
echo "\`llvm-gcc\`. To build older versions of Ruby you must have the official"
echo "GCC compiler installed on your system."
echo
- echo "${esc}[1mTO FIX THE PROBLEM${esc}[0m: Install the official GCC compiler using these"
- echo "packages: ${esc}[4mhttps://github.com/kennethreitz/osx-gcc-installer/downloads${esc}[0m"
+
+ colorize 1 "TO FIX THE PROBLEM"
+ if type brew &>/dev/null; then
+ echo ": Install Homebrew's apple-gcc42 package with this"
+ echo -n "command: "
+ colorize 4 "brew tap homebrew/dupes ; brew install apple-gcc42"
+ else
+ echo ": Install the official GCC compiler using these"
+ echo -n "packages: "
+ colorize 4 "https://github.com/kennethreitz/osx-gcc-installer/downloads"
+ fi
+
+ echo
echo
echo "You will need to install the official GCC compiler to build older"
echo "versions of Ruby even if you have installed Apple's Command Line Tools"
@@ -529,10 +687,45 @@ verify_gcc() {
echo "$gcc"
}
+needs_yaml() {
+ [[ "$RUBY_CONFIGURE_OPTS" != *--with-libyaml-dir=* ]] &&
+ ! use_homebrew_yaml
+}
+
+use_homebrew_yaml() {
+ local libdir="$(brew --prefix libyaml 2>/dev/null || true)"
+ if [ -d "$libdir" ]; then
+ package_option ruby configure --with-libyaml-dir="$libdir"
+ else
+ return 1
+ fi
+}
+
+use_homebrew_readline() {
+ if [[ "$RUBY_CONFIGURE_OPTS" != *--with-readline-dir=* ]]; then
+ local libdir="$(brew --prefix readline 2>/dev/null || true)"
+ if [ -d "$libdir" ]; then
+ package_option ruby configure --with-readline-dir="$libdir"
+ else
+ return 1
+ fi
+ fi
+}
+
has_broken_mac_openssl() {
[ "$(uname -s)" = "Darwin" ] &&
- [ "$(openssl version 2>/dev/null || true)" = "OpenSSL 0.9.8r 8 Feb 2011" ] &&
- [[ "$RUBY_CONFIGURE_OPTS" != *--with-openssl-dir=* ]]
+ [[ "$(openssl version 2>/dev/null || true)" = "OpenSSL 0.9.8"?* ]] &&
+ [[ "$RUBY_CONFIGURE_OPTS" != *--with-openssl-dir=* ]] &&
+ ! use_homebrew_openssl
+}
+
+use_homebrew_openssl() {
+ local ssldir="$(brew --prefix openssl 2>/dev/null || true)"
+ if [ -d "$ssldir" ]; then
+ package_option ruby configure --with-openssl-dir="$ssldir"
+ else
+ return 1
+ fi
}
build_package_mac_openssl() {
@@ -573,13 +766,73 @@ build_package_verify_openssl() {
end' >&4 2>&1
}
+# Ensure that directories listed in LDFLAGS exist
+build_package_ldflags_dirs() {
+ local arg
+ for arg in $LDFLAGS; do
+ case "$arg" in
+ -L* ) mkdir -p "${arg#-L}" ;;
+ esac
+ done
+}
+
+build_package_auto_tcltk() {
+ if [ "Darwin" = "$(uname -s)" ] && [ ! -d /usr/include/X11 ]; then
+ if [ -d /opt/X11/include ]; then
+ if [[ "$CPPFLAGS" != *-I/opt/X11/include* ]]; then
+ export CPPFLAGS="-I/opt/X11/include $CPPFLAGS"
+ fi
+ else
+ package_option ruby configure --without-tk
+ fi
+ fi
+}
+
+rake() {
+ if [ -e "./Gemfile" ]; then
+ bundle exec rake "$@"
+ else
+ isolated_gem_dependency "rake --version" rake -v '~> 10.1.0'
+ command rake "$@"
+ fi
+}
+
+bundle() {
+ isolated_gem_dependency "bundle --version" bundler -v '~> 1.3.5'
+ command bundle "$@"
+}
+
+isolated_gem_dependency() {
+ set +E
+ ( command $1 &>/dev/null ) || {
+ set -E
+ shift 1
+ isolated_gem_install "$@"
+ }
+ set -E
+}
+
+isolated_gem_install() {
+ export GEM_HOME="${PWD}/.gem"
+ export PATH="${GEM_HOME}/bin:${PATH}"
+ gem install "$@"
+}
+
+apply_ruby_patch() {
+ case "$1" in
+ ruby-* | jruby-* | rubinius-* )
+ patch -p0 -i "${2:--}"
+ ;;
+ esac
+}
+
version() {
echo "ruby-build ${RUBY_BUILD_VERSION}"
}
usage() {
{ version
- echo "usage: ruby-build [-k|--keep] [-v|--verbose] definition prefix"
+ echo "usage: ruby-build [-k|--keep] [-v|--verbose] [-p|--patch] definition prefix"
echo " ruby-build --definitions"
} >&2
@@ -599,6 +852,7 @@ list_definitions() {
unset VERBOSE
unset KEEP_BUILD_PATH
+unset HAS_PATCH
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
parse_options "$@"
@@ -610,6 +864,7 @@ for option in "${OPTIONS[@]}"; do
{ echo
echo " -k/--keep Do not remove source tree after installation"
echo " -v/--verbose Verbose mode: print compilation status to stdout"
+ echo " -p/--patch Apply a patch from stdin before building"
echo " --definitions List all built-in definitions"
echo
} >&2
@@ -625,6 +880,9 @@ for option in "${OPTIONS[@]}"; do
"v" | "verbose" )
VERBOSE=true
;;
+ "p" | "patch" )
+ HAS_PATCH=true
+ ;;
"version" )
version
exit 0
@@ -641,13 +899,15 @@ elif [ ! -e "$DEFINITION_PATH" ]; then
DEFINITION_PATH="$BUILTIN_DEFINITION_PATH"
else
echo "ruby-build: definition not found: ${DEFINITION_PATH}" >&2
- exit 1
+ exit 2
fi
fi
PREFIX_PATH="${ARGUMENTS[1]}"
if [ -z "$PREFIX_PATH" ]; then
usage
+elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
+ PREFIX_PATH="${PWD}/${PREFIX_PATH}"
fi
if [ -z "$TMPDIR" ]; then
@@ -656,15 +916,27 @@ else
TMP="${TMPDIR%/}"
fi
-# Work around warnings building Ruby 2.0 on Clang 2.x
-if type clang &>/dev/null; then
- if "${CC:-clang}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
- RUBY_CFLAGS="$RUBY_CFLAGS -Wno-error=shorten-64-to-32"
- fi
+if [ ! -w "$TMP" ] || [ ! -x "$TMP" ]; then
+ echo "ruby-build: TMPDIR=$TMP is set to a non-accessible location" >&2
+ exit 1
+fi
+
+# Work around warnings building Ruby 2.0 on Clang 2.x:
+# pass -Wno-error=shorten-64-to-32 if the compiler accepts it.
+#
+# When we set CFLAGS, Ruby won't apply its default flags, though. Since clang
+# builds 1.9.x and 2.x only, where -O3 is default, we can safely set that flag.
+# Ensure it's the first flag since later flags take precedence.
+if "${CC:-cc}" -x c /dev/null -E -Wno-error=shorten-64-to-32 &>/dev/null; then
+ RUBY_CFLAGS="-O3 -Wno-error=shorten-64-to-32 $RUBY_CFLAGS"
fi
if [ -z "$MAKE" ]; then
- export MAKE="make"
+ if [[ "FreeBSD" = "$(uname -s)" ]]; then
+ export MAKE="gmake"
+ else
+ export MAKE="make"
+ fi
fi
if [ -n "$RUBY_BUILD_CACHE_PATH" ] && [ -d "$RUBY_BUILD_CACHE_PATH" ]; then
@@ -708,8 +980,8 @@ if [ -n "$VERBOSE" ]; then
trap "kill $TAIL_PID" SIGINT SIGTERM EXIT
fi
-export LDFLAGS="-L'${PREFIX_PATH}/lib' ${LDFLAGS}"
-export CPPFLAGS="-I'${PREFIX_PATH}/include' ${CPPFLAGS}"
+export LDFLAGS="-L${PREFIX_PATH}/lib ${LDFLAGS}"
+export CPPFLAGS="-I${PREFIX_PATH}/include ${CPPFLAGS}"
unset RUBYOPT
unset RUBYLIB
diff --git a/install.sh b/install.sh
index f01f456..94f3531 100755
--- a/install.sh
+++ b/install.sh
@@ -1,7 +1,12 @@
#!/bin/sh
+# Usage: PREFIX=/usr/local ./install.sh
+#
+# Installs ruby-build under $PREFIX.
set -e
+cd "$(dirname "$0")"
+
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
@@ -9,15 +14,7 @@ fi
BIN_PATH="${PREFIX}/bin"
SHARE_PATH="${PREFIX}/share/ruby-build"
-mkdir -p "${BIN_PATH}"
-mkdir -p "${SHARE_PATH}"
-
-for file in bin/*; do
- cp "${file}" "${BIN_PATH}"
-done
-
-for file in share/ruby-build/*; do
- cp "${file}" "${SHARE_PATH}"
-done
+mkdir -p "$BIN_PATH" "$SHARE_PATH"
-echo "Installed ruby-build at ${PREFIX}"
+install -p bin/* "$BIN_PATH"
+install -p -m 0644 share/ruby-build/* "$SHARE_PATH"
diff --git a/script/mirror b/script/mirror
new file mode 100755
index 0000000..ec23b87
--- /dev/null
+++ b/script/mirror
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+# Usage: script/mirror update <COMMIT-RANGE>
+# script/mirror stats
+set -e
+
+commit_range="${1?}"
+
+eval "$(grep RUBY_BUILD_MIRROR_URL= ./bin/ruby-build | head -1)"
+
+test_mirrored() {
+ curl -qsSfIL "$RUBY_BUILD_MIRROR_URL/$1" >/dev/null 2>&1
+}
+
+compute_md5() {
+ local output="$(openssl md5)"
+ echo "${output##* }" | tr '[A-Z]' '[a-z]'
+}
+
+download_package() {
+ curl -qsSfL -o "$2" "$1"
+}
+
+download_and_verify() {
+ local checksum
+ local url="$1"
+ local file="$2"
+ local expected="$3"
+ download_package "$url" "$file"
+ checksum="$(compute_md5 < "$file")"
+ if [ "$checksum" != "$expected" ]; then
+ echo "Error: $url doesn't match its checksum $expected" >&2
+ return 1
+ fi
+}
+
+changed_files() {
+ git diff --name-only --diff-filter=ACMR "$@"
+}
+
+potentially_new_packages() {
+ local files="$(changed_files "$1" -- ./share/ruby-build)"
+ [ -n "$files" ] && extract_urls $files
+}
+
+extract_urls() {
+ grep -hoe 'http[^"]\+#[^"]\+' "$@" | sort | uniq
+}
+
+update() {
+ local url
+ local checksum
+ local file
+ for url in $(potentially_new_packages "$1"); do
+ checksum="${url#*#}"
+ url="${url%#*}"
+ if test_mirrored "$checksum"; then
+ echo "Already mirrored: $url"
+ else
+ echo "Mirroring: $url"
+ file="${TMPDIR:-/tmp}/$checksum"
+ download_and_verify "$url" "$file" "$checksum"
+ ./script/s3-put "$file" "${AMAZON_S3_BUCKET?}"
+ fi
+ done
+}
+
+stats() {
+ local packages=( $(extract_urls ./share/ruby-build/*) )
+ local total="${#packages[@]}"
+ local confirmed=0
+ local checksum
+ for url in "${packages[@]}"; do
+ checksum="${url#*#}"
+ if test_mirrored "$checksum"; then
+ confirmed="$((confirmed + 1))"
+ else
+ echo "failed: $url" >&2
+ fi
+ echo -n "."
+ done
+ echo
+ echo "$confirmed/$total mirrored"
+}
+
+cmd="${1?}"
+shift 1
+"$cmd" "$@"
diff --git a/script/s3-put b/script/s3-put
new file mode 100755
index 0000000..5efdfce
--- /dev/null
+++ b/script/s3-put
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# Usage: s3-put <FILE> <S3_BUCKET> [<CONTENT_TYPE>]
+#
+# Uploads a file to the Amazon S3 service.
+#
+# Depends on AWS credentials being set via env:
+# - AMAZON_ACCESS_KEY_ID
+# - AMAZON_SECRET_ACCESS_KEY
+#
+# Outputs the URL of the newly uploaded file.
+set -e
+
+authorization() {
+ local signature="$(string_to_sign | hmac_sha1 | base64)"
+ echo "AWS ${AMAZON_ACCESS_KEY_ID?}:${signature}"
+}
+
+hmac_sha1() {
+ openssl dgst -binary -sha1 -hmac "${AMAZON_SECRET_ACCESS_KEY?}"
+}
+
+base64() {
+ openssl enc -base64
+}
+
+bin_md5() {
+ openssl dgst -binary -md5
+}
+
+string_to_sign() {
+ echo "$http_method"
+ echo "$content_md5"
+ echo "$content_type"
+ echo "$date"
+ echo "x-amz-acl:$acl"
+ printf "/$bucket/$remote_path"
+}
+
+date_string() {
+ LC_TIME=C date "+%a, %d %h %Y %T %z"
+}
+
+file="$1"
+bucket="$2"
+content_type="$3"
+
+http_method=PUT
+acl="public-read"
+remote_path="${file##*/}"
+content_md5="$(bin_md5 < "$file" | base64)"
+date="$(date_string)"
+
+url="https://$bucket.s3.amazonaws.com/$remote_path"
+
+curl -qsSf -T "$file" \
+ -H "Authorization: $(authorization)" \
+ -H "x-amz-acl: $acl" \
+ -H "Date: $date" \
+ -H "Content-MD5: $content_md5" \
+ -H "Content-Type: $content_type" \
+ "$url"
+
+echo "$url"
diff --git a/script/test b/script/test
new file mode 100755
index 0000000..d7a667e
--- /dev/null
+++ b/script/test
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+set -e
+
+[ -d ./bats/bin ] && export PATH=./bats/bin:"$PATH"
+
+STATUS=0
+bats -t test || STATUS="$?"
+
+if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then
+ ./script/mirror update "$TRAVIS_COMMIT_RANGE"
+fi
+
+exit "$STATUS"
diff --git a/share/ruby-build/1.8.6-p383 b/share/ruby-build/1.8.6-p383
index 70236d6..3e96190 100644
--- a/share/ruby-build/1.8.6-p383
+++ b/share/ruby-build/1.8.6-p383
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.6-p383" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p383.tar.gz#4f49544d4a4d0d34e9d86c41e853db2e"
+install_package "ruby-1.8.6-p383" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p383.tar.gz#4f49544d4a4d0d34e9d86c41e853db2e" auto_tcltk standard
install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz#e85cfadd025ff6ab689375adbf344bbe" ruby
diff --git a/share/ruby-build/1.8.6-p420 b/share/ruby-build/1.8.6-p420
index 3caa0b0..ce40539 100644
--- a/share/ruby-build/1.8.6-p420
+++ b/share/ruby-build/1.8.6-p420
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.6-p420" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p420.tar.gz#ca1eee44f842e93b5098bc5a2bb9a40b"
+install_package "ruby-1.8.6-p420" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p420.tar.gz#ca1eee44f842e93b5098bc5a2bb9a40b" auto_tcltk standard
install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz#e85cfadd025ff6ab689375adbf344bbe" ruby
diff --git a/share/ruby-build/1.8.7-p249 b/share/ruby-build/1.8.7-p249
index a5a8c01..2a7ed34 100644
--- a/share/ruby-build/1.8.7-p249
+++ b/share/ruby-build/1.8.7-p249
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p249" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz#d7db7763cffad279952eb7e9bbfc221c"
+install_package "ruby-1.8.7-p249" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p249.tar.gz#d7db7763cffad279952eb7e9bbfc221c" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p302 b/share/ruby-build/1.8.7-p302
index 88b086e..1324e32 100644
--- a/share/ruby-build/1.8.7-p302
+++ b/share/ruby-build/1.8.7-p302
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p302" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.gz#f446550dfde0d8162a6ed8d5a38b3ac2"
+install_package "ruby-1.8.7-p302" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p302.tar.gz#f446550dfde0d8162a6ed8d5a38b3ac2" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p334 b/share/ruby-build/1.8.7-p334
index 00417fa..cab1761 100644
--- a/share/ruby-build/1.8.7-p334
+++ b/share/ruby-build/1.8.7-p334
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p334" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz#aacb6ee5dfe2367682bba56af7f415b8"
+install_package "ruby-1.8.7-p334" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz#aacb6ee5dfe2367682bba56af7f415b8" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p352 b/share/ruby-build/1.8.7-p352
index 33a9577..881ce60 100644
--- a/share/ruby-build/1.8.7-p352
+++ b/share/ruby-build/1.8.7-p352
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p352" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p352.tar.gz#0c33f663a10a540ea65677bb755e57a7"
+install_package "ruby-1.8.7-p352" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p352.tar.gz#0c33f663a10a540ea65677bb755e57a7" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p357 b/share/ruby-build/1.8.7-p357
index 48ba0f0..ae16d0d 100644
--- a/share/ruby-build/1.8.7-p357
+++ b/share/ruby-build/1.8.7-p357
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p357" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p357.tar.gz#b2b8248ff5097cfd629f5b9768d1df82"
+install_package "ruby-1.8.7-p357" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p357.tar.gz#b2b8248ff5097cfd629f5b9768d1df82" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p358 b/share/ruby-build/1.8.7-p358
index 0c58305..1937a1a 100644
--- a/share/ruby-build/1.8.7-p358
+++ b/share/ruby-build/1.8.7-p358
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p358" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p358.tar.gz#26bd55358847459a7752acdbd33a535f"
+install_package "ruby-1.8.7-p358" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p358.tar.gz#26bd55358847459a7752acdbd33a535f" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p370 b/share/ruby-build/1.8.7-p370
index deaa0e0..8fe6cbb 100644
--- a/share/ruby-build/1.8.7-p370
+++ b/share/ruby-build/1.8.7-p370
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p370" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p370.tar.gz#98b00bbd1cdde3116155edb6e555b781"
+install_package "ruby-1.8.7-p370" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p370.tar.gz#98b00bbd1cdde3116155edb6e555b781" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p371 b/share/ruby-build/1.8.7-p371
index 456bb7e..f64d4d4 100644
--- a/share/ruby-build/1.8.7-p371
+++ b/share/ruby-build/1.8.7-p371
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p371" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p371.tar.gz#653f07bb45f03d0bf3910491288764df"
+install_package "ruby-1.8.7-p371" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p371.tar.gz#653f07bb45f03d0bf3910491288764df" auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p374 b/share/ruby-build/1.8.7-p374
new file mode 100644
index 0000000..946b032
--- /dev/null
+++ b/share/ruby-build/1.8.7-p374
@@ -0,0 +1,3 @@
+require_gcc
+install_package "ruby-1.8.7-p374" "http://cache.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p374.tar.gz#b72a0bc5b824398537762e5272bbb8dc" auto_tcltk standard
+install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.8.7-p334 b/share/ruby-build/1.8.7-p375
similarity index 53%
copy from share/ruby-build/1.8.7-p334
copy to share/ruby-build/1.8.7-p375
index 00417fa..938a09a 100644
--- a/share/ruby-build/1.8.7-p334
+++ b/share/ruby-build/1.8.7-p375
@@ -1,3 +1,3 @@
require_gcc
-install_package "ruby-1.8.7-p334" "http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz#aacb6ee5dfe2367682bba56af7f415b8"
+install_svn "ruby-1.8.7-p375" "http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7" "44351" autoconf auto_tcltk standard
install_package "rubygems-1.6.2" "http://production.cf.rubygems.org/rubygems/rubygems-1.6.2.tgz#0c95a9869914ba1a45bf71d3b8048420" ruby
diff --git a/share/ruby-build/1.9.1-p378 b/share/ruby-build/1.9.1-p378
index 106e193..c6fdc26 100644
--- a/share/ruby-build/1.9.1-p378
+++ b/share/ruby-build/1.9.1-p378
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.1-p378" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p378.tar.gz#9fc5941bda150ac0a33b299e1e53654c"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.1-p378" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p378.tar.gz#9fc5941bda150ac0a33b299e1e53654c"
install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz#e85cfadd025ff6ab689375adbf344bbe" ruby
diff --git a/share/ruby-build/1.9.1-p430 b/share/ruby-build/1.9.1-p430
new file mode 100644
index 0000000..4870c10
--- /dev/null
+++ b/share/ruby-build/1.9.1-p430
@@ -0,0 +1,4 @@
+require_gcc
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.1-p430" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p430.tar.gz#093d17e911b1f7306de95422ec332826"
+install_package "rubygems-1.3.7" "http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz#e85cfadd025ff6ab689375adbf344bbe" ruby
diff --git a/share/ruby-build/1.9.2-p0 b/share/ruby-build/1.9.2-p0
new file mode 100644
index 0000000..9b1252c
--- /dev/null
+++ b/share/ruby-build/1.9.2-p0
@@ -0,0 +1,4 @@
+require_gcc
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.2-p0" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p0.tar.gz#755aba44607c580fddc25e7c89260460"
+install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.2-p180 b/share/ruby-build/1.9.2-p180
index 1daeeed..9addcff 100644
--- a/share/ruby-build/1.9.2-p180
+++ b/share/ruby-build/1.9.2-p180
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.2-p180" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz#0d6953820c9918820dd916e79f4bfde8"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.2-p180" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p180.tar.gz#0d6953820c9918820dd916e79f4bfde8"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.2-p290 b/share/ruby-build/1.9.2-p290
index 0100d82..fcdc054 100644
--- a/share/ruby-build/1.9.2-p290
+++ b/share/ruby-build/1.9.2-p290
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.2-p290" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz#604da71839a6ae02b5b5b5e1b792d5eb"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.2-p290" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p290.tar.gz#604da71839a6ae02b5b5b5e1b792d5eb"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.2-p318 b/share/ruby-build/1.9.2-p318
index 5f7b28c..e4ef92a 100644
--- a/share/ruby-build/1.9.2-p318
+++ b/share/ruby-build/1.9.2-p318
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.2-p318" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p318.tar.gz#cc7bf1025128e1985882ae243f348802"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.2-p318" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p318.tar.gz#cc7bf1025128e1985882ae243f348802"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.2-p320 b/share/ruby-build/1.9.2-p320
index b301ff8..cee9c6b 100644
--- a/share/ruby-build/1.9.2-p320
+++ b/share/ruby-build/1.9.2-p320
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.2-p320" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p320.tar.gz#5ef5d9c07af207710bd9c2ad1cef4b42"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.2-p320" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p320.tar.gz#5ef5d9c07af207710bd9c2ad1cef4b42"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.2-p326 b/share/ruby-build/1.9.2-p326
new file mode 100644
index 0000000..5171a3e
--- /dev/null
+++ b/share/ruby-build/1.9.2-p326
@@ -0,0 +1,4 @@
+require_gcc
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_svn "ruby-1.9.2-p326" "http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_2" "44353" autoconf standard
+install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.3-dev b/share/ruby-build/1.9.3-dev
index 39fce63..6e53fb4 100644
--- a/share/ruby-build/1.9.3-dev
+++ b/share/ruby-build/1.9.3-dev
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_git "ruby-1.9.3-dev" "https://github.com/ruby/ruby.git" "ruby_1_9_3" autoconf standard
diff --git a/share/ruby-build/1.9.3-p0 b/share/ruby-build/1.9.3-p0
index 013c886..ec24df5 100644
--- a/share/ruby-build/1.9.3-p0
+++ b/share/ruby-build/1.9.3-p0
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p0" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz#8e2fef56185cfbaf29d0c8329fc77c05"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p0" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz#8e2fef56185cfbaf29d0c8329fc77c05"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.3-p125 b/share/ruby-build/1.9.3-p125
index 3dd8957..0dc1734 100644
--- a/share/ruby-build/1.9.3-p125
+++ b/share/ruby-build/1.9.3-p125
@@ -1,4 +1,4 @@
[ -n "$CC" ] || export CC=cc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p125" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz#e3ea86b9d3fc2d3ec867f66969ae3b92"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p125" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz#e3ea86b9d3fc2d3ec867f66969ae3b92"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.3-p194 b/share/ruby-build/1.9.3-p194
index 78086b0..969162a 100644
--- a/share/ruby-build/1.9.3-p194
+++ b/share/ruby-build/1.9.3-p194
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p194" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz#bc0c715c69da4d1d8bd57069c19f6c0e"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p194" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz#bc0c715c69da4d1d8bd57069c19f6c0e"
diff --git a/share/ruby-build/1.9.3-p286 b/share/ruby-build/1.9.3-p286
index 7f8e033..c7ffe14 100644
--- a/share/ruby-build/1.9.3-p286
+++ b/share/ruby-build/1.9.3-p286
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p286" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz#e2469b55c2a3d0d643097d47fe4984bb"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p286" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p286.tar.gz#e2469b55c2a3d0d643097d47fe4984bb"
diff --git a/share/ruby-build/1.9.3-p327 b/share/ruby-build/1.9.3-p327
index d5750ad..50bbbef 100644
--- a/share/ruby-build/1.9.3-p327
+++ b/share/ruby-build/1.9.3-p327
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p327" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz#96118e856b502b5d7b3a4398e6c6e98c"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p327" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz#96118e856b502b5d7b3a4398e6c6e98c"
diff --git a/share/ruby-build/1.9.3-p362 b/share/ruby-build/1.9.3-p362
index 47e542c..50e40f2 100644
--- a/share/ruby-build/1.9.3-p362
+++ b/share/ruby-build/1.9.3-p362
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p362" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p362.tar.gz#1efc2316dc50e97591792d90647fade2"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p362" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p362.tar.gz#1efc2316dc50e97591792d90647fade2"
diff --git a/share/ruby-build/1.9.3-p374 b/share/ruby-build/1.9.3-p374
index e3a4494..df80255 100644
--- a/share/ruby-build/1.9.3-p374
+++ b/share/ruby-build/1.9.3-p374
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p374" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz#90b6c327abcdf30a954c2d6ae44da2a9"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p374" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz#90b6c327abcdf30a954c2d6ae44da2a9"
diff --git a/share/ruby-build/1.9.3-p385 b/share/ruby-build/1.9.3-p385
index 412c5e5..4dfe84a 100644
--- a/share/ruby-build/1.9.3-p385
+++ b/share/ruby-build/1.9.3-p385
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p385" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p385.tar.gz#3e0d7f8512400c1a6732327728a56f1d"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p385" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p385.tar.gz#3e0d7f8512400c1a6732327728a56f1d"
diff --git a/share/ruby-build/1.9.3-p392 b/share/ruby-build/1.9.3-p392
index d76a578..43258d8 100644
--- a/share/ruby-build/1.9.3-p392
+++ b/share/ruby-build/1.9.3-p392
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-p392" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz#f689a7b61379f83cbbed3c7077d83859"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p392" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz#f689a7b61379f83cbbed3c7077d83859"
diff --git a/share/ruby-build/1.9.3-p429 b/share/ruby-build/1.9.3-p429
new file mode 100644
index 0000000..034b65a
--- /dev/null
+++ b/share/ruby-build/1.9.3-p429
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p429" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p429.tar.gz#993c72f7f805a9eb453f90b0b7fe0d2b"
diff --git a/share/ruby-build/1.9.3-p448 b/share/ruby-build/1.9.3-p448
new file mode 100644
index 0000000..e1a9e3f
--- /dev/null
+++ b/share/ruby-build/1.9.3-p448
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p448" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz#a893cff26bcf351b8975ebf2a63b1023"
diff --git a/share/ruby-build/1.9.3-p484 b/share/ruby-build/1.9.3-p484
new file mode 100644
index 0000000..eddf4af
--- /dev/null
+++ b/share/ruby-build/1.9.3-p484
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p484" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz#8ac0dee72fe12d75c8b2d0ef5d0c2968"
diff --git a/share/ruby-build/1.9.3-p545 b/share/ruby-build/1.9.3-p545
new file mode 100644
index 0000000..5b75e06
--- /dev/null
+++ b/share/ruby-build/1.9.3-p545
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-p545" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p545.tar.gz#8e8f6e4d7d0bb54e0edf8d9c4120f40c"
diff --git a/share/ruby-build/1.9.3-preview1 b/share/ruby-build/1.9.3-preview1
index dc57cb7..e2e8b2f 100644
--- a/share/ruby-build/1.9.3-preview1
+++ b/share/ruby-build/1.9.3-preview1
@@ -1,4 +1,4 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-preview1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-preview1.tar.gz#0f0220be4cc7c51a82c1bd8f6a0969f3"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-preview1" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-preview1.tar.gz#0f0220be4cc7c51a82c1bd8f6a0969f3"
install_package "rubygems-1.8.23" "http://production.cf.rubygems.org/rubygems/rubygems-1.8.23.tgz#178b0ebae78dbb46963c51ad29bb6bd9" ruby
diff --git a/share/ruby-build/1.9.3-rc1 b/share/ruby-build/1.9.3-rc1
index 39fbf30..65c747f 100644
--- a/share/ruby-build/1.9.3-rc1
+++ b/share/ruby-build/1.9.3-rc1
@@ -1,3 +1,3 @@
require_gcc
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-1.9.3-rc1" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-rc1.tar.gz#46a2a481536ca0ca0b80ad2b091df68e"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-1.9.3-rc1" "http://cache.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-rc1.tar.gz#46a2a481536ca0ca0b80ad2b091df68e"
diff --git a/share/ruby-build/2.0.0-p0 b/share/ruby-build/2.0.0-p0
index 1c48a46..9495677 100644
--- a/share/ruby-build/2.0.0-p0
+++ b/share/ruby-build/2.0.0-p0
@@ -1,2 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-p0" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz#50d307c4dc9297ae59952527be4e755d" standard verify_openssl
+install_package "ruby-2.0.0-p0" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz#50d307c4dc9297ae59952527be4e755d" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-p195 b/share/ruby-build/2.0.0-p195
new file mode 100644
index 0000000..031d811
--- /dev/null
+++ b/share/ruby-build/2.0.0-p195
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.0.0-p195" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p195.tar.gz#0672e5af309ae99d1703d0e96eff8ea5" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-p247 b/share/ruby-build/2.0.0-p247
new file mode 100644
index 0000000..209ef5f
--- /dev/null
+++ b/share/ruby-build/2.0.0-p247
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.0.0-p247" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz#c351450a0bed670e0f5ca07da3458a5b" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-p353 b/share/ruby-build/2.0.0-p353
new file mode 100644
index 0000000..47d787c
--- /dev/null
+++ b/share/ruby-build/2.0.0-p353
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.0.0-p353" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz#78282433fb697dd3613613ff55d734c1" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-p0 b/share/ruby-build/2.0.0-p451
similarity index 50%
copy from share/ruby-build/2.0.0-p0
copy to share/ruby-build/2.0.0-p451
index 1c48a46..318005e 100644
--- a/share/ruby-build/2.0.0-p0
+++ b/share/ruby-build/2.0.0-p451
@@ -1,2 +1,2 @@
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-p0" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz#50d307c4dc9297ae59952527be4e755d" standard verify_openssl
+install_package "ruby-2.0.0-p451" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p451.tar.gz#9227787a9636551f1749ee8394b5ffe5" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-preview1 b/share/ruby-build/2.0.0-preview1
index 0d3d1e9..668214e 100644
--- a/share/ruby-build/2.0.0-preview1
+++ b/share/ruby-build/2.0.0-preview1
@@ -1,3 +1,3 @@
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
-install_package "ruby-2.0.0-preview1" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-preview1.tar.gz#c7d73f3ddb6d25e7733626ddbad04158" standard verify_openssl
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "ruby-2.0.0-preview1" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-preview1.tar.gz#c7d73f3ddb6d25e7733626ddbad04158" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-preview2 b/share/ruby-build/2.0.0-preview2
index 70c5870..226f9df 100644
--- a/share/ruby-build/2.0.0-preview2
+++ b/share/ruby-build/2.0.0-preview2
@@ -1,2 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-preview2" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-preview2.tar.gz#eaddcbf63dc775708de45c7a81ab54b9" standard verify_openssl
+install_package "ruby-2.0.0-preview2" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-preview2.tar.gz#eaddcbf63dc775708de45c7a81ab54b9" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-rc1 b/share/ruby-build/2.0.0-rc1
index 4687b02..581d062 100644
--- a/share/ruby-build/2.0.0-rc1
+++ b/share/ruby-build/2.0.0-rc1
@@ -1,2 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-rc1" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc1.tar.gz#7d587dde85e0edf7a2e4f6783e6c0e2e" standard verify_openssl
+install_package "ruby-2.0.0-rc1" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc1.tar.gz#7d587dde85e0edf7a2e4f6783e6c0e2e" standard verify_openssl
diff --git a/share/ruby-build/2.0.0-rc2 b/share/ruby-build/2.0.0-rc2
index ac2e103..b2ca161 100644
--- a/share/ruby-build/2.0.0-rc2
+++ b/share/ruby-build/2.0.0-rc2
@@ -1,2 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-rc2" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc2.tar.gz#9d5e6f26db7c8c3ddefc81fdb19bd41a" standard verify_openssl
+install_package "ruby-2.0.0-rc2" "http://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc2.tar.gz#9d5e6f26db7c8c3ddefc81fdb19bd41a" standard verify_openssl
diff --git a/share/ruby-build/2.1.0 b/share/ruby-build/2.1.0
new file mode 100644
index 0000000..97cbe61
--- /dev/null
+++ b/share/ruby-build/2.1.0
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.1.0" "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0.tar.gz#9e6386d53f5200a3e7069107405b93f7" ldflags_dirs standard verify_openssl
diff --git a/share/ruby-build/2.1.0-dev b/share/ruby-build/2.1.0-dev
index 04dcb97..a928605 100644
--- a/share/ruby-build/2.1.0-dev
+++ b/share/ruby-build/2.1.0-dev
@@ -1,2 +1,2 @@
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_git "ruby-2.1.0-dev" "https://github.com/ruby/ruby.git" "trunk" autoconf standard verify_openssl
+install_git "ruby-2.1.0-dev" "https://github.com/ruby/ruby.git" "ruby_2_1" ldflags_dirs autoconf standard verify_openssl
diff --git a/share/ruby-build/2.1.0-preview1 b/share/ruby-build/2.1.0-preview1
new file mode 100644
index 0000000..969a37c
--- /dev/null
+++ b/share/ruby-build/2.1.0-preview1
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.1.0-preview1" "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0-preview1.tar.gz#9df4f546f6b961895ba58a8afdf857da" standard verify_openssl
diff --git a/share/ruby-build/2.1.0-preview2 b/share/ruby-build/2.1.0-preview2
new file mode 100644
index 0000000..c67f92f
--- /dev/null
+++ b/share/ruby-build/2.1.0-preview2
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.1.0-preview2" "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0-preview2.tar.gz#ba2b95d174e156b417a4d580a452eaf5" ldflags_dirs standard verify_openssl
diff --git a/share/ruby-build/2.1.0-rc1 b/share/ruby-build/2.1.0-rc1
new file mode 100644
index 0000000..6c2f865
--- /dev/null
+++ b/share/ruby-build/2.1.0-rc1
@@ -0,0 +1,3 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
+install_package "ruby-2.1.0-rc1" "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.0-rc1.tar.gz#a16561f64d78a902fab08693a300df98" ldflags_dirs standard verify_openssl
diff --git a/share/ruby-build/2.0.0-p0 b/share/ruby-build/2.1.1
similarity index 50%
copy from share/ruby-build/2.0.0-p0
copy to share/ruby-build/2.1.1
index 1c48a46..b1b400a 100644
--- a/share/ruby-build/2.0.0-p0
+++ b/share/ruby-build/2.1.1
@@ -1,2 +1,2 @@
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_package "ruby-2.0.0-p0" "http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz#50d307c4dc9297ae59952527be4e755d" standard verify_openssl
+install_package "ruby-2.1.1" "http://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.1.tar.gz#e57fdbb8ed56e70c43f39c79da1654b2" ldflags_dirs standard verify_openssl
diff --git a/share/ruby-build/2.1.0-dev b/share/ruby-build/2.2.0-dev
similarity index 57%
copy from share/ruby-build/2.1.0-dev
copy to share/ruby-build/2.2.0-dev
index 04dcb97..0ca95f6 100644
--- a/share/ruby-build/2.1.0-dev
+++ b/share/ruby-build/2.2.0-dev
@@ -1,2 +1,2 @@
install_package "openssl-1.0.1e" "https://www.openssl.org/source/openssl-1.0.1e.tar.gz#66bf6f10f060d561929de96f9dfe5b8c" mac_openssl --if has_broken_mac_openssl
-install_git "ruby-2.1.0-dev" "https://github.com/ruby/ruby.git" "trunk" autoconf standard verify_openssl
+install_git "ruby-2.2.0-dev" "https://github.com/ruby/ruby.git" "trunk" ldflags_dirs autoconf standard verify_openssl
diff --git a/share/ruby-build/jruby-1.7.10 b/share/ruby-build/jruby-1.7.10
new file mode 100644
index 0000000..4afbe0f
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.10
@@ -0,0 +1 @@
+install_package "jruby-1.7.10" "http://jruby.org.s3.amazonaws.com/downloads/1.7.10/jruby-bin-1.7.10.tar.gz#c84fe9245a73f9cd29f56343b7d2e39a" jruby
diff --git a/share/ruby-build/jruby-1.7.4 b/share/ruby-build/jruby-1.7.4
new file mode 100644
index 0000000..ade1d3b
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.4
@@ -0,0 +1 @@
+install_package "jruby-1.7.4" "http://jruby.org.s3.amazonaws.com/downloads/1.7.4/jruby-bin-1.7.4.tar.gz#c6a56eae78db28dddba911ccd0848c32" jruby
diff --git a/share/ruby-build/jruby-1.7.5 b/share/ruby-build/jruby-1.7.5
new file mode 100644
index 0000000..e95526a
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.5
@@ -0,0 +1 @@
+install_package "jruby-1.7.5" "http://jruby.org.s3.amazonaws.com/downloads/1.7.5/jruby-bin-1.7.5.tar.gz#c2a28c43c8095127d4a4aee0cf9b1439" jruby
diff --git a/share/ruby-build/jruby-1.7.6 b/share/ruby-build/jruby-1.7.6
new file mode 100644
index 0000000..b066f8c
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.6
@@ -0,0 +1 @@
+install_package "jruby-1.7.6" "http://jruby.org.s3.amazonaws.com/downloads/1.7.6/jruby-bin-1.7.6.tar.gz#5d10011516a3d3bde10209b60cfcc0ef" jruby
diff --git a/share/ruby-build/jruby-1.7.7 b/share/ruby-build/jruby-1.7.7
new file mode 100644
index 0000000..de5f045
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.7
@@ -0,0 +1 @@
+install_package "jruby-1.7.7" "http://jruby.org.s3.amazonaws.com/downloads/1.7.7/jruby-bin-1.7.7.tar.gz#9d6df2188fa57f12bf6fde4e4b2e3f09" jruby
diff --git a/share/ruby-build/jruby-1.7.8 b/share/ruby-build/jruby-1.7.8
new file mode 100644
index 0000000..c8d671f
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.8
@@ -0,0 +1 @@
+install_package "jruby-1.7.8" "http://jruby.org.s3.amazonaws.com/downloads/1.7.8/jruby-bin-1.7.8.tar.gz#1e68f39d6dba7b6d9db81e24bb6b7d0a" jruby
diff --git a/share/ruby-build/jruby-1.7.9 b/share/ruby-build/jruby-1.7.9
new file mode 100644
index 0000000..9c67be9
--- /dev/null
+++ b/share/ruby-build/jruby-1.7.9
@@ -0,0 +1 @@
+install_package "jruby-1.7.9" "http://jruby.org.s3.amazonaws.com/downloads/1.7.9/jruby-bin-1.7.9.tar.gz#b2e44f1f44837c07068ee453a89f4b55" jruby
diff --git a/share/ruby-build/jruby-9000-dev b/share/ruby-build/jruby-9000-dev
new file mode 100644
index 0000000..7562193
--- /dev/null
+++ b/share/ruby-build/jruby-9000-dev
@@ -0,0 +1,2 @@
+require_java7
+install_package "jruby-9000.dev" "http://ci.jruby.org/snapshots/master/jruby-dist-9000.dev-bin.tar.gz" jruby
diff --git a/share/ruby-build/maglev-2.0.0-dev b/share/ruby-build/maglev-2.0.0-dev
new file mode 100644
index 0000000..87a1103
--- /dev/null
+++ b/share/ruby-build/maglev-2.0.0-dev
@@ -0,0 +1 @@
+install_git "maglev-2.0.0-dev" "https://github.com/MagLev/maglev.git" "master" maglev
diff --git a/share/ruby-build/mruby-1.0.0 b/share/ruby-build/mruby-1.0.0
new file mode 100644
index 0000000..d8b3e08
--- /dev/null
+++ b/share/ruby-build/mruby-1.0.0
@@ -0,0 +1 @@
+install_package "mruby-1.0.0" "https://github.com/mruby/mruby/archive/1.0.0.tar.gz" mruby
diff --git a/share/ruby-build/mruby-dev b/share/ruby-build/mruby-dev
new file mode 100644
index 0000000..2093df2
--- /dev/null
+++ b/share/ruby-build/mruby-dev
@@ -0,0 +1 @@
+install_git "mruby-dev" "https://github.com/mruby/mruby.git" "master" mruby
diff --git a/share/ruby-build/rbx-2.0.0 b/share/ruby-build/rbx-2.0.0
new file mode 100644
index 0000000..cd22be4
--- /dev/null
+++ b/share/ruby-build/rbx-2.0.0
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.0.0" "http://releases.rubini.us/rubinius-2.0.0.tar.bz2#62e379e044c822b81e7b20a27daf133e" rbx
diff --git a/share/ruby-build/rbx-2.0.0-dev b/share/ruby-build/rbx-2.0.0-dev
index d4c3d27..8ceda8a 100644
--- a/share/ruby-build/rbx-2.0.0-dev
+++ b/share/ruby-build/rbx-2.0.0-dev
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_git "rubinius-2.0.0-dev" "https://github.com/rubinius/rubinius.git" "master" rbx
diff --git a/share/ruby-build/rbx-2.0.0-rc1 b/share/ruby-build/rbx-2.0.0-rc1
index 5e0b882..51f9e9e 100644
--- a/share/ruby-build/rbx-2.0.0-rc1
+++ b/share/ruby-build/rbx-2.0.0-rc1
@@ -1,2 +1,2 @@
-install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
install_package "rubinius-release-2.0.0-rc1" "https://nodeload.github.com/rubinius/rubinius/tar.gz/release-2.0.0-rc1#d9726d9eb34c861b9f6596bf478a3116" rbx
diff --git a/share/ruby-build/rbx-2.1.0 b/share/ruby-build/rbx-2.1.0
new file mode 100644
index 0000000..cafda2f
--- /dev/null
+++ b/share/ruby-build/rbx-2.1.0
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.1.0" "http://releases.rubini.us/rubinius-2.1.0.tar.bz2#908053f38fd840c75a93aab7487c20a5" rbx
diff --git a/share/ruby-build/rbx-2.1.1 b/share/ruby-build/rbx-2.1.1
new file mode 100644
index 0000000..7aea0cd
--- /dev/null
+++ b/share/ruby-build/rbx-2.1.1
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.1.1" "http://releases.rubini.us/rubinius-2.1.1.tar.bz2#6b4df0caec5ea88373e113f97a3b4c72" rbx
diff --git a/share/ruby-build/rbx-2.2.0 b/share/ruby-build/rbx-2.2.0
new file mode 100644
index 0000000..4bb32af
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.0
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.0" "http://releases.rubini.us/rubinius-2.2.0.tar.bz2#f1fbc6f3baf1da5ad86b3858f30f3349" rbx
diff --git a/share/ruby-build/rbx-2.2.1 b/share/ruby-build/rbx-2.2.1
new file mode 100644
index 0000000..92a0ff6
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.1
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.1" "http://releases.rubini.us/rubinius-2.2.1.tar.bz2#83c4d61d5fdb070d11babd867852277b" rbx
diff --git a/share/ruby-build/rbx-2.2.2 b/share/ruby-build/rbx-2.2.2
new file mode 100644
index 0000000..b3ba1c6
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.2
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.2" "http://releases.rubini.us/rubinius-2.2.2.tar.bz2#ac70d629ea43525d91e81f4ccf135299" rbx
diff --git a/share/ruby-build/rbx-2.2.3 b/share/ruby-build/rbx-2.2.3
new file mode 100644
index 0000000..b07795a
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.3
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.3" "http://releases.rubini.us/rubinius-2.2.3.tar.bz2#d9978cf1a4e8f0310db63e49834f9837" rbx
diff --git a/share/ruby-build/rbx-2.2.4 b/share/ruby-build/rbx-2.2.4
new file mode 100644
index 0000000..59b72b8
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.4
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.4" "http://releases.rubini.us/rubinius-2.2.4.tar.bz2#c10699da85a8eb5861a37b29077213bd" rbx
diff --git a/share/ruby-build/rbx-2.2.5 b/share/ruby-build/rbx-2.2.5
new file mode 100644
index 0000000..f536f01
--- /dev/null
+++ b/share/ruby-build/rbx-2.2.5
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz#24f6093c1e840ca5df2eb09291a1dbf1" --if needs_yaml
+install_package "rubinius-2.2.5" "http://releases.rubini.us/rubinius-2.2.5.tar.bz2" rbx
diff --git a/share/ruby-build/topaz-dev b/share/ruby-build/topaz-dev
new file mode 100644
index 0000000..c6b4d03
--- /dev/null
+++ b/share/ruby-build/topaz-dev
@@ -0,0 +1 @@
+install_package topaz "http://topazruby.com/builds/$(topaz_architecture)/latest/?_=.tar.bz2" topaz
diff --git a/test/build.bats b/test/build.bats
new file mode 100644
index 0000000..1d15b18
--- /dev/null
+++ b/test/build.bats
@@ -0,0 +1,482 @@
+#!/usr/bin/env bats
+
+load test_helper
+export RUBY_BUILD_CACHE_PATH="$TMP/cache"
+export MAKE=make
+export MAKE_OPTS="-j 2"
+
+setup() {
+ mkdir -p "$INSTALL_ROOT"
+ stub md5 false
+ stub curl false
+}
+
+executable() {
+ local file="$1"
+ mkdir -p "${file%/*}"
+ cat > "$file"
+ chmod +x "$file"
+}
+
+cached_tarball() {
+ mkdir -p "$RUBY_BUILD_CACHE_PATH"
+ pushd "$RUBY_BUILD_CACHE_PATH" >/dev/null
+ tarball "$@"
+ popd >/dev/null
+}
+
+tarball() {
+ local name="$1"
+ local path="$PWD/$name"
+ local configure="$path/configure"
+ shift 1
+
+ executable "$configure" <<OUT
+#!$BASH
+echo "$name: \$@" \${RUBYOPT:+RUBYOPT=\$RUBYOPT} >> build.log
+OUT
+
+ for file; do
+ mkdir -p "$(dirname "${path}/${file}")"
+ touch "${path}/${file}"
+ done
+
+ tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
+}
+
+stub_make_install() {
+ stub "$MAKE" \
+ " : echo \"$MAKE \$@\" >> build.log" \
+ "install : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'"
+}
+
+assert_build_log() {
+ run cat "$INSTALL_ROOT/build.log"
+ assert_output
+}
+
+ at test "yaml is installed for ruby" {
+ cached_tarball "yaml-0.1.5"
+ cached_tarball "ruby-2.0.0"
+
+ stub brew false
+ stub_make_install
+ stub_make_install
+
+ install_fixture definitions/needs-yaml
+ assert_success
+
+ unstub make
+
+ assert_build_log <<OUT
+yaml-0.1.5: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+OUT
+}
+
+ at test "apply ruby patch before building" {
+ cached_tarball "yaml-0.1.5"
+ cached_tarball "ruby-2.0.0"
+
+ stub brew false
+ stub_make_install
+ stub_make_install
+ stub patch ' : echo patch "$@" >> build.log'
+
+ install_fixture --patch definitions/needs-yaml
+ assert_success
+
+ unstub make
+ unstub patch
+
+ assert_build_log <<OUT
+yaml-0.1.5: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+patch -p0 -i -
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+OUT
+}
+
+ at test "yaml is linked from Homebrew" {
+ cached_tarball "ruby-2.0.0"
+
+ brew_libdir="$TMP/homebrew-yaml"
+ mkdir -p "$brew_libdir"
+
+ stub brew "--prefix libyaml : echo '$brew_libdir'" false
+ stub_make_install
+
+ install_fixture definitions/needs-yaml
+ assert_success
+
+ unstub brew
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT --with-libyaml-dir=$brew_libdir
+make -j 2
+make install
+OUT
+}
+
+ at test "readline is linked from Homebrew" {
+ cached_tarball "ruby-2.0.0"
+
+ readline_libdir="$TMP/homebrew-readline"
+ mkdir -p "$readline_libdir"
+
+ stub brew "--prefix readline : echo '$readline_libdir'"
+ stub_make_install
+
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub brew
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT --with-readline-dir=$readline_libdir
+make -j 2
+make install
+OUT
+}
+
+ at test "readline is not linked from Homebrew when explicitly defined" {
+ cached_tarball "ruby-2.0.0"
+
+ stub brew
+ stub_make_install
+
+ export RUBY_CONFIGURE_OPTS='--with-readline-dir=/custom'
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub brew
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT --with-readline-dir=/custom
+make -j 2
+make install
+OUT
+}
+
+ at test "number of CPU cores defaults to 2" {
+ cached_tarball "ruby-2.0.0"
+
+ stub uname '-s : echo Darwin'
+ stub sysctl false
+ stub_make_install
+
+ export -n MAKE_OPTS
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub uname
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+OUT
+}
+
+ at test "number of CPU cores is detected on Mac" {
+ cached_tarball "ruby-2.0.0"
+
+ stub uname '-s : echo Darwin'
+ stub sysctl '-n hw.ncpu : echo 4'
+ stub_make_install
+
+ export -n MAKE_OPTS
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub uname
+ unstub sysctl
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 4
+make install
+OUT
+}
+
+ at test "setting RUBY_MAKE_INSTALL_OPTS to a multi-word string" {
+ cached_tarball "ruby-2.0.0"
+
+ stub_make_install
+
+ export RUBY_MAKE_INSTALL_OPTS="DOGE=\"such wow\""
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install DOGE="such wow"
+OUT
+}
+
+ at test "setting MAKE_INSTALL_OPTS to a multi-word string" {
+ cached_tarball "ruby-2.0.0"
+
+ stub_make_install
+
+ export MAKE_INSTALL_OPTS="DOGE=\"such wow\""
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub make
+
+ assert_build_log <<OUT
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install DOGE="such wow"
+OUT
+}
+
+ at test "custom relative install destination" {
+ export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT"
+
+ cd "$TMP"
+ install_fixture definitions/without-checksum ./here
+ assert_success
+ assert [ -x ./here/bin/package ]
+}
+
+ at test "make on FreeBSD defaults to gmake" {
+ cached_tarball "ruby-2.0.0"
+
+ stub uname "-s : echo FreeBSD"
+ MAKE=gmake stub_make_install
+
+ MAKE= install_fixture definitions/vanilla-ruby
+ assert_success
+
+ unstub gmake
+ unstub uname
+}
+
+ at test "can use RUBY_CONFIGURE to apply a patch" {
+ cached_tarball "ruby-2.0.0"
+
+ executable "${TMP}/custom-configure" <<CONF
+#!$BASH
+apply -p1 -i /my/patch.diff
+exec ./configure "\$@"
+CONF
+
+ stub apply 'echo apply "$@" >> build.log'
+ stub_make_install
+
+ export RUBY_CONFIGURE="${TMP}/custom-configure"
+ run_inline_definition <<DEF
+install_package "ruby-2.0.0" "http://ruby-lang.org/pub/ruby-2.0.0.tar.gz"
+DEF
+ assert_success
+
+ unstub make
+ unstub apply
+
+ assert_build_log <<OUT
+apply -p1 -i /my/patch.diff
+ruby-2.0.0: --prefix=$INSTALL_ROOT
+make -j 2
+make install
+OUT
+}
+
+ at test "copy strategy forces overwrite" {
+ export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT"
+
+ mkdir -p "$INSTALL_ROOT/bin"
+ touch "$INSTALL_ROOT/bin/package"
+ chmod -w "$INSTALL_ROOT/bin/package"
+
+ install_fixture definitions/without-checksum
+ assert_success
+
+ run "$INSTALL_ROOT/bin/package" "world"
+ assert_success "hello world"
+}
+
+ at test "mruby strategy overwrites non-writable files" {
+ cached_tarball "mruby-1.0" build/host/bin/{mruby,mirb}
+
+ mkdir -p "$INSTALL_ROOT/bin"
+ touch "$INSTALL_ROOT/bin/mruby"
+ chmod -w "$INSTALL_ROOT/bin/mruby"
+
+ stub gem false
+ stub rake '--version : echo 1' true
+
+ run_inline_definition <<DEF
+install_package "mruby-1.0" "http://ruby-lang.org/pub/mruby-1.0.tar.gz" mruby
+DEF
+ assert_success
+
+ unstub rake
+
+ assert [ -w "$INSTALL_ROOT/bin/mruby" ]
+ assert [ -e "$INSTALL_ROOT/bin/ruby" ]
+ assert [ -e "$INSTALL_ROOT/bin/irb" ]
+}
+
+ at test "mruby strategy fetches rake if missing" {
+ cached_tarball "mruby-1.0" build/host/bin/mruby
+
+ stub rake '--version : false' true
+ stub gem 'install rake -v *10.1.0 : true'
+
+ run_inline_definition <<DEF
+install_package "mruby-1.0" "http://ruby-lang.org/pub/mruby-1.0.tar.gz" mruby
+DEF
+ assert_success
+
+ unstub gem
+ unstub rake
+}
+
+ at test "rbx uses bundle then rake" {
+ cached_tarball "rubinius-2.0.0" "Gemfile"
+
+ stub gem false
+ stub rake false
+ stub bundle \
+ '--version : echo 1' \
+ ' : echo bundle "$@" >> build.log' \
+ '--version : echo 1' \
+ " exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'"
+
+ run_inline_definition <<DEF
+install_package "rubinius-2.0.0" "http://releases.rubini.us/rubinius-2.0.0.tar.gz" rbx
+DEF
+ assert_success
+
+ unstub bundle
+
+ assert_build_log <<OUT
+bundle --path=vendor/bundle
+rubinius-2.0.0: --prefix=$INSTALL_ROOT RUBYOPT=-rubygems
+bundle exec rake install
+OUT
+}
+
+ at test "JRuby build" {
+ executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/jruby" <<OUT
+#!${BASH}
+echo jruby "\$@" >> ../build.log
+OUT
+ executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/gem" <<OUT
+#!/usr/bin/env jruby
+nice gem things
+OUT
+ cached_tarball "jruby-1.7.9" bin/foo.exe bin/bar.dll bin/baz.bat
+
+ run_inline_definition <<DEF
+install_package "jruby-1.7.9" "http://jruby.org/downloads/jruby-bin-1.7.9.tar.gz" jruby
+DEF
+ assert_success
+
+ assert_build_log <<OUT
+jruby gem install jruby-launcher
+OUT
+
+ run ls "${INSTALL_ROOT}/bin"
+ assert_output <<OUT
+gem
+jruby
+ruby
+OUT
+
+ assert [ -x "${INSTALL_ROOT}/bin/gem" ]
+ run cat "${INSTALL_ROOT}/bin/gem"
+ assert_output <<OUT
+#!${INSTALL_ROOT}/bin/jruby
+nice gem things
+OUT
+}
+
+ at test "JRuby Java 7 missing" {
+ cached_tarball "jruby-9000.dev" bin/jruby
+
+ stub java false
+
+ run_inline_definition <<DEF
+require_java7
+install_package "jruby-9000.dev" "http://ci.jruby.org/jruby-dist-9000.dev-bin.tar.gz" jruby
+DEF
+ assert_failure <<OUT
+ERROR: Java 7 required. Please install a 1.7-compatible JRE.
+OUT
+}
+
+ at test "JRuby Java is outdated" {
+ cached_tarball "jruby-9000.dev" bin/jruby
+
+ stub java '-version : echo java version "1.6.0_21" >&2'
+
+ run_inline_definition <<DEF
+require_java7
+install_package "jruby-9000.dev" "http://ci.jruby.org/jruby-dist-9000.dev-bin.tar.gz" jruby
+DEF
+ assert_failure <<OUT
+ERROR: Java 7 required. Please install a 1.7-compatible JRE.
+OUT
+}
+
+ at test "JRuby Java 7 up-to-date" {
+ cached_tarball "jruby-9000.dev" bin/jruby
+
+ stub java '-version : echo java version "1.7.0_21" >&2'
+
+ run_inline_definition <<DEF
+require_java7
+install_package "jruby-9000.dev" "http://ci.jruby.org/jruby-dist-9000.dev-bin.tar.gz" jruby
+DEF
+ assert_success
+}
+
+ at test "non-writable TMPDIR aborts build" {
+ export TMPDIR="${TMP}/build"
+ mkdir -p "$TMPDIR"
+ chmod -w "$TMPDIR"
+
+ touch "${TMP}/build-definition"
+ run ruby-build "${TMP}/build-definition" "$INSTALL_ROOT"
+ assert_failure "ruby-build: TMPDIR=$TMPDIR is set to a non-accessible location"
+}
+
+ at test "non-executable TMPDIR aborts build" {
+ export TMPDIR="${TMP}/build"
+ mkdir -p "$TMPDIR"
+ chmod -x "$TMPDIR"
+
+ touch "${TMP}/build-definition"
+ run ruby-build "${TMP}/build-definition" "$INSTALL_ROOT"
+ assert_failure "ruby-build: TMPDIR=$TMPDIR is set to a non-accessible location"
+}
diff --git a/test/cache.bats b/test/cache.bats
index e377d4d..8c71c35 100644
--- a/test/cache.bats
+++ b/test/cache.bats
@@ -11,7 +11,7 @@ setup() {
@test "packages are saved to download cache" {
stub md5 true
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
@@ -58,7 +58,8 @@ setup() {
local checksum="83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo invalid" "echo $checksum"
- stub curl "-*I* : true" "-*S* http://?*/$checksum : cat package-1.0.0.tar.gz"
+ stub curl "-*I* : true" \
+ "-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
@@ -75,7 +76,7 @@ setup() {
@test "nonexistent cache directory is ignored" {
stub md5 true
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
diff --git a/test/checksum.bats b/test/checksum.bats
index a064194..3c4ffc3 100644
--- a/test/checksum.bats
+++ b/test/checksum.bats
@@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL without checksum" {
stub md5 true
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
@@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with valid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
@@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with invalid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-invalid-checksum
[ "$status" -eq 1 ]
@@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with checksum but no MD5 support" {
stub md5 false
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
@@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package with invalid checksum" {
stub md5 true "echo invalid"
- stub curl "-*S* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 1 ]
diff --git a/test/fetch.bats b/test/fetch.bats
new file mode 100644
index 0000000..f2babd5
--- /dev/null
+++ b/test/fetch.bats
@@ -0,0 +1,14 @@
+#!/usr/bin/env bats
+
+load test_helper
+export RUBY_BUILD_SKIP_MIRROR=1
+export RUBY_BUILD_CACHE_PATH=
+
+ at test "failed download displays error message" {
+ stub curl false
+
+ install_fixture definitions/without-checksum
+ assert_failure
+ assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz"
+ assert_output_contains "error: failed to download package-1.0.0.tar.gz"
+}
diff --git a/test/fixtures/definitions/needs-yaml b/test/fixtures/definitions/needs-yaml
new file mode 100644
index 0000000..b63728f
--- /dev/null
+++ b/test/fixtures/definitions/needs-yaml
@@ -0,0 +1,2 @@
+install_package "yaml-0.1.5" "http://pyyaml.org/download/libyaml/yaml-0.1.5.tar.gz" --if needs_yaml
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
diff --git a/test/fixtures/definitions/vanilla-ruby b/test/fixtures/definitions/vanilla-ruby
new file mode 100644
index 0000000..2cfe97b
--- /dev/null
+++ b/test/fixtures/definitions/vanilla-ruby
@@ -0,0 +1 @@
+install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
diff --git a/test/hooks.bats b/test/hooks.bats
new file mode 100644
index 0000000..a09f189
--- /dev/null
+++ b/test/hooks.bats
@@ -0,0 +1,56 @@
+#!/usr/bin/env bats
+
+load test_helper
+
+setup() {
+ export RBENV_ROOT="${TMP}/rbenv"
+ export HOOK_PATH="${TMP}/i has hooks"
+ mkdir -p "$HOOK_PATH"
+}
+
+ at test "rbenv-install hooks" {
+ cat > "${HOOK_PATH}/install.bash" <<OUT
+before_install 'echo before: \$PREFIX'
+after_install 'echo after: \$STATUS'
+OUT
+ stub rbenv-hooks "install : echo '$HOOK_PATH'/install.bash"
+ stub rbenv-rehash "echo rehashed"
+
+ definition="${TMP}/2.0.0"
+ cat > "$definition" <<<"echo ruby-build"
+ run rbenv-install "$definition"
+
+ assert_success
+ assert_output <<-OUT
+before: ${RBENV_ROOT}/versions/2.0.0
+ruby-build
+after: 0
+rehashed
+OUT
+}
+
+ at test "rbenv-uninstall hooks" {
+ cat > "${HOOK_PATH}/uninstall.bash" <<OUT
+before_uninstall 'echo before: \$PREFIX'
+after_uninstall 'echo after.'
+rm() {
+ echo "rm \$@"
+ command rm "\$@"
+}
+OUT
+ stub rbenv-hooks "uninstall : echo '$HOOK_PATH'/uninstall.bash"
+ stub rbenv-rehash "echo rehashed"
+
+ mkdir -p "${RBENV_ROOT}/versions/2.0.0"
+ run rbenv-uninstall -f 2.0.0
+
+ assert_success
+ assert_output <<-OUT
+before: ${RBENV_ROOT}/versions/2.0.0
+rm -rf ${RBENV_ROOT}/versions/2.0.0
+rehashed
+after.
+OUT
+
+ assert [ ! -d "${RBENV_ROOT}/versions/2.0.0" ]
+}
diff --git a/test/installer.bats b/test/installer.bats
new file mode 100644
index 0000000..15a141d
--- /dev/null
+++ b/test/installer.bats
@@ -0,0 +1,61 @@
+#!/usr/bin/env bats
+
+load test_helper
+
+ at test "installs ruby-build into PREFIX" {
+ cd "$TMP"
+ PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
+ assert_success ""
+
+ cd usr
+
+ assert [ -x bin/ruby-build ]
+ assert [ -x bin/rbenv-install ]
+ assert [ -x bin/rbenv-uninstall ]
+
+ assert [ -e share/ruby-build/1.8.6-p383 ]
+ assert [ -e share/ruby-build/ree-1.8.7-2012.02 ]
+}
+
+ at test "build definitions don't have the executable bit" {
+ cd "$TMP"
+ PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
+ assert_success ""
+
+ run $BASH -c 'ls -l usr/share/ruby-build | tail -2 | cut -d" " -f1'
+ assert_output <<OUT
+-rw-r--r--
+-rw-r--r--
+OUT
+}
+
+ at test "overwrites old installation" {
+ cd "$TMP"
+ mkdir -p bin share/ruby-build
+ touch bin/ruby-build
+ touch share/ruby-build/1.8.6-p383
+
+ PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
+ assert_success ""
+
+ assert [ -x bin/ruby-build ]
+ run grep "install_package" share/ruby-build/1.8.6-p383
+ assert_success
+}
+
+ at test "unrelated files are untouched" {
+ cd "$TMP"
+ mkdir -p bin share/bananas
+ chmod g-w bin
+ touch bin/bananas
+ touch share/bananas/docs
+
+ PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
+ assert_success ""
+
+ assert [ -e bin/bananas ]
+ assert [ -e share/bananas/docs ]
+
+ run ls -ld bin
+ assert_equal "r-x" "${output:4:3}"
+}
diff --git a/test/mirror.bats b/test/mirror.bats
index 9c4615f..9ec45b5 100644
--- a/test/mirror.bats
+++ b/test/mirror.bats
@@ -8,9 +8,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL without checksum bypasses mirror" {
stub md5 true
- stub curl "-*S* http://example.com/* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/without-checksum
+ echo "$output" >&2
[ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ]
@@ -21,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL with checksum but no MD5 support bypasses mirror" {
stub md5 false
- stub curl "-*S* http://example.com/* : cat package-1.0.0.tar.gz"
+ stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
@@ -37,7 +38,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
stub md5 true "echo $checksum"
- stub curl "-*I* $mirror_url : true" "-*S* $mirror_url : cat package-1.0.0.tar.gz"
+ stub curl "-*I* $mirror_url : true" \
+ "-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
@@ -51,10 +53,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package is fetched from original URL if mirror download fails" {
local checksum="83e6d7725e20166024a1eb74cde80677"
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
- local original_url="http://example.com/packages/package-1.0.0.tar.gz"
stub md5 true "echo $checksum"
- stub curl "-*I* $mirror_url : false" "-*S* $original_url : cat package-1.0.0.tar.gz"
+ stub curl "-*I* $mirror_url : false" \
+ "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
@@ -68,12 +70,14 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package is fetched from original URL if mirror download checksum is invalid" {
local checksum="83e6d7725e20166024a1eb74cde80677"
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
- local original_url="http://example.com/packages/package-1.0.0.tar.gz"
stub md5 true "echo invalid" "echo $checksum"
- stub curl "-*I* $mirror_url : true" "-*S* $mirror_url : cat package-1.0.0.tar.gz" "-*S* $original_url : cat package-1.0.0.tar.gz"
+ stub curl "-*I* $mirror_url : true" \
+ "-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
+ "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
install_fixture definitions/with-checksum
+ echo "$output" >&2
[ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ]
@@ -87,7 +91,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
local checksum="83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo $checksum"
- stub curl "-*I* : true" "-*S* http://?*/$checksum : cat package-1.0.0.tar.gz"
+ stub curl "-*I* : true" \
+ "-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
diff --git a/test/stubs/curl/curl b/test/stubs/curl/curl
deleted file mode 120000
index a8e9ac9..0000000
--- a/test/stubs/curl/curl
+++ /dev/null
@@ -1 +0,0 @@
-../stub
\ No newline at end of file
diff --git a/test/stubs/md5/md5 b/test/stubs/md5/md5
deleted file mode 120000
index a8e9ac9..0000000
--- a/test/stubs/md5/md5
+++ /dev/null
@@ -1 +0,0 @@
-../stub
\ No newline at end of file
diff --git a/test/stubs/stub b/test/stubs/stub
index 8414c92..bd5c5d6 100755
--- a/test/stubs/stub
+++ b/test/stubs/stub
@@ -3,15 +3,19 @@ set -e
status=0
program="${0##*/}"
-PROGRAM="$(echo "$program" | tr a-z A-Z)"
+PROGRAM="$(echo "$program" | tr a-z- A-Z_)"
[ -n "$TMPDIR" ] || TMPDIR="/tmp"
_STUB_PLAN="${PROGRAM}_STUB_PLAN"
_STUB_RUN="${PROGRAM}_STUB_RUN"
-_STUB_DIR="${PROGRAM}_STUB_DIR"
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
_STUB_END="${PROGRAM}_STUB_END"
+_STUB_DEBUG="${PROGRAM}_STUB_DEBUG"
+
+if [ -n "${!_STUB_DEBUG}" ]; then
+ echo "$program" "$@" >&${!_STUB_DEBUG}
+fi
[ -e "${!_STUB_PLAN}" ] || exit 1
[ -n "${!_STUB_RUN}" ] || eval "${_STUB_RUN}"="${TMPDIR}/${program}-stub-run"
@@ -44,7 +48,9 @@ while IFS= read -r line; do
# Naively split patterns by whitespace for now.
# In the future, use a sed script to split while
# respecting quoting.
+ set -f
patterns=($patterns)
+ set +f
arguments=("$@")
# Match the expected argument patterns to actual
@@ -62,10 +68,8 @@ while IFS= read -r line; do
# If the arguments matched, evaluate the command
# in a subshell. Otherwise, log the failure.
if [ $result -eq 0 ] ; then
- dir="$(pwd)"
- [ ! -d "${!_STUB_DIR}" ] || dir="${!_STUB_DIR}"
set +e
- ( cd "$dir" ; eval "$command" )
+ ( eval "$command" )
status="$?"
set -e
else
diff --git a/test/test_helper.bash b/test/test_helper.bash
index a038381..11fb63a 100644
--- a/test/test_helper.bash
+++ b/test/test_helper.bash
@@ -1,7 +1,13 @@
-export PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
export TMP="$BATS_TEST_DIRNAME/tmp"
-export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
-export INSTALL_ROOT="$TMP/install"
+
+if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
+ export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
+ export INSTALL_ROOT="$TMP/install"
+ PATH=/usr/bin:/usr/sbin:/bin/:/sbin
+ PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
+ PATH="$TMP/bin:$PATH"
+ export PATH
+fi
teardown() {
rm -fr "$TMP"/*
@@ -9,39 +15,109 @@ teardown() {
stub() {
local program="$1"
- local prefix="$(echo "$program" | tr a-z A-Z)"
+ local prefix="$(echo "$program" | tr a-z- A-Z_)"
shift
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
- export "${prefix}_STUB_DIR"="$FIXTURE_ROOT"
export "${prefix}_STUB_END"=
- export PATH="${BATS_TEST_DIRNAME}/stubs/${program}:$PATH"
+ mkdir -p "${TMP}/bin"
+ ln -sf "${BATS_TEST_DIRNAME}/stubs/stub" "${TMP}/bin/${program}"
- rm -f "${TMP}/${program}-stub-plan" "${TMP}/${program}-stub-run"
touch "${TMP}/${program}-stub-plan"
for arg in "$@"; do printf "%s\n" "$arg" >> "${TMP}/${program}-stub-plan"; done
}
unstub() {
local program="$1"
- local prefix="$(echo "$program" | tr a-z A-Z)"
+ local prefix="$(echo "$program" | tr a-z- A-Z_)"
+ local path="${TMP}/bin/${program}"
- export "${prefix}_STUB_DIR"=
export "${prefix}_STUB_END"=1
- local path="${BATS_TEST_DIRNAME}/stubs/$program"
- local escaped_path="${path//\//\\/}"
- export PATH="${PATH/${escaped_path}:}"
+ local STATUS=0
+ "$path" || STATUS="$?"
+
+ rm -f "$path"
+ rm -f "${TMP}/${program}-stub-plan" "${TMP}/${program}-stub-run"
+ return "$STATUS"
+}
- "${path}/$program"
+run_inline_definition() {
+ local definition="${TMP}/build-definition"
+ cat > "$definition"
+ run ruby-build "$definition" "${1:-$INSTALL_ROOT}"
}
install_fixture() {
+ local args
+
+ while [ "${1#-}" != "$1" ]; do
+ args="$args $1"
+ shift 1
+ done
+
local name="$1"
local destination="$2"
[ -n "$destination" ] || destination="$INSTALL_ROOT"
- run ruby-build "$FIXTURE_ROOT/$name" "$destination"
+ run ruby-build $args "$FIXTURE_ROOT/$name" "$destination"
+}
+
+assert() {
+ if ! "$@"; then
+ flunk "failed: $@"
+ fi
+}
+
+flunk() {
+ { if [ "$#" -eq 0 ]; then cat -
+ else echo "$@"
+ fi
+ } | sed "s:${TMP}:\${TMP}:g" >&2
+ return 1
+}
+
+assert_success() {
+ if [ "$status" -ne 0 ]; then
+ { echo "command failed with exit status $status"
+ echo "output: $output"
+ } | flunk
+ elif [ "$#" -gt 0 ]; then
+ assert_output "$1"
+ fi
+}
+
+assert_failure() {
+ if [ "$status" -eq 0 ]; then
+ flunk "expected failed exit status"
+ elif [ "$#" -gt 0 ]; then
+ assert_output "$1"
+ fi
+}
+
+assert_equal() {
+ if [ "$1" != "$2" ]; then
+ { echo "expected: $1"
+ echo "actual: $2"
+ } | flunk
+ fi
+}
+
+assert_output() {
+ local expected
+ if [ $# -eq 0 ]; then expected="$(cat -)"
+ else expected="$1"
+ fi
+ assert_equal "$expected" "$output"
+}
+
+assert_output_contains() {
+ local expected="$1"
+ echo "$output" | grep -F "$expected" >/dev/null || {
+ { echo "expected output to contain $expected"
+ echo "actual: $output"
+ } | flunk
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-build.git
More information about the Pkg-ruby-extras-commits
mailing list