github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/builtin/scriptpack/ruby/data/install.sh (about) 1 # ruby_install_prepare installs ruby-install and chruby 2 ruby_install_prepare() { 3 rubyinstall_version="0.6.0" 4 chruby_version="0.3.9" 5 6 # If we don't have wget, install that 7 if ! hash wget 2>/dev/null; then 8 apt_update_once 9 oe sudo apt-get install -y wget 10 fi 11 12 # Download/Install ruby-install 13 pushd /tmp >/dev/null 14 oe wget -O ruby-install-${rubyinstall_version}.tar.gz \ 15 https://github.com/postmodern/ruby-install/archive/v${rubyinstall_version}.tar.gz 16 oe tar -xzvf ruby-install-${rubyinstall_version}.tar.gz 17 cd ruby-install-${rubyinstall_version}/ 18 oe sudo make install 19 popd >/dev/null 20 21 # Download/Install chruby 22 pushd /tmp >/dev/null 23 oe wget -O chruby-${chruby_version}.tar.gz \ 24 https://github.com/postmodern/chruby/archive/v${chruby_version}.tar.gz 25 oe tar -xzvf chruby-${chruby_version}.tar.gz 26 cd chruby-${chruby_version}/ 27 oe sudo make install 28 popd >/dev/null 29 30 # Make /opt/rubies ahead of time so that chruby configures properly 31 sudo mkdir -p /opt/rubies 32 33 # Install chruby system-wide 34 cat <<EOF >/tmp/chruby.sh 35 if [ -n "\$BASH_VERSION" ] || [ -n "\$ZSH_VERSION" ]; then 36 source /usr/local/share/chruby/chruby.sh 37 fi 38 EOF 39 sudo mv /tmp/chruby.sh /etc/profile.d/chruby.sh 40 sudo chmod +x /etc/profile.d/chruby.sh 41 source /etc/profile.d/chruby.sh 42 } 43 44 # ruby_install installs the given ruby version. The parameter should be 45 # the ruby version to install, such as "ruby-2.1.3" 46 ruby_install() { 47 local version=$1 48 49 # Install the ruby version 50 oe sudo ruby-install $version -- --disable-install-rdoc 51 52 # Resource chruby so it detects our new ruby 53 . /etc/profile.d/chruby.sh 54 55 # Configure the environment to use it 56 echo "chruby ${version}" >> $HOME/.profile 57 chruby ${version} 58 }