-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
get
executable file
·154 lines (106 loc) · 3.21 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
#!/usr/bin/env bash
source "$rvm_path/scripts/base"
source "$rvm_path/scripts/version"
get_help()
{
printf "
Usage:
rvm get {latest,head,help}
Options:
latest - download and install the latest RVM release listed by
http://rvm.beginrescueend.com/releases/stable-version.txt
head - git clone and install the latest RVM repository HEAD.
help - Output this message.
"
}
get_latest()
{
local version_url stable_version archive
version_url="http://rvm.beginrescueend.com/releases/stable-version.txt"
stable_version=$(curl -s $version_url)
"$rvm_path/scripts/log" "info" "\nOriginal installed RVM version:"
(__rvm_version)
[[ ! -d "$rvm_path/src" ]] && mkdir -p "$rvm_path/src/"
[[ ! -d "$rvm_path/archives" ]] && mkdir -p "$rvm_path/archives/"
# NOTE: This is the content as in binscripts/rvm-update-latest
stable_version=$(curl -B http://rvm.beginrescueend.com/releases/stable-version.txt 2>/dev/null)
stable_md5=$(curl -B http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz.md5 2>/dev/null)
echo "rvm-${stable_version}"
archive="$rvm_path/archives/rvm-${stable_version}.tar.gz"
curl -L "http://rvm.beginrescueend.com/releases/rvm-${stable_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}" | awk '{print $1}')"
;;
esac
if [[ "$archive_md5" != "$stable_md5" ]]; then
printf "ERROR:
Archive package rvm-${stable_version}.tar.gz downloaded does not match it's md5 checksum ${stable_md5}.
Aborting RVM Installation.
"
exit 1
fi
tar zxf "${rvm_path}/archives/rvm-${stable_version}.tar.gz" -C "$rvm_path/src/"
(
cd "$rvm_path/src/rvm-${stable_version}"
chmod +x ./scripts/install
./scripts/install
)
"$rvm_path/scripts/log" "info" "\nInstalled RVM version:"
( source $rvm_path/scripts/rvm ; rvm --version )
rvm_hook="after_update"
source "$rvm_path/scripts/hook"
}
get_head()
{
"$rvm_path/scripts/log" "info" "\nOriginal installed RVM version:"
__rvm_version
(
if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}" ]] ; then
\mkdir -p "${rvm_src_path:-"$rvm_path/src"}"
fi
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
if [[ -d "${rvm_src_path:-"$rvm_path/src"}/rvm/.git" ]] ; then
builtin cd "${rvm_src_path:-"$rvm_path/src"}/rvm/" && \
git pull origin master && \
./scripts/install
else
builtin cd "${rvm_src_path:-"$rvm_path/src"}" && \
( git clone --depth 1 git://github.com/wayneeseguin/rvm.git || \
git clone https://github.com/wayneeseguin/rvm.git ) && \
builtin cd rvm/ && ./scripts/install
fi
)
"$rvm_path/scripts/log" "info" "\nInstalled RVM HEAD version:"
( source $rvm_path/scripts/rvm ; rvm --version )
rvm_hook="after_update"
source "$rvm_path/scripts/hook"
return 0
}
args=($*)
action="${args[$__array_start]}"
args[$__array_start]=""
args=(${args[@]})
case "$action" in
latest)
get_latest
;;
head)
get_head
;;
help)
get_help
true
;;
*)
false
;;
esac
exit $?