mirror of
https://github.com/faye/wstest.git
synced 2025-11-01 13:58:47 +00:00
164 lines
3.2 KiB
Bash
Executable File
164 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eo pipefail
|
|
|
|
CHRUBY_VERSION='0.3.9'
|
|
RUBY_INSTALL_VERSION='0.9.1'
|
|
RUBY_DIR=~/src/rubies
|
|
|
|
BASHRC=~/.bash_aliases
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -y \
|
|
build-essential \
|
|
libcurl4-openssl-dev \
|
|
libpcre3-dev
|
|
|
|
mkdir -p "$RUBY_DIR"
|
|
|
|
install-ruby-install () {
|
|
local version="$1"
|
|
local filename="ruby-install-${version}.tar.gz"
|
|
local url="https://github.com/postmodern/ruby-install/archive/v${version}.tar.gz"
|
|
|
|
cd ~/src
|
|
[[ -f "$filename" ]] && return
|
|
|
|
wget -O "$filename" "$url"
|
|
tar -xzvf "$filename"
|
|
|
|
cd "ruby-install-${version}"
|
|
sudo make install
|
|
}
|
|
|
|
install-chruby () {
|
|
local version="$1"
|
|
local filename="chruby-${version}.tar.gz"
|
|
local url="https://github.com/postmodern/chruby/archive/v${version}.tar.gz"
|
|
|
|
cd ~/src
|
|
[[ -f "$filename" ]] && return
|
|
|
|
wget -O "$filename" "$url"
|
|
tar -xzvf "$filename"
|
|
|
|
cd "chruby-${version}"
|
|
sudo make install
|
|
|
|
touch "$BASHRC"
|
|
|
|
if [[ ! -f ~/.rubyrc ]] ; then
|
|
cat > ~/.rubyrc <<-EOF
|
|
export SSL_CERT_DIR=/etc/ssl/certs
|
|
source /usr/local/share/chruby/chruby.sh
|
|
RUBIES+=(${RUBY_DIR}/*)
|
|
EOF
|
|
echo 'source ~/.rubyrc' >> "$BASHRC"
|
|
fi
|
|
}
|
|
|
|
install-openssl () {
|
|
local version="$1"
|
|
local prefix="$2"
|
|
[[ -d "$prefix" ]] && return
|
|
|
|
local filename="openssl-${version}.tar.gz"
|
|
local url="https://www.openssl.org/source/${filename}"
|
|
|
|
cd ~/src
|
|
wget -O "$filename" "$url"
|
|
tar -xzvf "$filename"
|
|
|
|
cd "openssl-${version}"
|
|
./config shared
|
|
make install INSTALL_PREFIX="$prefix"
|
|
}
|
|
|
|
install-ruby () {
|
|
local version="$1"
|
|
local ssl_dir="$2"
|
|
|
|
local pathname="${RUBY_DIR}/ruby-${version}"
|
|
[[ -d "$pathname" ]] && return
|
|
|
|
if [[ -n "$ssl_dir" ]] ; then
|
|
ruby-install -r "$RUBY_DIR" ruby "$version" -- --with-openssl-dir="$ssl_dir"
|
|
install-bundler "ruby-${version}" '< 2'
|
|
else
|
|
ruby-install -r "$RUBY_DIR" ruby "$version"
|
|
fi
|
|
}
|
|
|
|
install-jruby () {
|
|
local version="$1"
|
|
local bundler_version="$2"
|
|
|
|
local pathname="${RUBY_DIR}/jruby-${version}"
|
|
[[ -d "$pathname" ]] && return
|
|
|
|
ruby-install -r "$RUBY_DIR" jruby "$version"
|
|
|
|
if [[ -n "$bundler_version" ]] ; then
|
|
install-bundler "jruby-${version}" "$bundler_version"
|
|
fi
|
|
}
|
|
|
|
install-bundler () {
|
|
install-gem "$1" bundler "$2"
|
|
}
|
|
|
|
install-gem () {
|
|
local ruby_version="$1"
|
|
local gem_name="$2"
|
|
local gem_version="$3"
|
|
local path="${RUBY_DIR}/${ruby_version}/bin"
|
|
|
|
if [[ "$ruby_version" == jruby-* ]] ; then
|
|
"${path}/ruby" -J-Xmx1024M -S gem install "$gem_name" -v "$gem_version"
|
|
else
|
|
SSL_CERT_DIR=/etc/ssl/certs "${path}/gem" install "$gem_name" -v "$gem_version"
|
|
fi
|
|
}
|
|
|
|
install-ruby-install "$RUBY_INSTALL_VERSION"
|
|
install-chruby "$CHRUBY_VERSION"
|
|
install-openssl '1.0.2u' ~/src/openssl@1.0
|
|
|
|
RUBY_VERSIONS=(
|
|
3.4.4
|
|
3.3.8
|
|
3.2.8
|
|
3.1.7
|
|
3.0.7
|
|
2.7.8
|
|
2.6.10
|
|
2.5.9
|
|
2.4.10
|
|
)
|
|
|
|
for version in "${RUBY_VERSIONS[@]}" ; do
|
|
install-ruby "$version"
|
|
|
|
if [[ "$version" < '2.6' ]] ; then
|
|
install-bundler "ruby-${version}" '< 2'
|
|
fi
|
|
done
|
|
|
|
RUBY_VERSIONS=(
|
|
2.3.8
|
|
2.2.10
|
|
2.1.10
|
|
# 2.0.0-p648
|
|
# 1.9.3-p551
|
|
)
|
|
|
|
for version in "${RUBY_VERSIONS[@]}" ; do
|
|
install-ruby "$version" ~/src/openssl@1.0/usr/local/ssl
|
|
done
|
|
|
|
install-jruby 9.4.12.1
|
|
install-jruby 9.3.15.0
|
|
install-jruby 9.2.21.0 '< 2.4'
|
|
install-jruby 9.1.17.0 '< 2.4'
|
|
install-jruby 1.7.27 '< 2'
|