Last active
December 15, 2015 10:09
-
-
Save tagomoris/5244094 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| TARGET_VERSION=$1 | |
| LOCATION=$2 | |
| if [ "x"$TARGET_VERSION = "x-h" -o "x"$TARGET_VERSION = "x--help" -o "x"$LOCATION = "x" ]; then | |
| echo "[usage] ruby-install VERSION LOCATION" | |
| echo " ex: ruby-install 1.9.3-p392 ~/local/ruby-1.9.3" | |
| exit 0 | |
| fi | |
| cd $(dirname $0) | |
| XBUILD_PATH=$(pwd) | |
| if [ ! -d ./var/ruby-build ]; then | |
| ( | |
| set -e | |
| mkdir -p var | |
| cd var | |
| git clone -q git://github.com/sstephenson/ruby-build.git ruby-build-repo | |
| cd ruby-build-repo | |
| PREFIX=$XBUILD_PATH/var/ruby-build ./install.sh >/dev/null 2>&1 | |
| ) || (echo "failed to download ruby-build" && exit 1) | |
| fi | |
| ./var/ruby-build/bin/ruby-build $TARGET_VERSION $LOCATION > /tmp/ruby-install.log 2>&1 | |
| RETVAL=$? | |
| if [ $RETVAL != 0 ]; then | |
| echo "ruby-build failed. see log: /tmp/ruby-install.log" | |
| exit 1 | |
| fi | |
| $LOCATION/bin/gem install --no-rdoc --no-ri bundler pry > /tmp/ruby-install-bundler.log 2>&1 | |
| RETVAL=$? | |
| if [ $RETVAL != 0 ]; then | |
| echo "gem install failed. see log /tmp/ruby-install-bundler.log" | |
| exit 2 | |
| fi | |
| echo "ruby $TARGET_VERSION successfully installed on $LOCATION" | |
| echo "To use this ruby, do 'export PATH=$LOCATION/bin:\$PATH'." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment