rvm 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/VERSION.yml +1 -1
- data/lib/rvm/environment.rb +1 -1
- data/lib/rvm/shell/shell_wrapper.sh +1 -1
- data/rvm.gemspec +3 -110
- metadata +4 -111
- data/binscripts/rvm +0 -76
- data/binscripts/rvm-auto-ruby +0 -24
- data/binscripts/rvm-prompt +0 -208
- data/binscripts/rvm-shell +0 -35
- data/binscripts/rvm-update-head +0 -58
- data/binscripts/rvm-update-latest +0 -27
- data/binscripts/rvmsudo +0 -20
- data/config/db +0 -71
- data/config/known +0 -54
- data/config/md5 +0 -139
- data/contrib/gemset_snapshot +0 -25
- data/contrib/install-system-wide +0 -221
- data/contrib/r +0 -44
- data/examples/rvmrc +0 -49
- data/gemsets/default.gems +0 -1
- data/gemsets/global.gems +0 -1
- data/help/alias +0 -46
- data/help/benchmark +0 -17
- data/help/cleanup +0 -23
- data/help/debug +0 -8
- data/help/disk-usage +0 -15
- data/help/docs +0 -22
- data/help/exec +0 -33
- data/help/fetch +0 -5
- data/help/gem +0 -0
- data/help/gemdir +0 -0
- data/help/gemset +0 -14
- data/help/implode +0 -0
- data/help/info +0 -62
- data/help/install +0 -0
- data/help/list +0 -0
- data/help/migrate +0 -15
- data/help/monitor +0 -0
- data/help/notes +0 -0
- data/help/package +0 -0
- data/help/rake +0 -14
- data/help/remove +0 -0
- data/help/repair +0 -23
- data/help/reset +0 -0
- data/help/ruby +0 -84
- data/help/rubygems +0 -11
- data/help/rvmrc +0 -34
- data/help/snapshot +0 -15
- data/help/specs +0 -0
- data/help/srcdir +0 -0
- data/help/tests +0 -0
- data/help/tools +0 -22
- data/help/uninstall +0 -0
- data/help/update +0 -0
- data/help/upgrade +0 -18
- data/help/use +0 -0
- data/help/wrapper +0 -41
- data/install +0 -667
- data/man/man1/rvm.1 +0 -380
- data/man/man1/rvm.1.gz +0 -0
- data/scripts/alias +0 -226
- data/scripts/aliases +0 -4
- data/scripts/array +0 -32
- data/scripts/base +0 -57
- data/scripts/cd +0 -94
- data/scripts/cleanup +0 -58
- data/scripts/cli +0 -798
- data/scripts/color +0 -49
- data/scripts/completion +0 -151
- data/scripts/db +0 -87
- data/scripts/default +0 -64
- data/scripts/disk-usage +0 -60
- data/scripts/docs +0 -115
- data/scripts/env +0 -46
- data/scripts/environment-convertor +0 -74
- data/scripts/fetch +0 -231
- data/scripts/gemsets +0 -1045
- data/scripts/get +0 -126
- data/scripts/hash +0 -37
- data/scripts/help +0 -46
- data/scripts/hook +0 -23
- data/scripts/info +0 -213
- data/scripts/initialize +0 -29
- data/scripts/install +0 -667
- data/scripts/irbrc +0 -13
- data/scripts/irbrc.rb +0 -64
- data/scripts/list +0 -315
- data/scripts/log +0 -38
- data/scripts/maglev +0 -193
- data/scripts/manage +0 -2157
- data/scripts/match +0 -6
- data/scripts/md5 +0 -22
- data/scripts/migrate +0 -175
- data/scripts/monitor +0 -105
- data/scripts/notes +0 -140
- data/scripts/override_gem +0 -14
- data/scripts/package +0 -302
- data/scripts/patches +0 -64
- data/scripts/patchsets +0 -87
- data/scripts/repair +0 -199
- data/scripts/rubygems +0 -157
- data/scripts/rvm +0 -128
- data/scripts/rvm-install +0 -667
- data/scripts/selector +0 -904
- data/scripts/set +0 -301
- data/scripts/snapshot +0 -262
- data/scripts/tools +0 -58
- data/scripts/update +0 -667
- data/scripts/upgrade +0 -144
- data/scripts/utility +0 -1499
- data/scripts/version +0 -17
- data/scripts/wrapper +0 -210
data/scripts/env
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
unset rvm_default_flag # Recursive loops, oh my!
|
4
|
-
|
5
|
-
source "$rvm_path/scripts/base"
|
6
|
-
|
7
|
-
usage()
|
8
|
-
{
|
9
|
-
printf "
|
10
|
-
Usage:
|
11
|
-
|
12
|
-
rvm env [ruby_string] [--path]
|
13
|
-
|
14
|
-
"
|
15
|
-
}
|
16
|
-
|
17
|
-
args=($*)
|
18
|
-
environment_name="${args[0]}"
|
19
|
-
|
20
|
-
if [[ -z "$environment_name" ]]; then
|
21
|
-
usage ; exit 1
|
22
|
-
fi
|
23
|
-
|
24
|
-
# Exit when we encounter an unknown environment name.
|
25
|
-
__rvm_become "$environment_name"
|
26
|
-
|
27
|
-
if [[ "$?" = 0 ]]; then
|
28
|
-
__rvm_use
|
29
|
-
environment_file_path="$rvm_path/environments/$(__rvm_environment_identifier)"
|
30
|
-
# Echo the path or environment file.
|
31
|
-
if [[ -n "$rvm_path_flag" ]]; then
|
32
|
-
echo "$environment_file_path"
|
33
|
-
else
|
34
|
-
cat "$environment_file_path"
|
35
|
-
fi
|
36
|
-
unset environment_file_path
|
37
|
-
result=0
|
38
|
-
else
|
39
|
-
result=1
|
40
|
-
fi
|
41
|
-
|
42
|
-
unset rvm_ruby_string environment_name
|
43
|
-
__rvm_unset_ruby_variables
|
44
|
-
|
45
|
-
exit $result
|
46
|
-
|
@@ -1,74 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# Usage: $rvm_path/scripts/environment-convertor <shell> <environment>
|
4
|
-
|
5
|
-
unset GREP_COLOR
|
6
|
-
unset GREP_OPTIONS
|
7
|
-
|
8
|
-
source "$rvm_path/scripts/base"
|
9
|
-
|
10
|
-
convert_path_to_fish()
|
11
|
-
{
|
12
|
-
local parts path_parts
|
13
|
-
|
14
|
-
path_part="$1"
|
15
|
-
parts="$(echo "$path_part" | sed -e 's#:\$PATH##' -e "s#:#\" \"#g" -e "s#^export \\([^[:space:]]*\\)=##")"
|
16
|
-
|
17
|
-
printf "\
|
18
|
-
for path_part in $parts
|
19
|
-
if test -d $path_part
|
20
|
-
set PATH $path_parth $PATH
|
21
|
-
end
|
22
|
-
end
|
23
|
-
"
|
24
|
-
return 0
|
25
|
-
}
|
26
|
-
|
27
|
-
convert_unset_to_fish()
|
28
|
-
{
|
29
|
-
sed 's#^unset #set -e #'
|
30
|
-
}
|
31
|
-
|
32
|
-
convert_exports_to_fish()
|
33
|
-
{
|
34
|
-
sed -e "s#:#' '#g" -e "s#^\\(export \\)\\{0,1\\}\\([^[:space:]]*\\)=#set -x \\2 #"
|
35
|
-
}
|
36
|
-
|
37
|
-
contents_of_environment_file()
|
38
|
-
{
|
39
|
-
cat "$rvm_path/environments/$(__rvm_environment_identifier)"
|
40
|
-
}
|
41
|
-
|
42
|
-
convert_to_shell()
|
43
|
-
{
|
44
|
-
convert_path_to_fish "$(contents_of_environment_file | \grep '^export PATH=')"
|
45
|
-
while read -r shell_line; do
|
46
|
-
if echo "$shell_line" | \grep -q '^unset '; then
|
47
|
-
echo "$shell_line" | convert_unset_to_fish
|
48
|
-
else
|
49
|
-
echo "$shell_line" | convert_exports_to_fish
|
50
|
-
fi
|
51
|
-
done < <(contents_of_environment_file | \grep -v '^export [^=]*$' | \grep -v '^export PATH=')
|
52
|
-
unset shell_line
|
53
|
-
}
|
54
|
-
|
55
|
-
ensure_has_shell()
|
56
|
-
{
|
57
|
-
for item in "path" "unset" "exports"; do
|
58
|
-
command -v "convert_${item}_to_${1}" >/dev/null || return 1
|
59
|
-
done; unset item
|
60
|
-
}
|
61
|
-
|
62
|
-
args=($*)
|
63
|
-
shell_name="${args[0]}"
|
64
|
-
environment_name="${args[1]:-"$(__rvm_environment_identifier)"}"
|
65
|
-
args="$(echo ${args[@]:2}) " # Strip trailing / leading / extra spacing.
|
66
|
-
|
67
|
-
[[ -n "$shell_name" && -n "$environment_name" ]] || exit 1
|
68
|
-
ensure_has_shell "$shell_name" || exit 1
|
69
|
-
# Check we're loading a different shell.
|
70
|
-
if [[ "$(__rvm_environment_identifier)" != "$environment_name" ]]; then
|
71
|
-
__rvm_become "$environment_name" || exit 1
|
72
|
-
fi
|
73
|
-
|
74
|
-
convert_to_shell
|
data/scripts/fetch
DELETED
@@ -1,231 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
rvm_base_except="selector"
|
4
|
-
|
5
|
-
source "$rvm_path/scripts/base"
|
6
|
-
|
7
|
-
result=0
|
8
|
-
|
9
|
-
# Set it to cleanup the download on interruption.
|
10
|
-
trap 'cleanup_download' 1 2 3 15
|
11
|
-
|
12
|
-
cleanup_download()
|
13
|
-
{
|
14
|
-
[[ -f "$archive" ]] && rm -f "$archive"
|
15
|
-
}
|
16
|
-
|
17
|
-
record_md5()
|
18
|
-
{
|
19
|
-
case "$(uname)" in
|
20
|
-
Darwin|FreeBSD)
|
21
|
-
archive_md5="$(/sbin/md5 -q "${archive}")"
|
22
|
-
;;
|
23
|
-
OpenBSD)
|
24
|
-
archive_md5="$(/bin/md5 -q "${archive}")"
|
25
|
-
;;
|
26
|
-
Linux|*)
|
27
|
-
archive_md5="$(md5sum "${archive}" | awk '{print $1}')"
|
28
|
-
;;
|
29
|
-
esac
|
30
|
-
|
31
|
-
"$rvm_path/scripts/db" "$rvm_path/config/md5" "$archive" "$archive_md5"
|
32
|
-
|
33
|
-
}
|
34
|
-
|
35
|
-
builtin cd "${rvm_archives_path:-"$rvm_path/archives"}"
|
36
|
-
|
37
|
-
# args=($*) # Reserved for future use
|
38
|
-
|
39
|
-
if [[ -z "$1" ]] ; then
|
40
|
-
|
41
|
-
"$rvm_path/scripts/log" "fail" \
|
42
|
-
"BUG: $0 called without an argument :/"
|
43
|
-
|
44
|
-
exit 1
|
45
|
-
fi
|
46
|
-
|
47
|
-
url="$1"; download=1 ; package_name="$2"
|
48
|
-
|
49
|
-
if ! command -v curl > /dev/null ; then
|
50
|
-
|
51
|
-
"$rvm_path/scripts/log" "fail" \
|
52
|
-
"rvm requires curl. curl was not found in your active path."
|
53
|
-
|
54
|
-
exit 1
|
55
|
-
|
56
|
-
elif [[ ! -z ${rvm_proxy} ]] ; then
|
57
|
-
|
58
|
-
fetch_command="curl -x${rvm_proxy} -L --create-dirs -C - " # -s for silent
|
59
|
-
|
60
|
-
else
|
61
|
-
|
62
|
-
fetch_command="curl -L --create-dirs -C - " # -s for silent
|
63
|
-
|
64
|
-
fi
|
65
|
-
|
66
|
-
if [[ ! -z "$package_name" ]] ; then
|
67
|
-
|
68
|
-
fetch_command="${fetch_command} -o ${package_name} "
|
69
|
-
|
70
|
-
archive="$package_name"
|
71
|
-
|
72
|
-
else
|
73
|
-
|
74
|
-
fetch_command="${fetch_command} -O "
|
75
|
-
|
76
|
-
archive=$(basename "$url")
|
77
|
-
|
78
|
-
fi
|
79
|
-
|
80
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
81
|
-
|
82
|
-
"$rvm_path/scripts/log" "debug" \
|
83
|
-
"Fetching $archive"
|
84
|
-
|
85
|
-
fi
|
86
|
-
|
87
|
-
# Check first if we have the correct archive
|
88
|
-
archive_md5="$("$rvm_path/scripts/db" "$rvm_path/config/md5" "$archive" | head -n1)"
|
89
|
-
|
90
|
-
if [[ -e "$archive" && ! -z "$archive_md5" ]] ; then
|
91
|
-
|
92
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
93
|
-
|
94
|
-
"$rvm_path/scripts/log" "debug" \
|
95
|
-
"Found archive and its md5, testing correctness"
|
96
|
-
|
97
|
-
fi
|
98
|
-
|
99
|
-
if ! "$rvm_path/scripts"/md5 "${rvm_archives_path:-"$rvm_path/archives"}/${archive}" "$archive_md5" ; then
|
100
|
-
|
101
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
102
|
-
"$rvm_path/scripts/log" "debug" \
|
103
|
-
"Archive md5 did not match, downloading"
|
104
|
-
fi
|
105
|
-
|
106
|
-
download=1
|
107
|
-
|
108
|
-
else
|
109
|
-
|
110
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
111
|
-
|
112
|
-
"$rvm_path/scripts/log" "debug" \
|
113
|
-
"Archive md5 matched, not downloading"
|
114
|
-
|
115
|
-
fi
|
116
|
-
|
117
|
-
download=0
|
118
|
-
|
119
|
-
result=0
|
120
|
-
|
121
|
-
fi
|
122
|
-
|
123
|
-
else
|
124
|
-
|
125
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
126
|
-
|
127
|
-
"$rvm_path/scripts/log" "debug" \
|
128
|
-
"No archive or no MD5, downloading"
|
129
|
-
|
130
|
-
fi
|
131
|
-
|
132
|
-
download=1
|
133
|
-
|
134
|
-
fi
|
135
|
-
|
136
|
-
# try to convert the ftp url to a http url
|
137
|
-
http_url="$(echo "$url" | sed -e 's/ftp:/http:/' -e 's/git:/http:/')"
|
138
|
-
|
139
|
-
if [[ $download -gt 0 ]] ; then
|
140
|
-
|
141
|
-
rm -f $archive
|
142
|
-
|
143
|
-
eval $fetch_command "$url" ; result=$?
|
144
|
-
|
145
|
-
if [[ $result -gt 0 ]] ; then
|
146
|
-
|
147
|
-
retry=0
|
148
|
-
|
149
|
-
try_http=0
|
150
|
-
|
151
|
-
if [[ $result -eq 78 ]] ; then
|
152
|
-
|
153
|
-
"$rvm_path/scripts/log" "error" \
|
154
|
-
"The requested url does not exist: '$url'"
|
155
|
-
|
156
|
-
try_http=1
|
157
|
-
|
158
|
-
elif [[ $result -eq 18 ]] ; then
|
159
|
-
|
160
|
-
"$rvm_path/scripts/log" "error" \
|
161
|
-
"Partial file. Only a part of the file was transferred. Removing partial and re-trying."
|
162
|
-
|
163
|
-
rm -f "$archive"
|
164
|
-
|
165
|
-
retry=1
|
166
|
-
|
167
|
-
elif [[ $result -eq 33 ]] ; then
|
168
|
-
|
169
|
-
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
170
|
-
|
171
|
-
"$rvm_path/scripts/log" "debug" \
|
172
|
-
"Server does not support 'range' command, removing '$archive'"
|
173
|
-
|
174
|
-
fi
|
175
|
-
|
176
|
-
rm -f "$archive"
|
177
|
-
|
178
|
-
retry=1
|
179
|
-
|
180
|
-
else
|
181
|
-
|
182
|
-
"$rvm_path/scripts/log" "error" \
|
183
|
-
"There was an error, please check ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/*.log. Next we'll try to fetch via http."
|
184
|
-
|
185
|
-
try_http=1
|
186
|
-
|
187
|
-
fi
|
188
|
-
|
189
|
-
if [[ $retry -eq 1 ]] ; then
|
190
|
-
|
191
|
-
eval $fetch_command "$url" ; result=$?
|
192
|
-
|
193
|
-
if [[ $result -gt 0 ]] ; then
|
194
|
-
|
195
|
-
"$rvm_path/scripts/log" "error" \
|
196
|
-
"There was an error, please check ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/*.log"
|
197
|
-
|
198
|
-
else
|
199
|
-
|
200
|
-
record_md5
|
201
|
-
|
202
|
-
fi
|
203
|
-
|
204
|
-
fi
|
205
|
-
|
206
|
-
if [[ $try_http -eq 1 ]] ; then
|
207
|
-
|
208
|
-
eval $fetch_command "$http_url" ; result=$?
|
209
|
-
|
210
|
-
if [[ $result -gt 0 ]] ; then
|
211
|
-
|
212
|
-
"$rvm_path/scripts/log" "error" \
|
213
|
-
"There was an error, please check ${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string/*.log"
|
214
|
-
|
215
|
-
else
|
216
|
-
|
217
|
-
record_md5
|
218
|
-
|
219
|
-
fi
|
220
|
-
|
221
|
-
fi
|
222
|
-
|
223
|
-
else
|
224
|
-
|
225
|
-
record_md5
|
226
|
-
|
227
|
-
fi
|
228
|
-
|
229
|
-
fi
|
230
|
-
|
231
|
-
exit $result
|
data/scripts/gemsets
DELETED
@@ -1,1045 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
source "$rvm_path/scripts/base"
|
4
|
-
|
5
|
-
rvm_ruby_gem_home="${rvm_ruby_gem_home:-$GEM_HOME}"
|
6
|
-
|
7
|
-
if [[ ! -d "$rvm_ruby_gem_home" ]] && command -v gem > /dev/null 2>&1; then rvm_ruby_gem_home="$(gem env home)" ; fi
|
8
|
-
|
9
|
-
usage()
|
10
|
-
{
|
11
|
-
printf "
|
12
|
-
Usage:
|
13
|
-
|
14
|
-
rvm gemset [action]
|
15
|
-
|
16
|
-
Action:
|
17
|
-
|
18
|
-
{import,export,create,copy,rename,empty,delete,name,dir,list,list_all,gemdir,install,pristine,clear,use,update,unpack,globalcache}
|
19
|
-
|
20
|
-
Description:
|
21
|
-
|
22
|
-
Commands for working with and manipulating gemsets within RVM.
|
23
|
-
|
24
|
-
"
|
25
|
-
}
|
26
|
-
|
27
|
-
gemset_list_all()
|
28
|
-
{
|
29
|
-
for rvm_ruby_string in $(rvm list strings) ; do
|
30
|
-
(__rvm_use $ruby ; gemset_list)
|
31
|
-
done
|
32
|
-
unset rvm_ruby_string
|
33
|
-
}
|
34
|
-
|
35
|
-
gemset_update()
|
36
|
-
{
|
37
|
-
|
38
|
-
if [[ -z "$rvm_ruby_strings" ]]; then
|
39
|
-
|
40
|
-
"$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets."
|
41
|
-
|
42
|
-
rvm_ruby_strings="$(
|
43
|
-
builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ;
|
44
|
-
find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null \
|
45
|
-
| grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ','
|
46
|
-
)"
|
47
|
-
|
48
|
-
rvm_ruby_strings="${rvm_ruby_strings/%,}"
|
49
|
-
|
50
|
-
rvm_ruby_strings="${rvm_ruby_strings//.\/}"
|
51
|
-
|
52
|
-
else
|
53
|
-
"$rvm_path/scripts/log" "info" "Running gem update for the specified rubies."
|
54
|
-
fi
|
55
|
-
|
56
|
-
export rvm_ruby_strings
|
57
|
-
|
58
|
-
"$rvm_path/scripts/set" "gem" "update"
|
59
|
-
|
60
|
-
return $?
|
61
|
-
}
|
62
|
-
|
63
|
-
gemset_globalcache()
|
64
|
-
{
|
65
|
-
local gc_status globalcache_enabled directories directory_name full_directory_path directory_name
|
66
|
-
|
67
|
-
if [[ "$1" == "enabled" ]]; then
|
68
|
-
|
69
|
-
__rvm_using_gemset_globalcache
|
70
|
-
|
71
|
-
globalcache_enabled=$?
|
72
|
-
|
73
|
-
gc_status="Unknown"
|
74
|
-
|
75
|
-
if [[ $globalcache_enabled -eq 0 ]]; then
|
76
|
-
gc_status="Enabled"
|
77
|
-
else
|
78
|
-
gc_status="Disabled"
|
79
|
-
fi
|
80
|
-
|
81
|
-
"$rvm_path/scripts/log" "info" \
|
82
|
-
"Gemset global cache is currently: $gc_status"
|
83
|
-
|
84
|
-
return "$globalcache_enabled"
|
85
|
-
|
86
|
-
elif [[ "$1" == "disable" ]]; then
|
87
|
-
|
88
|
-
"$rvm_path/scripts/log" "info" \
|
89
|
-
"Removing the global cache (note: this will empty the caches)"
|
90
|
-
|
91
|
-
directories=($(
|
92
|
-
builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ;
|
93
|
-
find . -maxdepth 1 -mindepth 1 -type d -print)
|
94
|
-
)
|
95
|
-
|
96
|
-
for directory_name in "${directories[@]//.\/}"; do
|
97
|
-
|
98
|
-
current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache"
|
99
|
-
|
100
|
-
if [[ -L "$current_cache_path" \
|
101
|
-
&& "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then
|
102
|
-
|
103
|
-
"$rvm_path/scripts/log" "info" \
|
104
|
-
"Reverting the gem cache for $directory_name to an empty directory."
|
105
|
-
|
106
|
-
rm -f "$current_cache_path" 2>/dev/null
|
107
|
-
|
108
|
-
mkdir -p "$current_cache_path" 2>/dev/null
|
109
|
-
fi
|
110
|
-
done
|
111
|
-
|
112
|
-
"$rvm_path/scripts/db" "$rvm_path/config/user" \
|
113
|
-
"use_gemset_globalcache" "delete"
|
114
|
-
|
115
|
-
elif [[ "$1" == "enable" ]]; then
|
116
|
-
|
117
|
-
"$rvm_path/scripts/log" "info" \
|
118
|
-
"Enabling global cache for gems."
|
119
|
-
|
120
|
-
mkdir -p "$rvm_gems_cache_path"
|
121
|
-
|
122
|
-
directories=($(
|
123
|
-
builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ;
|
124
|
-
find . -maxdepth 1 -mindepth 1 -type d -print)
|
125
|
-
)
|
126
|
-
|
127
|
-
for directory_name in "${directories[@]//.\/}" ; do
|
128
|
-
|
129
|
-
current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache"
|
130
|
-
|
131
|
-
if [[ -d "$current_cache_path" && ! -L "$current_cache_path" ]]; then
|
132
|
-
|
133
|
-
"$rvm_path/scripts/log" "info" \
|
134
|
-
"Moving the gem cache for $directory_name to the global cache."
|
135
|
-
|
136
|
-
mv "$current_cache_path/"*.gem "$rvm_gems_cache_path/" 2>/dev/null
|
137
|
-
|
138
|
-
rm -rf "$current_cache_path"
|
139
|
-
|
140
|
-
ln -nfs "$rvm_gems_cache_path" "$current_cache_path"
|
141
|
-
fi
|
142
|
-
|
143
|
-
done
|
144
|
-
|
145
|
-
"$rvm_path/scripts/db" "$rvm_path/config/user" \
|
146
|
-
"use_gemset_globalcache" "true"
|
147
|
-
|
148
|
-
else
|
149
|
-
printf "
|
150
|
-
|
151
|
-
Usage:
|
152
|
-
|
153
|
-
rvm gemset globalcache {enable,disable}
|
154
|
-
|
155
|
-
Enable / Disable the use of a global gem cachedir.
|
156
|
-
|
157
|
-
"
|
158
|
-
return 1
|
159
|
-
fi
|
160
|
-
}
|
161
|
-
|
162
|
-
gemset_name()
|
163
|
-
{
|
164
|
-
gemset_dir | awk -F${rvm_gemset_separator:-"@"} '{print $2}'
|
165
|
-
return $?
|
166
|
-
}
|
167
|
-
|
168
|
-
gemset_dir()
|
169
|
-
{
|
170
|
-
echo "$rvm_ruby_gem_home"
|
171
|
-
return $?
|
172
|
-
}
|
173
|
-
|
174
|
-
gemset_create()
|
175
|
-
{
|
176
|
-
local gem_home gemset gemsets prefix
|
177
|
-
|
178
|
-
if [[ -n "$rvm_ruby_string" ]] ; then
|
179
|
-
__rvm_select
|
180
|
-
fi
|
181
|
-
|
182
|
-
prefix=$(echo $rvm_ruby_gem_home | sed 's/'${rvm_gemset_separator:-"@"}'.*$//')
|
183
|
-
|
184
|
-
gemsets=(${args[@]})
|
185
|
-
|
186
|
-
for gemset in "${gemsets[@]}" ; do
|
187
|
-
|
188
|
-
if [[ "$gemset" == *"${rvm_gemset_separator:-"@"}"* ]]; then
|
189
|
-
"$rvm_path/scripts/log" "error" \
|
190
|
-
"Can not create gemset '$gemset', it contains a \"${rvm_gemset_separator:-"@"}\"."
|
191
|
-
continue
|
192
|
-
fi
|
193
|
-
|
194
|
-
if [[ -z "$gemset" || "$gemset" = *"${rvm_gemset_separator:-"@"}" ]] ; then
|
195
|
-
"$rvm_path/scripts/log" "error" \
|
196
|
-
"Can not create gemset '$gemset', Missing name. "
|
197
|
-
continue
|
198
|
-
fi
|
199
|
-
|
200
|
-
gem_home="${prefix}${rvm_gemset_separator:-"@"}${gemset}"
|
201
|
-
|
202
|
-
if [[ ! -d "$gem_home" ]] ; then
|
203
|
-
mkdir -p "$gem_home"
|
204
|
-
fi
|
205
|
-
|
206
|
-
# When the globalcache is enabled, we need to ensure we setup the cache directory correctly.
|
207
|
-
if __rvm_using_gemset_globalcache ; then
|
208
|
-
|
209
|
-
if [[ -d "$gem_home/cache" && ! -L "$gem_home/cache" ]]; then
|
210
|
-
|
211
|
-
mv "$gem_home/cache"/*.gem "$rvm_gems_cache_path/" 2>/dev/null
|
212
|
-
|
213
|
-
rm -rf "$gem_home/cache"
|
214
|
-
fi
|
215
|
-
|
216
|
-
ln -nfs "$rvm_gems_cache_path" "$gem_home/cache"
|
217
|
-
fi
|
218
|
-
|
219
|
-
"$rvm_path/scripts/log" "info" "'$gemset' gemset created ($gem_home)."
|
220
|
-
done
|
221
|
-
|
222
|
-
return 0
|
223
|
-
}
|
224
|
-
|
225
|
-
gemset_list()
|
226
|
-
{
|
227
|
-
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
228
|
-
|
229
|
-
"$rvm_path/scripts/log" "info" \
|
230
|
-
"\ngemsets for $rvm_ruby_string (found in ${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string)"
|
231
|
-
|
232
|
-
if [[ -d "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
|
233
|
-
|
234
|
-
if [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
235
|
-
|
236
|
-
ls "${rvm_gems_path:-"$rvm_path/gems"}/" \
|
237
|
-
| awk -F"${rvm_gemset_separator:-"@"}" \
|
238
|
-
"/${rvm_ruby_string}${rvm_gemset_separator:-"@"}/{print \$2}" \
|
239
|
-
2>/dev/null
|
240
|
-
|
241
|
-
else
|
242
|
-
"$rvm_path/scripts/log" "error" \
|
243
|
-
"\$rvm_ruby_string is not set!"
|
244
|
-
return 1
|
245
|
-
fi
|
246
|
-
|
247
|
-
else
|
248
|
-
"$rvm_path/scripts/log" "error" \
|
249
|
-
"${rvm_gems_path:-"$rvm_path/gems"} does not exist!"
|
250
|
-
return 1
|
251
|
-
fi
|
252
|
-
printf "\n"
|
253
|
-
|
254
|
-
return 0
|
255
|
-
}
|
256
|
-
|
257
|
-
gemset_delete()
|
258
|
-
{
|
259
|
-
gemsets=(${args[@]})
|
260
|
-
|
261
|
-
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
262
|
-
|
263
|
-
if [[ -n "${gemsets[__array_start]}" ]] ; then
|
264
|
-
rvm_gemset_name="${gemsets[__array_start]}"
|
265
|
-
fi
|
266
|
-
|
267
|
-
if [[ -n "$rvm_gemset_name" ]] ; then
|
268
|
-
|
269
|
-
gemdir="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name"
|
270
|
-
|
271
|
-
if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]] ; then
|
272
|
-
|
273
|
-
rm -rf "$gemdir"
|
274
|
-
|
275
|
-
elif [[ -d "$gemdir" ]] ; then
|
276
|
-
|
277
|
-
"$rvm_path/scripts/log" "warn" \
|
278
|
-
"Are you SURE you wish to remove the entire gemset directory '$rvm_gemset_name' ($gemdir)?"
|
279
|
-
|
280
|
-
printf "(anything other than 'yes' will cancel) > "
|
281
|
-
|
282
|
-
read response
|
283
|
-
|
284
|
-
if [[ "yes" = "$response" ]] ; then
|
285
|
-
|
286
|
-
if [[ -L "$gemdir/cache" ]] ; then
|
287
|
-
rm -f "$gemdir/cache"
|
288
|
-
fi
|
289
|
-
|
290
|
-
rm -rf "$gemdir"
|
291
|
-
|
292
|
-
else
|
293
|
-
"$rvm_path/scripts/log" "info" \
|
294
|
-
"Not doing anything, phew... close call that one eh?"
|
295
|
-
fi
|
296
|
-
|
297
|
-
else
|
298
|
-
"$rvm_path/scripts/log" "info" \
|
299
|
-
"$gemdir already does not exist."
|
300
|
-
fi
|
301
|
-
|
302
|
-
else
|
303
|
-
"$rvm_path/scripts/log" "error" \
|
304
|
-
"A gemset name must be specified in order to delete a gems."
|
305
|
-
return 1
|
306
|
-
fi
|
307
|
-
|
308
|
-
return 0
|
309
|
-
}
|
310
|
-
|
311
|
-
gemset_empty()
|
312
|
-
{
|
313
|
-
local gemdir
|
314
|
-
|
315
|
-
if [[ -z "${rvm_ruby_gem_home:-""}" ]] ; then __rvm_select ; fi
|
316
|
-
|
317
|
-
gemdir="$rvm_ruby_gem_home"
|
318
|
-
|
319
|
-
if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]] ; then
|
320
|
-
|
321
|
-
builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
|
322
|
-
|
323
|
-
elif [[ -d "$gemdir" ]] ; then
|
324
|
-
|
325
|
-
"$rvm_path/scripts/log" "warn" \
|
326
|
-
"Are you SURE you wish to remove the installed gemset for gemset '$(basename "$gemdir")' ($gemdir)?"
|
327
|
-
|
328
|
-
echo -n "(anything other than 'yes' will cancel) > "
|
329
|
-
|
330
|
-
read response
|
331
|
-
|
332
|
-
if [[ "yes" = "$response" ]] ; then
|
333
|
-
|
334
|
-
builtin cd "$gemdir" && rm -rf ./bin/* ./doc/* ./gems/* ./specifications/*
|
335
|
-
|
336
|
-
else
|
337
|
-
"$rvm_path/scripts/log" "info" \
|
338
|
-
"Not doing anything, phew... close call that one eh?"
|
339
|
-
fi
|
340
|
-
|
341
|
-
else
|
342
|
-
"$rvm_path/scripts/log" "info" \
|
343
|
-
"$gemdir already does not exist."
|
344
|
-
fi
|
345
|
-
|
346
|
-
return 0
|
347
|
-
}
|
348
|
-
|
349
|
-
# Migrate gemsets from ruby X to ruby Y
|
350
|
-
gemset_copy()
|
351
|
-
{
|
352
|
-
local source_ruby destination_ruby source_path destination_path
|
353
|
-
|
354
|
-
source_ruby="${args[__array_start]:-""}"
|
355
|
-
args[$__array_start]="" ; args=(${args[@]})
|
356
|
-
|
357
|
-
destination_ruby="${args[__array_start]:-""}"
|
358
|
-
args[$__array_start]="" ; args=(${args[@]})
|
359
|
-
|
360
|
-
if [[ -z "$destination_ruby" || -z "$source_ruby" ]] ; then
|
361
|
-
"$rvm_path/scripts/log" "error" "Source and destination must be specified: 'rvm gemset copy X Y'"
|
362
|
-
return 1
|
363
|
-
fi
|
364
|
-
|
365
|
-
# TODO: Account for more possibilities:
|
366
|
-
# rvm gemset copy 1.9.2 @gemsetb # From 1.9.2 default to current ruby, 1.9.2 exists.
|
367
|
-
# rvm gemset copy @gemseta @gemsetb # Current ruby, gemseta exists.
|
368
|
-
# rvm gemset copy gemseta gemsetb # Currenty Ruby, gemseta exists.
|
369
|
-
# rvm gemset copy gemseta 1.8.7@gemsetb # Currenty Ruby@gemseta, current ruby@gemseta exists.
|
370
|
-
|
371
|
-
source_path="$(rvm_silence_logging=1 rvm "$source_ruby" gem env gemdir)"
|
372
|
-
|
373
|
-
destination_path="$(rvm_silence_logging=1 rvm "$destination_ruby" gem env gemdir)"
|
374
|
-
|
375
|
-
if [[ -z "$source_path" || ! -d "$source_path" ]]; then
|
376
|
-
"$rvm_path/scripts/log" "error" \
|
377
|
-
"Unable to expand '$source_ruby' or directory does not exist."
|
378
|
-
return 1
|
379
|
-
fi
|
380
|
-
|
381
|
-
if [[ -z "$destination_path" ]]; then
|
382
|
-
"$rvm_path/scripts/log" "error" \
|
383
|
-
"Unable to expand '$destination_ruby'"
|
384
|
-
return 1
|
385
|
-
fi
|
386
|
-
|
387
|
-
if [[ -d "$source_path" ]] ; then
|
388
|
-
|
389
|
-
"$rvm_path/scripts/log" "info" "Copying gemset from $source_ruby to $destination_ruby"
|
390
|
-
|
391
|
-
for dir in bin doc gems specifications cache ; do
|
392
|
-
|
393
|
-
mkdir -p "$destination_path/$dir"
|
394
|
-
|
395
|
-
if [[ -d "$source_path/$dir" ]] ; then
|
396
|
-
cp -Rf "$source_path/$dir" "$destination_path/"
|
397
|
-
|
398
|
-
elif [[ -L "$source_path/$dir" ]] ; then
|
399
|
-
cp "$source_path/$dir" "$destination_path/$dir"
|
400
|
-
fi
|
401
|
-
|
402
|
-
done
|
403
|
-
|
404
|
-
"$rvm_path/scripts/log" "info" \
|
405
|
-
"Making gemset for $destination_ruby pristine."
|
406
|
-
|
407
|
-
__rvm_run_with_env "gemset.pristine" "$destination_ruby" "rvm gemset pristine"
|
408
|
-
|
409
|
-
else
|
410
|
-
"$rvm_path/scripts/log" "error" \
|
411
|
-
"Gems directory does not exist for $source_path ($source_path)"
|
412
|
-
return 1
|
413
|
-
fi
|
414
|
-
}
|
415
|
-
|
416
|
-
# Migrate gemsets from ruby X to ruby Y
|
417
|
-
gemset_rename()
|
418
|
-
{
|
419
|
-
local source_name destination_name source_path destination_path
|
420
|
-
|
421
|
-
source_name="${args[__array_start]:-""}"
|
422
|
-
args[$__array_start]="" ; args=(${args[@]})
|
423
|
-
|
424
|
-
destination_name="${args[__array_start]:-""}"
|
425
|
-
args[$__array_start]="" ; args=(${args[@]})
|
426
|
-
|
427
|
-
if [[ -z "$destination_name" || -z "$source_name" ]] ; then
|
428
|
-
"$rvm_path/scripts/log" "error" \
|
429
|
-
"Source and destination gemsets must be specified: 'rvm gemset rename X Y'"
|
430
|
-
return 1
|
431
|
-
fi
|
432
|
-
|
433
|
-
source_path="$(rvm_silence_logging=1 rvm "@$source_name" gem env gemdir)"
|
434
|
-
|
435
|
-
if [[ -z "$source_path" || ! -d "$source_path" ]]; then
|
436
|
-
"$rvm_path/scripts/log" "error" \
|
437
|
-
"'$source_name' does not exist."
|
438
|
-
return 1
|
439
|
-
fi
|
440
|
-
|
441
|
-
destination_path=${source_path/%$source_name/$destination_name}
|
442
|
-
|
443
|
-
if [[ -d "$source_path" ]] ; then
|
444
|
-
|
445
|
-
if [[ ! -d "$destination_path" ]] ; then
|
446
|
-
|
447
|
-
mv "$source_path" "$destination_path"
|
448
|
-
|
449
|
-
else
|
450
|
-
|
451
|
-
"$rvm_path/scripts/log" "error" \
|
452
|
-
"Gemset $destination_name already exists!"
|
453
|
-
|
454
|
-
return 1
|
455
|
-
|
456
|
-
fi
|
457
|
-
|
458
|
-
else
|
459
|
-
|
460
|
-
"$rvm_path/scripts/log" "error" \
|
461
|
-
"Gems directory does not exist for $source_path ($source_path)"
|
462
|
-
|
463
|
-
return 1
|
464
|
-
|
465
|
-
fi
|
466
|
-
}
|
467
|
-
|
468
|
-
|
469
|
-
gemset_unpack()
|
470
|
-
{
|
471
|
-
local gems name directory version versions
|
472
|
-
|
473
|
-
directory="${args[$__array_start]}"
|
474
|
-
|
475
|
-
if [[ -z "$directory" ]] ; then
|
476
|
-
directory="vendor/gems"
|
477
|
-
fi
|
478
|
-
|
479
|
-
if [[ -n "$rvm_ruby_gem_home" ]] ; then
|
480
|
-
export GEM_HOME="$rvm_ruby_gem_home"
|
481
|
-
export GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
|
482
|
-
fi
|
483
|
-
|
484
|
-
"$rvm_path/scripts/log" "info" \
|
485
|
-
"Unpacking current environments gemset to ${directory}\n"
|
486
|
-
|
487
|
-
unset -f gem
|
488
|
-
|
489
|
-
gems=($(command gem list | sed 's#[\(|\)]##g' | sed -e 's#, #,#g' -e 's/ /;/g'))
|
490
|
-
|
491
|
-
for gem in ${gems[@]} ; do
|
492
|
-
|
493
|
-
name="${gem/;*/}"
|
494
|
-
|
495
|
-
versions="${gem/*;/}" ; versions=(${versions//,/ })
|
496
|
-
|
497
|
-
for version in "${versions[@]}" ; do
|
498
|
-
|
499
|
-
( command gem unpack "$name" -v"$version" --target "$directory" )&
|
500
|
-
|
501
|
-
done
|
502
|
-
|
503
|
-
done ; wait
|
504
|
-
|
505
|
-
"$rvm_path/scripts/log" "info" \
|
506
|
-
"Unpacking into ${directory} complete\n"
|
507
|
-
|
508
|
-
return 0
|
509
|
-
}
|
510
|
-
|
511
|
-
gemset_export()
|
512
|
-
{
|
513
|
-
local gems name file_name version versions
|
514
|
-
|
515
|
-
rvm_file_name="${rvm_file_name:-${gems_args// }}"
|
516
|
-
|
517
|
-
if [[ -n "$rvm_ruby_gem_home" ]] ; then
|
518
|
-
export GEM_HOME="$rvm_ruby_gem_home"
|
519
|
-
export GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
|
520
|
-
fi
|
521
|
-
|
522
|
-
if [[ -z "$rvm_file_name" ]] ; then
|
523
|
-
|
524
|
-
if [[ -n "$rvm_gemset_name" ]] ; then
|
525
|
-
rvm_file_name="$rvm_gemset_name.gems"
|
526
|
-
|
527
|
-
else
|
528
|
-
rvm_file_name="default.gems"
|
529
|
-
fi
|
530
|
-
fi
|
531
|
-
|
532
|
-
"$rvm_path/scripts/log" "info" \
|
533
|
-
"Exporting current environments gemset to $rvm_file_name"
|
534
|
-
|
535
|
-
touch "$rvm_file_name"
|
536
|
-
|
537
|
-
echo "# $rvm_file_name generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator" \
|
538
|
-
> "$rvm_file_name"
|
539
|
-
|
540
|
-
gems=($(gem list | sed 's#[\(|\)]##g' | sed 's#, #,#g' | tr ' ' ';'))
|
541
|
-
|
542
|
-
for gem in "${gems[@]}" ; do
|
543
|
-
|
544
|
-
name="${gem/;*/}"
|
545
|
-
|
546
|
-
if [[ ${rvm_latest_flag:-0} -eq 0 ]] ; then
|
547
|
-
|
548
|
-
versions="${gem/*;/}" ; versions="${versions//,/ }"
|
549
|
-
|
550
|
-
for version in $versions ; do
|
551
|
-
echo "$name -v$version" >> $rvm_file_name
|
552
|
-
done ; unset version versions
|
553
|
-
|
554
|
-
else
|
555
|
-
echo "$name" >> $rvm_file_name
|
556
|
-
fi
|
557
|
-
done
|
558
|
-
|
559
|
-
return 0
|
560
|
-
}
|
561
|
-
|
562
|
-
gemset_import()
|
563
|
-
{
|
564
|
-
unset -f gem
|
565
|
-
|
566
|
-
if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then
|
567
|
-
export GEM_HOME="$rvm_ruby_gem_home"
|
568
|
-
export GEM_PATH="$rvm_ruby_gem_home"
|
569
|
-
else
|
570
|
-
rvm_ruby_gem_home=${GEM_HOME:-$(gem env gemdir)}
|
571
|
-
fi
|
572
|
-
|
573
|
-
#rvm_gemset_name="${gems_args//.gem*/}"
|
574
|
-
#rvm_gemset_name="${gems_args// /}"
|
575
|
-
|
576
|
-
rvm_file_name="${gems_args// /}"
|
577
|
-
|
578
|
-
# TODO: this could likely be better with find
|
579
|
-
if [[ -s "${rvm_file_name%.gems*}.gems" ]] ; then
|
580
|
-
rvm_file_name="${rvm_file_name%.gems*}.gems"
|
581
|
-
|
582
|
-
elif [[ -s "${rvm_gemset_name}.gems" ]] ; then
|
583
|
-
rvm_file_name="${rvm_gemset_name}.gems"
|
584
|
-
|
585
|
-
elif [[ -s "default.gems" ]] ; then
|
586
|
-
rvm_file_name="default.gems"
|
587
|
-
|
588
|
-
elif [[ -s "system.gems" ]] ; then
|
589
|
-
rvm_file_name="system.gems"
|
590
|
-
|
591
|
-
elif [[ -s ".gems" ]] ; then
|
592
|
-
rvm_file_name=".gems"
|
593
|
-
|
594
|
-
else
|
595
|
-
"$rvm_path/scripts/log" "error" "No *.gems file found."
|
596
|
-
return 1
|
597
|
-
fi
|
598
|
-
|
599
|
-
if [[ ! -d "$rvm_ruby_gem_home/specifications/" ]] ; then
|
600
|
-
mkdir -p "$rvm_ruby_gem_home/specifications/"
|
601
|
-
fi
|
602
|
-
|
603
|
-
if [[ ! -d "$rvm_gems_cache_path" ]] ; then
|
604
|
-
mkdir -p "$rvm_gems_cache_path" # Ensure the base cache dir is initialized.
|
605
|
-
fi
|
606
|
-
|
607
|
-
if [[ -s "$rvm_file_name" ]] ; then
|
608
|
-
|
609
|
-
printf "\nInstalling gems listed in $rvm_file_name file...\n\n"
|
610
|
-
|
611
|
-
rvm_ruby_gem_list=$(
|
612
|
-
builtin cd "$rvm_ruby_gem_home/specifications/" ;
|
613
|
-
find . -maxdepth 1 -mindepth 1 -type f -print 2> /dev/null | \
|
614
|
-
sed -e 's#.gems.*$##' -e 's#^./##g' 2> /dev/null
|
615
|
-
)
|
616
|
-
# rvm_ruby_gem_list="${rvm_ruby_gem_list//.\/}"
|
617
|
-
|
618
|
-
while read -r line
|
619
|
-
do # Keep this on 2nd line :(
|
620
|
-
|
621
|
-
if [[ -n "${line// /}" ]] ; then
|
622
|
-
gems_args="$line" ; gem_install
|
623
|
-
fi
|
624
|
-
|
625
|
-
done < <(awk '/^[^#]+/{print}' "${rvm_file_name}")
|
626
|
-
|
627
|
-
printf "\nProcessing of $rvm_file_name is complete.\n\n"
|
628
|
-
|
629
|
-
else
|
630
|
-
"$rvm_path/scripts/log" "error" \
|
631
|
-
"${rvm_file_name} does not exist to import from."
|
632
|
-
fi
|
633
|
-
}
|
634
|
-
|
635
|
-
__rvm_parse_gems_args()
|
636
|
-
{
|
637
|
-
gem="${gems_args/;*}" ; gem_prefix=""
|
638
|
-
|
639
|
-
if echo "$gems_args" | grep -q ';' ; then
|
640
|
-
gem_prefix="${gems_args/*;}"
|
641
|
-
fi
|
642
|
-
|
643
|
-
if "$rvm_path/scripts/match" "$gem" ".gem$" ; then
|
644
|
-
gem_name="$(basename "${gem/.gem/}" | awk -F'-' '{$NF=NULL;print}')"
|
645
|
-
gem_version="$(basename "${gem/.gem/}" | awk -F'-' '{print $NF}' )"
|
646
|
-
gem_postfix="$(basename "${gem/*.gem/}")"
|
647
|
-
|
648
|
-
else
|
649
|
-
gem_name="${gem/ */}"
|
650
|
-
|
651
|
-
if "$rvm_path/scripts/match" "$gem" "--version" ; then
|
652
|
-
gem_version="$(echo "$gem" | sed -e 's#.*--version[=]*[ ]*##' | awk '{print $1}')"
|
653
|
-
gem_postfix="$(echo "$gem" | sed -e "s#${gem_name/ /}##" -e "s#--version[=]*[ ]*${gem_version/ /}##")"
|
654
|
-
|
655
|
-
elif "$rvm_path/scripts/match" "$gem" "-v" ; then
|
656
|
-
gem_version="$(echo "$gem" | sed -e 's#.*-v[=]*[ ]*##' | awk '{print $1}')"
|
657
|
-
gem_postfix="$(echo "$gem" | sed -e "s#${gem_name/ /}##" -e "s#-v[=]*[ ]*${gem_version/ /}##")"
|
658
|
-
|
659
|
-
else
|
660
|
-
unset gem_version # no version
|
661
|
-
fi
|
662
|
-
fi
|
663
|
-
|
664
|
-
if [[ -s "$gem" ]] ; then
|
665
|
-
gem_file_name="$gem"
|
666
|
-
|
667
|
-
elif "$rvm_path/scripts/match" "$gem" ".gem$" ; then
|
668
|
-
gem_file_name="$gem"
|
669
|
-
|
670
|
-
elif [[ -z "${gem_version/ /}" ]] ; then
|
671
|
-
gem_file_name="${gem_name/ /}*.gem"
|
672
|
-
|
673
|
-
else # version
|
674
|
-
gem_file_name="${gem_name/ /}-${gem_version/ /}.gem"
|
675
|
-
fi
|
676
|
-
}
|
677
|
-
|
678
|
-
# Install a gem
|
679
|
-
gem_install()
|
680
|
-
{
|
681
|
-
local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action
|
682
|
-
|
683
|
-
result=0
|
684
|
-
|
685
|
-
# First we parse the gem args to pick apart the pieces.
|
686
|
-
__rvm_parse_gems_args
|
687
|
-
|
688
|
-
# Now we determine if a .gem cache file is already installed
|
689
|
-
if [[ ${rvm_force_flag:-0} -eq 0 && -f "${rvm_ruby_gem_home}/specifications/$(basename "$gem_file_name")spec" ]] ; then
|
690
|
-
gem=""
|
691
|
-
|
692
|
-
"$rvm_path/scripts/log" "info" "$gem_name $gem_version is already installed."
|
693
|
-
|
694
|
-
else
|
695
|
-
if [[ -s "$gem" ]] ; then
|
696
|
-
cache_file="$gem"
|
697
|
-
|
698
|
-
elif [[ -s "$(__rvm_current_gemcache_dir)/${gem_file_name}" ]] ; then
|
699
|
-
cache_file="$(__rvm_current_gemcache_dir)/${gem_file_name}"
|
700
|
-
|
701
|
-
else
|
702
|
-
cache_file="${cache_file:-$( find "$(__rvm_current_gemcache_dir)/${gem_file_name}" -maxdepth 1 -mindepth 1 -type f -print 2> /dev/null | sort | head -n1)}"
|
703
|
-
cache_file="${cache_file//.\/}"
|
704
|
-
fi
|
705
|
-
|
706
|
-
if [[ ! -s "$cache_file" ]] ; then
|
707
|
-
|
708
|
-
if [[ -s "$gem_file_name" ]] ; then
|
709
|
-
gem="$gem_file_name"
|
710
|
-
|
711
|
-
elif [[ -z "${gem_version// /}" ]] ; then
|
712
|
-
gem="${gem_name// /}"
|
713
|
-
|
714
|
-
else
|
715
|
-
gem="${gem_name// /} -v $gem_version"
|
716
|
-
fi
|
717
|
-
else # cached
|
718
|
-
|
719
|
-
gem_file_name="$(basename "$cache_file")"
|
720
|
-
|
721
|
-
gem_string="$(echo "$gem_file_name" | sed 's#\.gem$##')"
|
722
|
-
|
723
|
-
if [[ ${rvm_force_flag:-0} -eq 0 && -s "${rvm_ruby_gem_home}/specifications/$(basename $gem_file_name)spec" ]] ; then
|
724
|
-
unset gem # already installed, not forcing reinstall.
|
725
|
-
|
726
|
-
"$rvm_path/scripts/log" "info" "$gem_name $gem_version exists, skipping (--force to re-install)"
|
727
|
-
|
728
|
-
else
|
729
|
-
if [[ -s "$(__rvm_current_gemcache_dir)/$(basename $gem_file_name)" ]] ; then
|
730
|
-
|
731
|
-
mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/"
|
732
|
-
|
733
|
-
mv "$(__rvm_current_gemcache_dir)/$gem_file_name" "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name"
|
734
|
-
|
735
|
-
gem="${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name -f -l"
|
736
|
-
else
|
737
|
-
gem="$cache_file"
|
738
|
-
fi
|
739
|
-
fi
|
740
|
-
fi
|
741
|
-
fi
|
742
|
-
|
743
|
-
# If $gem is still set, go forward with the install.
|
744
|
-
if [[ -n "$gem" ]] ; then
|
745
|
-
|
746
|
-
# TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line.
|
747
|
-
if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi
|
748
|
-
|
749
|
-
if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then
|
750
|
-
|
751
|
-
command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home' $gem_prefix gem install $gems_args $rvm_gem_options $gem_postfix $vars"
|
752
|
-
|
753
|
-
else
|
754
|
-
|
755
|
-
command="$gem_prefix gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars"
|
756
|
-
|
757
|
-
fi
|
758
|
-
|
759
|
-
unset -f gem
|
760
|
-
|
761
|
-
__rvm_run "gem.install" "$command" \
|
762
|
-
"installing ${gem_name} ${gem_version}..."
|
763
|
-
result=$?
|
764
|
-
|
765
|
-
if [[ $result -eq 0 ]] ; then
|
766
|
-
|
767
|
-
"$rvm_path/scripts/log" "info" \
|
768
|
-
"$gem_name $gem_version installed."
|
769
|
-
|
770
|
-
else
|
771
|
-
|
772
|
-
"$rvm_path/scripts/log" "error" \
|
773
|
-
"$gem_name $gem_version failed to install ( output logged to: $rvm_path/log/$rvm_ruby_string/gem.install.log )"
|
774
|
-
|
775
|
-
fi
|
776
|
-
fi
|
777
|
-
|
778
|
-
return $result
|
779
|
-
}
|
780
|
-
|
781
|
-
# Output the user's current gem directory.
|
782
|
-
gemset_info()
|
783
|
-
{
|
784
|
-
if [[ ${rvm_user_flag:-0} -eq 1 ]] ; then
|
785
|
-
|
786
|
-
echo $(rvm system ; gem env | grep "\- $HOME" | awk '{print $NF}')
|
787
|
-
|
788
|
-
elif [[ ${rvm_system_flag:-0} -eq 1 ]] ; then
|
789
|
-
|
790
|
-
echo $(rvm system ; gem env $action system)
|
791
|
-
|
792
|
-
elif [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
793
|
-
|
794
|
-
echo $(rvm "$rvm_ruby_string" ; gem env $action)
|
795
|
-
|
796
|
-
elif [[ -n "${GEM_HOME:-""}" ]] ; then
|
797
|
-
|
798
|
-
echo "$GEM_HOME"
|
799
|
-
|
800
|
-
else
|
801
|
-
|
802
|
-
gem env $action
|
803
|
-
|
804
|
-
fi
|
805
|
-
|
806
|
-
return $?
|
807
|
-
}
|
808
|
-
|
809
|
-
gemset_prune()
|
810
|
-
{
|
811
|
-
local temporary_cache_path live_cache_path gemset_name version versions cached_gem_name cached_file_path
|
812
|
-
|
813
|
-
temporary_cache_path="$GEM_HOME/temporary-cache"
|
814
|
-
|
815
|
-
live_cache_path="$GEM_HOME/cache"
|
816
|
-
|
817
|
-
mkdir -p "$temporary_cache_path"
|
818
|
-
|
819
|
-
"$rvm_path/scripts/log" "info" \
|
820
|
-
"Moving active gems into temporary cache..."
|
821
|
-
|
822
|
-
while read -r used_gem
|
823
|
-
do
|
824
|
-
gem_name="$(echo "$used_gem" | sed -e 's/ .*//')"
|
825
|
-
|
826
|
-
versions="$(echo "${used_gem//, / }" | sed -e 's/.* (//' -e 's/)//')"
|
827
|
-
|
828
|
-
for version in $versions; do
|
829
|
-
|
830
|
-
cached_gem_name="${gem_name}-${version}.gem"
|
831
|
-
|
832
|
-
cached_file_path="${live_cache_path}/${cached_gem_name}"
|
833
|
-
|
834
|
-
if [[ -f "$cached_file_path" ]]; then
|
835
|
-
mv "$cached_file_path" "${temporary_cache_path}/${cached_gem_name}"
|
836
|
-
fi
|
837
|
-
done
|
838
|
-
done < <(gem list --versions)
|
839
|
-
|
840
|
-
"$rvm_path/scripts/log" "info" \
|
841
|
-
"Removing live cache and restoring temporary cache..."
|
842
|
-
|
843
|
-
# Switch the cache back.
|
844
|
-
rm -rf "$live_cache_path"
|
845
|
-
|
846
|
-
mv "$temporary_cache_path" "$live_cache_path"
|
847
|
-
|
848
|
-
return 0
|
849
|
-
}
|
850
|
-
|
851
|
-
gemset_pristine()
|
852
|
-
{
|
853
|
-
if ( unset -f gem ; command -v gem > /dev/null ) ; then
|
854
|
-
|
855
|
-
gem pristine --all
|
856
|
-
|
857
|
-
return $?
|
858
|
-
|
859
|
-
else
|
860
|
-
|
861
|
-
"$rvm_path/scripts/log" "error" \
|
862
|
-
"'gem' command not found in PATH"
|
863
|
-
|
864
|
-
return 1
|
865
|
-
fi
|
866
|
-
}
|
867
|
-
|
868
|
-
# Loads the default gemsets for the current interpreter and gemset.
|
869
|
-
gemset_initial()
|
870
|
-
{
|
871
|
-
local gemsets gemset path paths
|
872
|
-
|
873
|
-
rvm_gemsets_path="${rvm_gemsets_path:-"$rvm_path/gemsets"}"
|
874
|
-
|
875
|
-
"$rvm_path/scripts/log" "info" \
|
876
|
-
"Importing initial gemsets for $(__rvm_environment_identifier)."
|
877
|
-
|
878
|
-
if [[ ! -d "$rvm_gemsets_path/${rvm_ruby_string//-//}" ]] ; then
|
879
|
-
mkdir -p "$rvm_gemsets_path/${rvm_ruby_string//-//}" 2>/dev/null
|
880
|
-
fi
|
881
|
-
|
882
|
-
paths=($(__rvm_ruby_string_paths_under "$rvm_gemsets_path"))
|
883
|
-
|
884
|
-
echo "paths: ${paths[@]}"
|
885
|
-
|
886
|
-
for path in "${paths[@]}" ; do
|
887
|
-
|
888
|
-
if [[ -n "$rvm_gemset_name" ]] ; then
|
889
|
-
|
890
|
-
if [[ -s "${rvm_gemset_name}.gems" ]] ; then
|
891
|
-
|
892
|
-
( gems_args="${rvm_gemset_name}.gems" ; gemset_import )
|
893
|
-
|
894
|
-
fi
|
895
|
-
|
896
|
-
else
|
897
|
-
|
898
|
-
if [[ -s "${path}/default.gems" ]] ; then
|
899
|
-
|
900
|
-
( gems_args="${path}/default.gems" ; gemset_import )
|
901
|
-
|
902
|
-
fi
|
903
|
-
|
904
|
-
if [[ -s "${path}/global.gems" ]] ; then
|
905
|
-
|
906
|
-
(
|
907
|
-
rvm_create_flag=1
|
908
|
-
rvm_ruby_gem_home="${rvm_ruby_gem_home//@*/}@global"
|
909
|
-
gems_args="${path}/global.gems"
|
910
|
-
gemset_import
|
911
|
-
)
|
912
|
-
|
913
|
-
fi
|
914
|
-
|
915
|
-
fi
|
916
|
-
|
917
|
-
done
|
918
|
-
|
919
|
-
"$rvm_path/scripts/log" "info" \
|
920
|
-
"Installation of gems for $(__rvm_environment_identifier) is complete."
|
921
|
-
|
922
|
-
return 0
|
923
|
-
}
|
924
|
-
|
925
|
-
unset GEM_PATH
|
926
|
-
|
927
|
-
if ! command -v gem > /dev/null ; then
|
928
|
-
"$rvm_path/scripts/log" "error" \
|
929
|
-
"'gem' was not found, cannot perform gem actions (Do you have an RVM ruby selected?)"
|
930
|
-
exit 1
|
931
|
-
fi
|
932
|
-
|
933
|
-
args=($*)
|
934
|
-
action="${args[$__array_start]}"
|
935
|
-
args[$__array_start]=""
|
936
|
-
args=(${args[@]})
|
937
|
-
gems_args="$(echo ${args[@]}) " # Strip trailing / leading / extra spacing.
|
938
|
-
|
939
|
-
export rvm_gemset_name="${args[1]:-""}" # For wherever used.
|
940
|
-
rvm_sticky_flag=1
|
941
|
-
|
942
|
-
if [[ -z "$rvm_ruby_string" ]] ; then
|
943
|
-
|
944
|
-
if echo "${GEM_HOME:-""}" | grep -q 'rvm' ; then
|
945
|
-
|
946
|
-
rvm_ruby_string="${GEM_HOME##*/}"
|
947
|
-
|
948
|
-
rvm_ruby_string="${rvm_ruby_string%%@*}"
|
949
|
-
|
950
|
-
fi
|
951
|
-
|
952
|
-
fi
|
953
|
-
|
954
|
-
case "$action" in
|
955
|
-
|
956
|
-
import|load)
|
957
|
-
|
958
|
-
if [[ -z "${rvm_ruby_strings:-""}" ]]; then
|
959
|
-
|
960
|
-
gemset_import
|
961
|
-
|
962
|
-
else
|
963
|
-
original_env="$(__rvm_environment_identifier)"
|
964
|
-
|
965
|
-
for rvm_ruby_string in $(echo "$rvm_ruby_strings" | tr "," " "); do
|
966
|
-
|
967
|
-
__rvm_become
|
968
|
-
|
969
|
-
gemset_import
|
970
|
-
done
|
971
|
-
|
972
|
-
__rvm_become "$original_env"
|
973
|
-
|
974
|
-
unset original_env
|
975
|
-
fi
|
976
|
-
;;
|
977
|
-
export|dump)
|
978
|
-
gemset_export
|
979
|
-
;;
|
980
|
-
create)
|
981
|
-
gemset_create
|
982
|
-
;;
|
983
|
-
copy)
|
984
|
-
gemset_copy
|
985
|
-
;;
|
986
|
-
rename)
|
987
|
-
gemset_rename
|
988
|
-
;;
|
989
|
-
empty)
|
990
|
-
gemset_empty
|
991
|
-
;;
|
992
|
-
delete)
|
993
|
-
gemset_delete
|
994
|
-
;;
|
995
|
-
name|string)
|
996
|
-
gemset_name
|
997
|
-
;;
|
998
|
-
dir)
|
999
|
-
gemset_dir
|
1000
|
-
;;
|
1001
|
-
list)
|
1002
|
-
gemset_list
|
1003
|
-
;;
|
1004
|
-
list_all)
|
1005
|
-
gemset_list_all
|
1006
|
-
;;
|
1007
|
-
gemdir|gempath|gemhome|home|path|version)
|
1008
|
-
gemset_info
|
1009
|
-
;;
|
1010
|
-
install)
|
1011
|
-
gem_install "$@"
|
1012
|
-
;;
|
1013
|
-
pristine)
|
1014
|
-
gemset_pristine "$@"
|
1015
|
-
;;
|
1016
|
-
initial)
|
1017
|
-
gemset_initial
|
1018
|
-
;;
|
1019
|
-
prune)
|
1020
|
-
gemset_prune
|
1021
|
-
;;
|
1022
|
-
update)
|
1023
|
-
gemset_update
|
1024
|
-
;;
|
1025
|
-
unpack)
|
1026
|
-
gemset_unpack
|
1027
|
-
;;
|
1028
|
-
globalcache)
|
1029
|
-
gemset_globalcache "$2"
|
1030
|
-
;;
|
1031
|
-
clear)
|
1032
|
-
"$rvm_path/scripts/log" "info" "gemset cleared."
|
1033
|
-
exit 0
|
1034
|
-
;;
|
1035
|
-
help)
|
1036
|
-
usage
|
1037
|
-
exit 0
|
1038
|
-
;;
|
1039
|
-
*)
|
1040
|
-
usage
|
1041
|
-
exit 1
|
1042
|
-
;;
|
1043
|
-
esac
|
1044
|
-
|
1045
|
-
exit $?
|