-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathruby-install-easy
executable file
·68 lines (63 loc) · 1.65 KB
/
ruby-install-easy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
set -euf -o pipefail
out () { printf %s\\n "$*" ; }
##
# Download the current ruby stable version,
# and install it in our preferred directory.
#
# Syntax:
#
# ruby-install-easy [vm [version [install_dir]]
#
# Example install of typical Ruby VM using latest version:
#
# ruby-install-easy
# #=> installs /opt/ruby/3.0.0
#
# Example install of JRuby VM using a specific version and install directory:
#
# ruby-install-easy jruby 9.2.16.0 /opt/jruby/9.2.16.0
# #=> installs /opt/jruby/9.2.16.0
#
# ## Locations
#
# We put our Ruby VMs in this directory tree:
#
# /opt/jruby/x.y.z
# /opt/ruby/x.y.z
# /opt/rbx/x.y.z
#
# ## Implemenation
#
# We use the `ruby-install` tool to do this because it handles
# many dependencies and in our opinion is better and simpler
# than other ruby downloaders such as rvm, rbenv, and ruby-build.
#
# We clone `ruby-install` in `/opt/ruby-install`.
# This script does a `git pull` to update the repo,
# which includes downloading any new VM version info.
#
# ## Tracking
#
# Command: ruby-install-easy
# Version: 4.0.0
# Created: 2014-11-09
# Updated: 2021-03-09
# Contact: Joel Parker Henderson ([email protected])
# License: GPL
##
out "Update ruby-install versions..."
(cd /opt/ruby-install && exec git pull)
# Identical to ruby-install source code
ruby_install_cache_dir(){
echo "${XDG_CACHE_HOME:-$HOME/.cache}/ruby-install"
}
latest_version(){
tail -1 "$(ruby_install_cache_dir)/.cache/ruby-install/$1/stable.txt"
}
vm=${1-ruby}
version=${2-$(latest_version $vm)}
install_dir=${3-"/opt/$vm/$version"}
set -x
ruby-install $vm "$version" --install-dir "$install_dir" --no-reinstall
set +x