-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
get
executable file
·158 lines (118 loc) · 2.81 KB
/
get
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
source "$rvm_scripts_path/base"
source "$rvm_scripts_path/version"
get_usage()
{
cat -v "$rvm_help_path/get"
}
#
# TODO: There is a lot of redundency in the get_X() functions, reduce it.
#
get_latest()
{
typeset version_url stable_version archive current
version_url="https://rvm.beginrescueend.com/releases/stable-version.txt"
stable_version=$(curl -s -B $version_url)
current=${rvm_version}
rvm_warn "
\`rvm get latest\` is deprecated, please use \`rvm get stable\`.
stable = latest + patches
"
if [ $stable_version != $current ]
then
[[ ! -d "$rvm_src_path" ]] && mkdir -p "$rvm_src_path/"
[[ ! -d "$rvm_archives_path" ]] && mkdir -p "$rvm_archives_path/"
get_version $stable_version
else
echo "You already have the latest version!"
fi
}
get_version()
{
version="$1"
md5=$(curl -s -B https://rvm.beginrescueend.com/releases/rvm-${version}.tar.gz.md5 2>/dev/null)
echo "rvm-${version}"
archive="$rvm_archives_path/rvm-${version}.tar.gz"
curl -L "https://rvm.beginrescueend.com/releases/rvm-${version}.tar.gz" \
-o "$archive"
case "$(uname)" in
Darwin|FreeBSD)
archive_md5="$(/sbin/md5 -q "${archive}")"
;;
OpenBSD)
archive_md5="$(/bin/md5 -q "${archive}")"
;;
Linux|*)
archive_md5="$(md5sum "${archive}")"
archive_md5="${archive_md5%% *}"
;;
esac
if [[ "$archive_md5" != "$md5" ]]; then
printf "%b" "ERROR:
Archive package rvm-${version}.tar.gz downloaded does not match its md5 checksum ${md5}.
Aborting RVM Installation.
"
exit 1
fi
$rvm_tar_command xzf "${rvm_path}/archives/rvm-${version}.tar.gz" -C "$rvm_src_path/" ${rvm_tar_options:-}
(
cd "$rvm_src_path/rvm-${version}"
chmod +x ./scripts/install
./scripts/install $args
)
rvm_log "\nInstalled RVM version:"
( source $rvm_scripts_path/rvm ; rvm --version )
rvm_hook="after_update"
source "$rvm_scripts_path/hook"
}
get_head()
{
(
export PATH
PATH="$PATH:${rvm_bin_path:-$rvm_path/bin}"
rvm-installer --branch $1 $args
) || return $?
rvm_log "\nInstalled RVM $1 version:"
( source $rvm_scripts_path/rvm ; rvm --version )
typeset -x rvm_hook
rvm_hook="after_update"
source "$rvm_scripts_path/hook"
return 0
}
export args
args=($*)
action="${args[$__array_start]}"
args[$__array_start]=""
args=(${args[@]})
case "$action" in
(latest)
get_latest
;;
(head|master)
get_head master
;;
(stable)
get_head stable
;;
(branch)
args[$__array_start]=""
args=(${args[@]})
get_head $2
;;
([0-9]*.[0-9]*.[0-9]*)
get_version "$action"
;;
# hack ... we will make it working properly in rvm2
(--auto)
exec $0 ${args[@]} --auto
;;
(help)
get_usage
true
;;
(*)
get_usage
false
;;
esac
exit $?