Skip to content

Instantly share code, notes, and snippets.

@takehiko
Last active December 14, 2015 09:39
Show Gist options
  • Save takehiko/5066720 to your computer and use it in GitHub Desktop.
Save takehiko/5066720 to your computer and use it in GitHub Desktop.
Settings for installing and utilizing Ruby snapshots
# settings for installing and utilizing Ruby snapshots
# function:
# ruby-snss-install
# ruby-snapshot-install
# ruby-sn-install
# ruby-stable-snapshot-install
# ruby-ss-install
# ruby-install
# use-ruby-snapshot
# use-ruby-sn
# use-ruby-stable-snapshot
# use-ruby-ss
# eng
# environment variable:
# HOME_BIN
# RUBY_SN_DIR
# RUBY_SN
# RUBY_SS_DIR
# RUBY_SS
export HOME_BIN=$HOME/bin
if [ -d $HOME_BIN ]
then
for d in $HOME_BIN/*
do
if [ -d $d/bin ]
then
PATH=$d/bin:$PATH
fi
done
fi
function ruby-snss-install() {
local ECHO=""
local today=$(date '+%Y%m%d')
local ssflag=1
local instdir="ruby"
local configopt=""
local uri base dir1 dir2 tgz
if [[ $# != 0 ]]
then
instdir=$1
shift
if [[ $# != 0 ]]
then
ssflag=$1
shift
fi
fi
if [[ $ssflag = "1" ]]
then
# stable snapshot (ruby 2.0.0)
uri=ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
base=ruby-ss-$today
else
# snapshot (ruby 2.1.0dev)
uri=ftp://ftp.ruby-lang.org/pub/ruby/snapshot.tar.gz
base=ruby-sn-$today
fi
dir1=${base}_tmp
dir2=$base
tgz=$base.tgz
$ECHO pushd $HOME/src
[ -f $tgz ] || $ECHO wget -O $tgz $uri
$ECHO mkdir $dir1
$ECHO tar xvzfC $tgz $dir1
$ECHO mv $dir1/r* $dir2
$ECHO rmdir $dir1
$ECHO cd $dir2
# As for ARCHI, get access to https://gist.github.com/takehiko/6543175
if [[ ${+ARCHI} = 1 && $ARCHI = "linux" ]]
then
configopt="${configopt} --enable-pthread"
fi
$ECHO ./configure --prefix=$HOME_BIN/$instdir ${=configopt}
$ECHO make
$ECHO make install
$ECHO popd
}
function ruby-snapshot-install() {
ruby-snss-install ruby 0
}
alias ruby-sn-install=ruby-snapshot-install
function ruby-stable-snapshot-install() {
ruby-snss-install .ruby-ss
}
alias ruby-ss-install=ruby-stable-snapshot-install
function ruby-install() {
ruby-sn-install
ruby-ss-install
}
export RUBY_SN_DIR=$HOME_BIN/ruby/bin
if [ -d $RUBY_SN_DIR ]
then
function use-ruby-snapshot () {
PATH=$RUBY_SN_DIR:$PATH
rehash
}
alias use-ruby-sn=use-ruby-snapshot
export RUBY_SN=$RUBY_SN_DIR/ruby
fi
export RUBY_SS_DIR=$HOME_BIN/.ruby-ss/bin
if [ -d $RUBY_SS_DIR ]
then
function use-ruby-stable-snapshot () {
PATH=$RUBY_SS_DIR:$PATH
rehash
}
alias use-ruby-ss=use-ruby-stable-snapshot
export RUBY_SS=$RUBY_SS_DIR/ruby
fi
# You may execute "eng" when using Cygwin to avoid folk-related errors.
alias eng='LANG=C LANGUAGE=C LC_ALL=C'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment