gemrage 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +5 -0
- data/VERSION +1 -1
- data/gemrage.gemspec +148 -3
- data/lib/rubygems/commands/scan_command.rb +77 -4
- data/vendor/ruby/1.8/bin/rvm-install +19 -0
- data/vendor/ruby/1.8/cache/macaddr-1.0.0.gem +0 -0
- data/vendor/ruby/1.8/cache/rvm-1.0.14.gem +0 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/README +33 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/gemspec.rb +27 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/install.rb +210 -0
- data/vendor/ruby/1.8/gems/macaddr-1.0.0/lib/macaddr.rb +69 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/LICENCE +18 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/README +127 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/bin/rvm-install +5 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm +76 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-auto-ruby +24 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-prompt +204 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-shell +35 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-head +35 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvm-update-latest +27 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/binscripts/rvmsudo +24 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/db +71 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/known +55 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/config/md5 +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/gemset_snapshot +25 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/install-system-wide +191 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/contrib/r +44 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/examples/rvmrc +47 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/default.gems +1 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/gemsets/global.gems +1 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/alias +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/benchmark +17 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/cleanup +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/debug +8 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/disk-usage +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/docs +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/exec +33 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/fetch +5 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gem +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemdir +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/gemset +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/implode +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/info +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/install +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/list +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/migrate +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/monitor +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/notes +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/package +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rake +14 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/remove +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/repair +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/reset +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/ruby +84 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rubygems +11 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/rvmrc +34 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/snapshot +15 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/specs +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/srcdir +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tests +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/tools +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/uninstall +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/update +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/upgrade +18 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/use +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/help/wrapper +41 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/VERSION.yml +4 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/capistrano.rb +45 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/alias.rb +69 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/cleanup.rb +54 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/configuration.rb +60 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/env.rb +52 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/gemset.rb +222 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/info.rb +13 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/list.rb +124 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/rubies.rb +50 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/sets.rb +123 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/tools.rb +68 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/utility.rb +173 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment/wrapper.rb +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/environment.rb +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/errors.rb +31 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/install_command_dumper.rb +51 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/abstract_wrapper.rb +145 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/calculate_rvm_path.sh +26 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/result.rb +42 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/shell_wrapper.sh +10 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/single_shot_wrapper.rb +56 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell/utility.rb +37 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/shell.rb +25 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm/version.rb +19 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/lib/rvm.rb +156 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1 +385 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/man/man1/rvm.1.gz +0 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/rvm.gemspec +184 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/alias +225 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/aliases +4 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/array +32 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/base +49 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cd +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cleanup +58 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/cli +781 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/color +49 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/completion +151 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/db +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/default +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/disk-usage +60 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/docs +115 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/env +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/environment-convertor +74 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/fetch +229 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/gemsets +950 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hash +37 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/help +46 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/hook +23 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/info +214 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/initialize +29 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc +9 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/irbrc.rb +63 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/list +315 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/log +38 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/maglev +193 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/manage +2094 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/match +6 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/md5 +22 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/migrate +175 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/monitor +105 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/notes +121 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/override_gem +14 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/package +301 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patches +64 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/patchsets +87 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/repair +199 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rubygems +157 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm +120 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/rvm-install +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/selector +818 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/set +301 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/snapshot +262 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/tools +58 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/update +631 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/upgrade +144 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/utility +1557 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/version +17 -0
- data/vendor/ruby/1.8/gems/rvm-1.0.14/scripts/wrapper +210 -0
- data/vendor/ruby/1.8/specifications/macaddr-1.0.0.gemspec +27 -0
- data/vendor/ruby/1.8/specifications/rvm-1.0.14.gemspec +42 -0
- metadata +149 -4
@@ -0,0 +1,1557 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
__rvm_setup()
|
4
|
+
{
|
5
|
+
# ZSH has 1 based array indexing, bash has 0 based.
|
6
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
7
|
+
__shell_array_start=1
|
8
|
+
# Set clobber for zsh users, for compatibility with bash's append operator ( >> file ) behavior
|
9
|
+
setopt | \grep -qs '^noclobber$'
|
10
|
+
rvm_zsh_clobber=$?
|
11
|
+
setopt clobber
|
12
|
+
else
|
13
|
+
__shell_array_start=0 # bash array indexes are 0 based.
|
14
|
+
fi ; export __shell_array_start
|
15
|
+
}
|
16
|
+
|
17
|
+
__rvm_teardown()
|
18
|
+
{
|
19
|
+
if [[ -n "${ZSH_VERSION:-""}" ]] ; then
|
20
|
+
|
21
|
+
if [[ ${rvm_zsh_clobber:-0} -eq 0 ]] ; then
|
22
|
+
|
23
|
+
setopt noclobber
|
24
|
+
|
25
|
+
fi
|
26
|
+
|
27
|
+
unset rvm_zsh_clobber
|
28
|
+
|
29
|
+
else
|
30
|
+
: # currently we are not doing any option setting for bash.
|
31
|
+
fi
|
32
|
+
# Ruby strings are scoped to their action.
|
33
|
+
# Hence, we ensure we remove them at in
|
34
|
+
# the cleanup phase.
|
35
|
+
|
36
|
+
# Clean up after CC switch
|
37
|
+
if [[ ${rvm_clang_flag:-0} -gt 0 ]] ; then
|
38
|
+
|
39
|
+
if [[ -n "${rvm_prior_cc:-""}" ]] ; then
|
40
|
+
|
41
|
+
export CC="$rvm_prior_cc"
|
42
|
+
|
43
|
+
else
|
44
|
+
|
45
|
+
unset CC
|
46
|
+
|
47
|
+
fi
|
48
|
+
|
49
|
+
fi
|
50
|
+
|
51
|
+
unset rvm_ruby_strings rvm_head_flag rvm_prior_cc next_token rvm_bin_path rvm_error_message rvm_gems_cache_path rvm_gems_path rvm_gemset_name rvm_interactive_flag rvm_man_path rvm_parse_break rvm_rc_files rvm_ruby_binary rvm_ruby_gem_home rvm_ruby_gem_path rvm_ruby_home rvm_ruby_interpreter rvm_ruby_irbrc rvm_ruby_log_path rvm_ruby_major_version rvm_ruby_minor_version rvm_ruby_package_name rvm_ruby_patch_level rvm_ruby_release_version rvm_ruby_repo_url rvm_ruby_revision rvm_ruby_selected_flag rvm_ruby_tag rvm_ruby_version rvm_selfcontained rvm_token rvm_ruby_load_path rvm_path_flag rvm_ruby_require rvm_action
|
52
|
+
|
53
|
+
[[ ${rvm_dump_environment_flag:-0} -eq 1 ]] && __rvm_dump_environment
|
54
|
+
|
55
|
+
return 0
|
56
|
+
}
|
57
|
+
|
58
|
+
# Dump the current environment to a file.
|
59
|
+
__rvm_dump_environment()
|
60
|
+
{
|
61
|
+
# Note: This assumes that there is a ','
|
62
|
+
local dump_environment_file dump_environment_type rvm_dump_environment_flag
|
63
|
+
|
64
|
+
dump_environment_file="${rvm_dump_environment_flag/,*/}"
|
65
|
+
|
66
|
+
dump_environment_type="${rvm_dump_environment_flag/*,/}"
|
67
|
+
|
68
|
+
if [[ -n "$dump_environment_file" && -n "$dump_environment_type" ]]; then
|
69
|
+
|
70
|
+
if [[ "$dump_environment_type" == "atheis"* && -f "$dump_environment_file" ]] ; then
|
71
|
+
# TODO: Query Darcy about the ln.
|
72
|
+
\rm -f "$dump_environment_file" \
|
73
|
+
&& ln -s /dev/null "$dump_environment_file" >/dev/null 2>&1
|
74
|
+
|
75
|
+
else
|
76
|
+
"$rvm_path/scripts/environment-convertor" "$dump_environment_type" \
|
77
|
+
"$(__rvm_environment_identifier)" > "$dump_environment_file"
|
78
|
+
if [[ "$?" -gt 0 && -f "$dump_environment_file" ]] ; then
|
79
|
+
\rm -f "$dump_environment_file"
|
80
|
+
fi
|
81
|
+
fi
|
82
|
+
fi
|
83
|
+
|
84
|
+
return 0
|
85
|
+
}
|
86
|
+
|
87
|
+
# Return a list of directories under a given base path.
|
88
|
+
# Derived from rvm_ruby_string.
|
89
|
+
__rvm_ruby_string_paths_under()
|
90
|
+
{
|
91
|
+
local path part parts
|
92
|
+
|
93
|
+
path="${1%/}" # Strip off any trailing slash
|
94
|
+
|
95
|
+
parts=(${rvm_ruby_string//-/ }) # Strip white space.
|
96
|
+
|
97
|
+
echo "$path"
|
98
|
+
|
99
|
+
for part in "${parts[@]}" ; do
|
100
|
+
|
101
|
+
path="$path/$part"
|
102
|
+
|
103
|
+
echo "$path"
|
104
|
+
|
105
|
+
done
|
106
|
+
|
107
|
+
return 0
|
108
|
+
}
|
109
|
+
|
110
|
+
# Query the rvm key-value database for a specific key
|
111
|
+
# Allow overrides from user specifications in $rvm_path/config/user
|
112
|
+
__rvm_db()
|
113
|
+
{
|
114
|
+
local value key variable
|
115
|
+
|
116
|
+
key=${1:-""}
|
117
|
+
variable=${2:-""}
|
118
|
+
|
119
|
+
if [[ -f "$rvm_path/config/user" ]] ; then
|
120
|
+
value="$("$rvm_path/scripts/db" "$rvm_path/config/user" "$key")"
|
121
|
+
fi
|
122
|
+
|
123
|
+
if [[ -z "$value" ]] ; then
|
124
|
+
value="$("$rvm_path/scripts/db" "$rvm_path/config/db" "$key")"
|
125
|
+
fi
|
126
|
+
|
127
|
+
if [[ -n "$value" ]] ; then
|
128
|
+
if [[ -z "$variable" ]] ; then
|
129
|
+
echo $value
|
130
|
+
else
|
131
|
+
eval "$variable='$value'"
|
132
|
+
fi
|
133
|
+
fi
|
134
|
+
|
135
|
+
return 0
|
136
|
+
}
|
137
|
+
|
138
|
+
is_a_function() { type $1 | head -n 1 | \grep -q "function" ; }
|
139
|
+
|
140
|
+
__rvm_quote_args()
|
141
|
+
{
|
142
|
+
local quoted_string=""
|
143
|
+
|
144
|
+
for quoted_argument in "$@"; do
|
145
|
+
|
146
|
+
if printf "%s" "$quoted_argument" | \grep -vq "^[[:alnum:]]$"; then
|
147
|
+
|
148
|
+
quoted_string="$quoted_string '$(printf "%s" "$quoted_argument" \
|
149
|
+
| sed "s/'/\'\\\'\'/g")'"
|
150
|
+
|
151
|
+
else
|
152
|
+
quoted_string="$quoted_string $quoted_argument"
|
153
|
+
fi
|
154
|
+
done
|
155
|
+
|
156
|
+
echo "$quoted_string" | sed -e 's/^ *//g' -e 's/ *$//g'
|
157
|
+
|
158
|
+
return 0
|
159
|
+
}
|
160
|
+
|
161
|
+
__rvm_quote_args_with_shift()
|
162
|
+
{
|
163
|
+
local shift_value="$1"; shift
|
164
|
+
|
165
|
+
while [[ "$shift_value" -gt 0 && $# -gt 0 ]]; do
|
166
|
+
|
167
|
+
shift
|
168
|
+
|
169
|
+
((shift_value--))
|
170
|
+
|
171
|
+
done
|
172
|
+
|
173
|
+
__rvm_quote_args "$@"
|
174
|
+
|
175
|
+
return 0
|
176
|
+
}
|
177
|
+
|
178
|
+
__rvm_warn_on_rubyopt()
|
179
|
+
{
|
180
|
+
if [[ -n "${RUBYOPT:-""}" ]]; then
|
181
|
+
"$rvm_path/scripts"/log "warn" \
|
182
|
+
"Please note: You have the RUBYOPT environment variable set and this \
|
183
|
+
may interfere with normal rvm operations. We sugges unsetting it."
|
184
|
+
return 1
|
185
|
+
else
|
186
|
+
return 0
|
187
|
+
fi
|
188
|
+
}
|
189
|
+
|
190
|
+
__rvm_strings()
|
191
|
+
{
|
192
|
+
local strings ruby_strings
|
193
|
+
|
194
|
+
ruby_strings=($(echo ${rvm_ruby_args:-$rvm_ruby_string}))
|
195
|
+
|
196
|
+
for rvm_ruby_string in "${ruby_strings[@]}" ; do
|
197
|
+
strings="$strings $(__rvm_select ; echo $rvm_ruby_string)"
|
198
|
+
done
|
199
|
+
|
200
|
+
echo $strings
|
201
|
+
|
202
|
+
return 0
|
203
|
+
}
|
204
|
+
|
205
|
+
# Push an item onto a given array.
|
206
|
+
__rvm_push()
|
207
|
+
{
|
208
|
+
local array item
|
209
|
+
|
210
|
+
array=$1 ; shift ; item=$2
|
211
|
+
|
212
|
+
# TODO: allow loop over more arguments.
|
213
|
+
eval "index=\$((\${#${array}[*]} + $__shell_array_start))"
|
214
|
+
|
215
|
+
eval "${array}[${index}]=${item}"
|
216
|
+
|
217
|
+
return 0
|
218
|
+
}
|
219
|
+
|
220
|
+
# Clean all *duplicate* items out of the path. (keep first occurrence of each)
|
221
|
+
__rvm_clean_path()
|
222
|
+
{
|
223
|
+
PATH="$(printf "$PATH" | \tr -s ':' '\n' | awk '!($0 in a){a[$0];print}' \
|
224
|
+
| \tr -s '\n' ':' | sed 's#:$##')"
|
225
|
+
|
226
|
+
export PATH
|
227
|
+
|
228
|
+
builtin hash -r
|
229
|
+
}
|
230
|
+
|
231
|
+
# Clean all rvm items out of the current working path.
|
232
|
+
__rvm_remove_rvm_from_path()
|
233
|
+
{
|
234
|
+
PATH="$(printf "$PATH" \
|
235
|
+
| awk -v RS=: -v ORS=: "/${rvm_path//\//\/}/ {next} {print}" \
|
236
|
+
| sed -e 's#:$##')"
|
237
|
+
|
238
|
+
export PATH
|
239
|
+
|
240
|
+
builtin hash -r
|
241
|
+
}
|
242
|
+
|
243
|
+
# Run a specified command and log it.
|
244
|
+
__rvm_run()
|
245
|
+
{
|
246
|
+
local name log path command message
|
247
|
+
|
248
|
+
name="${1:-""}"
|
249
|
+
command="${2:-""}"
|
250
|
+
message="${3:-""}"
|
251
|
+
|
252
|
+
if [[ -n "$message" ]] ; then
|
253
|
+
"$rvm_path/scripts/log" "info" "$message"
|
254
|
+
fi
|
255
|
+
|
256
|
+
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
257
|
+
"$rvm_path/scripts/log" "debug" "Executing: $command"
|
258
|
+
fi
|
259
|
+
|
260
|
+
if [[ -n "${rvm_ruby_string:-""}" ]] ; then
|
261
|
+
path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
|
262
|
+
else
|
263
|
+
path="${rvm_log_path:-"$rvm_path/log"}"
|
264
|
+
fi
|
265
|
+
|
266
|
+
log="$path/$name.log"
|
267
|
+
|
268
|
+
if [[ ! -d "${log%\/*}" ]] ; then
|
269
|
+
\mkdir -p "${log%\/*}"
|
270
|
+
fi
|
271
|
+
|
272
|
+
\touch "$log" "${log/%.log/.error.log}" # for zsh :(
|
273
|
+
|
274
|
+
printf "[$(date +'%Y-%m-%d %H:%M:%S')] $command\n" | \
|
275
|
+
\tee "$log" \
|
276
|
+
>> "${log/%log/error.log}"
|
277
|
+
|
278
|
+
if [[ ${rvm_niceness:-0} -gt 0 ]] ; then
|
279
|
+
command="nice -n $rvm_niceness $command"
|
280
|
+
fi
|
281
|
+
|
282
|
+
eval "$command" \
|
283
|
+
>> "$log" \
|
284
|
+
2>> "${log/%log/error.log}"
|
285
|
+
|
286
|
+
result=$?
|
287
|
+
|
288
|
+
if [[ $result -gt 0 ]] ; then
|
289
|
+
"$rvm_path/scripts/log" "error" \
|
290
|
+
"Error running '$command', please check ${log/%log/error.log}"
|
291
|
+
fi
|
292
|
+
|
293
|
+
return ${result:-0}
|
294
|
+
}
|
295
|
+
|
296
|
+
# Runs a command in a given env.
|
297
|
+
__rvm_run_with_env()
|
298
|
+
{
|
299
|
+
local name environment command message log path
|
300
|
+
|
301
|
+
name="${1:-""}"
|
302
|
+
environment="${2:-""}"
|
303
|
+
command="${3:-""}"
|
304
|
+
message="${4:-""}"
|
305
|
+
|
306
|
+
if [[ -z "$environment" ]] ; then
|
307
|
+
environment="$(__rvm_environment_identifier)"
|
308
|
+
fi
|
309
|
+
|
310
|
+
if [[ -n "$message" ]] ; then
|
311
|
+
"$rvm_path/scripts/log" "info" "$message"
|
312
|
+
fi
|
313
|
+
|
314
|
+
if [[ ${rvm_debug_flag:-0} -gt 0 ]] ; then
|
315
|
+
"$rvm_path/scripts/log" "debug" \
|
316
|
+
"Executing: $command in environment $environment"
|
317
|
+
fi
|
318
|
+
|
319
|
+
path="${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
|
320
|
+
|
321
|
+
log="$path/$name.log"
|
322
|
+
|
323
|
+
if [[ ! -d "$path" ]] ; then
|
324
|
+
\mkdir -p "$path"
|
325
|
+
fi
|
326
|
+
|
327
|
+
\touch "$log" "${log/%.log/.error.log}" # for zsh :(
|
328
|
+
|
329
|
+
printf "[$(date +'%Y-%m-%d %H:%M:%S')] $command # under $environment\n" \
|
330
|
+
| tee "${log}" \
|
331
|
+
>> "${log/%log/error.log}"
|
332
|
+
|
333
|
+
if [[ ${rvm_niceness:-0} -gt 0 ]] ; then
|
334
|
+
command="nice -n $rvm_niceness $command"
|
335
|
+
fi
|
336
|
+
|
337
|
+
(
|
338
|
+
rvm_ruby_string="$environment"
|
339
|
+
|
340
|
+
__rvm_use
|
341
|
+
|
342
|
+
eval "$command" \
|
343
|
+
>> "${log}" \
|
344
|
+
2>> "${log/%log/error.log}"
|
345
|
+
)
|
346
|
+
|
347
|
+
result=$?
|
348
|
+
|
349
|
+
if [[ $result -gt 0 ]] ; then
|
350
|
+
"$rvm_path/scripts/log" "error" \
|
351
|
+
"Error running '$command' under $env_name,\
|
352
|
+
\nplease check ${log/%log/error.log}"
|
353
|
+
fi
|
354
|
+
|
355
|
+
return ${result:-0}
|
356
|
+
}
|
357
|
+
|
358
|
+
__rvm_nuke_rvm_variables()
|
359
|
+
{
|
360
|
+
unset rvm_head_flag $(env | awk -F= '/^rvm_/{print $1" "}')
|
361
|
+
}
|
362
|
+
|
363
|
+
# Unset ruby-specific variables
|
364
|
+
__rvm_unset_ruby_variables()
|
365
|
+
{
|
366
|
+
unset rvm_ruby_flag $(env | awk -F= '/^rvm_ruby_/{printf $1" "}')
|
367
|
+
}
|
368
|
+
|
369
|
+
# TODO: Should be able to...
|
370
|
+
# Unset both rvm variables as well as ruby-specific variables
|
371
|
+
# Preserve gemset if 'rvm_sticky' is set
|
372
|
+
# (persist gemset unless clear is explicitely called).
|
373
|
+
__rvm_cleanse_variables()
|
374
|
+
{
|
375
|
+
__rvm_unset_ruby_variables
|
376
|
+
|
377
|
+
if [[ ${rvm_sticky_flag:-0} -eq 1 ]] ; then
|
378
|
+
export rvm_gemset_name
|
379
|
+
else
|
380
|
+
unset rvm_gemset_name
|
381
|
+
fi
|
382
|
+
|
383
|
+
unset rvm_action rvm_irbrc_file rvm_command rvm_error_message rvm_force_flag rvm_all_flag rvm_reconfigure_flag rvm_make_flags rvm_bin_flag rvm_import_flag rvm_export_flag rvm_self_flag rvm_gem_flag rvm_rubygems_flag rvm_debug_flag rvm_delete_flag rvm_summary_flag rvm_test_flag _rvm_spec_flag rvm_json_flag rvm_yaml_flag rvm_shebang_flag rvm_env_flag rvm_tail_flag rvm_use_flag rvm_dir_flag rvm_list_flag rvm_empty_flag rvm_file_name rvm_benchmark_flag rvm_clear_flag rvm_name_flag rvm_verbose_flag rvm_user_flag rvm_system_flag rvm_configure_flags rvm_uninstall_flag rvm_install_flag rvm_llvm_flag rvm_ruby_bits rvm_sticky_flag rvm_rvmrc_flag rvm_gems_flag rvm_only_path_flag rvm_docs_flag rvm_ruby_aliases rvm_patch_names rvm_clang_flag rvm_install_arguments rvm_dump_environment_flag rvm_ruby_alias
|
384
|
+
}
|
385
|
+
|
386
|
+
# Returns the first 1.8.7-compatible (partly) ruby for use
|
387
|
+
# with things like rbx etc which require a ruby be installed.
|
388
|
+
__rvm_18_compat_ruby()
|
389
|
+
{
|
390
|
+
local rubies ruby_name
|
391
|
+
|
392
|
+
rubies=($( cd "$rvm_path/rubies" ; find . -maxdepth 1 -mindepth 1 -type d ))
|
393
|
+
|
394
|
+
for ruby_name in "${rubies[@]//.\/}"; do
|
395
|
+
|
396
|
+
if [[ ! -L "$rvm_path/rubies/$ruby_name" ]] ; then
|
397
|
+
|
398
|
+
case $ruby_name in
|
399
|
+
*1.8.*|rbx-*|ree-*) rubies="$rubies $ruby_name" ;;
|
400
|
+
esac
|
401
|
+
fi
|
402
|
+
done
|
403
|
+
|
404
|
+
echo $rubies | \tr ' ' '\n' | \sort | \tail -n1
|
405
|
+
|
406
|
+
return 0
|
407
|
+
}
|
408
|
+
|
409
|
+
__rvm_ensure_has_18_compat_ruby()
|
410
|
+
{
|
411
|
+
if [[ -z "$(__rvm_18_compat_ruby)" ]]; then
|
412
|
+
# TODO: install currently doesn't return the correct status.
|
413
|
+
local compat_result=0
|
414
|
+
|
415
|
+
if ! ( "$rvm_path/scripts/manage" install 1.8.7 ); then
|
416
|
+
|
417
|
+
"$rvm_path/scripts/log" "fail" \
|
418
|
+
"To proceed rvm requires a 1.8-compatible ruby is installed.\
|
419
|
+
\nWe attempted to install 1.8.7 automatically but it failed.\
|
420
|
+
\nPlease install it manually (or a compatible alternative) to proceed."
|
421
|
+
|
422
|
+
compat_result=1
|
423
|
+
|
424
|
+
fi
|
425
|
+
# unset original_ruby
|
426
|
+
# Question: Why *were* we unsetting original_ruby here
|
427
|
+
return $compat_result
|
428
|
+
fi
|
429
|
+
|
430
|
+
return 0
|
431
|
+
}
|
432
|
+
|
433
|
+
# Cleans up temp folders for a given prefix ($1),
|
434
|
+
# typically the current process id.
|
435
|
+
__rvm_cleanup_temp_for()
|
436
|
+
{
|
437
|
+
result=$? # Capture last command status
|
438
|
+
|
439
|
+
[[ -z "${1:-""}" ]] && return 1
|
440
|
+
|
441
|
+
if [[ -d "${rvm_tmp_path:-"$rvm_path/tmp"}/" ]]; then
|
442
|
+
|
443
|
+
\rm -rf "${rvm_tmp_path:-"$rvm_path/tmp"}/$1"* >/dev/null 2>&1
|
444
|
+
|
445
|
+
fi
|
446
|
+
|
447
|
+
return $result
|
448
|
+
}
|
449
|
+
|
450
|
+
__rvm_set_rvmrc()
|
451
|
+
{
|
452
|
+
local flags
|
453
|
+
|
454
|
+
if [[ "$HOME" != "$PWD" ]] ; then
|
455
|
+
|
456
|
+
if [[ ${rvm_verbose_flag:-0} -gt 0 ]] ; then
|
457
|
+
flags="use "
|
458
|
+
fi
|
459
|
+
|
460
|
+
if [[ -s .rvmrc ]] ; then
|
461
|
+
|
462
|
+
mv .rvmrc .rvmrc.$(date +%m.%d.%Y-%H:%M:%S)
|
463
|
+
|
464
|
+
"$rvm_path/scripts/log" "warning" \
|
465
|
+
".rvmrc is not empty, moving aside to preserve."
|
466
|
+
|
467
|
+
fi
|
468
|
+
|
469
|
+
local identifier=$(__rvm_environment_identifier)
|
470
|
+
|
471
|
+
printf "
|
472
|
+
if [[ -d \"\${rvm_path:-\$HOME/.rvm}/environments\" \\
|
473
|
+
&& -s \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\" ]] ; then
|
474
|
+
\\. \"\${rvm_path:-\$HOME/.rvm}/environments/$identifier\"
|
475
|
+
else
|
476
|
+
rvm --create $flags \"$identifier\"
|
477
|
+
fi
|
478
|
+
" >> .rvmrc
|
479
|
+
|
480
|
+
else
|
481
|
+
"$rvm_path/scripts/log" "error" \
|
482
|
+
".rvmrc cannot be set in your home directory.\
|
483
|
+
\nThe home .rvmrc is for global rvm settings only."
|
484
|
+
fi
|
485
|
+
}
|
486
|
+
|
487
|
+
__rvm_load_rvmrc()
|
488
|
+
{
|
489
|
+
[[ ${rvm_ignore_rvmrc:-0} -eq 1 ]] && return 0
|
490
|
+
|
491
|
+
for rvmrc in /etc/rvmrc $HOME/.rvmrc ; do
|
492
|
+
|
493
|
+
if [[ -f "$rvmrc" ]] ; then
|
494
|
+
|
495
|
+
if \grep -q '^\s*rvm .*$' $rvmrc ; then
|
496
|
+
|
497
|
+
"$rvm_path/scripts/log" "error" \
|
498
|
+
"$rvmrc is for rvm settings only.\
|
499
|
+
\nrvm CLI may NOT be called from within $rvmrc.\
|
500
|
+
\nSkipping the loading of $rvmrc"
|
501
|
+
|
502
|
+
return 1
|
503
|
+
|
504
|
+
else
|
505
|
+
|
506
|
+
source "$rvmrc"
|
507
|
+
|
508
|
+
fi
|
509
|
+
|
510
|
+
fi
|
511
|
+
|
512
|
+
done
|
513
|
+
|
514
|
+
return 0
|
515
|
+
}
|
516
|
+
|
517
|
+
# Wrap the specified ruby code file in a Benchmark.bmbm block and execute it.
|
518
|
+
__rvm_benchmark()
|
519
|
+
{
|
520
|
+
local old_rvm_ruby_string
|
521
|
+
|
522
|
+
code="require \"benchmark\" \n \
|
523
|
+
Benchmark.bmbm do |benchmark| \n \
|
524
|
+
benchmark.report(\"${rvm_ruby_file}\") do \n"
|
525
|
+
|
526
|
+
printf "\n$code" > "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
527
|
+
|
528
|
+
unset code
|
529
|
+
|
530
|
+
cat $rvm_ruby_file >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
531
|
+
|
532
|
+
printf "\n end \nend\n" >> "${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
533
|
+
|
534
|
+
rvm_ruby_args="${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb"
|
535
|
+
|
536
|
+
rvm_benchmark_flag=1
|
537
|
+
|
538
|
+
rvm_action="ruby"
|
539
|
+
|
540
|
+
if [[ ${rvm_debug_flag:0} -gt 0 ]] ; then
|
541
|
+
|
542
|
+
printf "\n${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb:\n\
|
543
|
+
$(cat ${rvm_tmp_path:-"$rvm_path/tmp"}/$$.rb)"
|
544
|
+
|
545
|
+
fi
|
546
|
+
|
547
|
+
# Override ruby string stuff, pass through.
|
548
|
+
|
549
|
+
old_rvm_ruby_string=$rvm_ruby_string
|
550
|
+
|
551
|
+
# TODO: We can likely do this in a subshell in order to
|
552
|
+
# preserve the original environment?
|
553
|
+
|
554
|
+
unset rvm_ruby_string
|
555
|
+
|
556
|
+
export rvm_ruby_strings
|
557
|
+
|
558
|
+
"$rvm_path/scripts/set" "$rvm_action" $rvm_ruby_args ; result=$?
|
559
|
+
|
560
|
+
# Restore the state pre-sets.
|
561
|
+
[[ -n "$old_rvm_ruby_string" ]] && rvm_ruby_string=$old_rvm_ruby_string
|
562
|
+
|
563
|
+
return ${result:-0}
|
564
|
+
}
|
565
|
+
|
566
|
+
# Loop over the currently installed rubies and refresh their binscripts.
|
567
|
+
__rvm_bin_scripts()
|
568
|
+
{
|
569
|
+
for rvm_ruby_binary in "$rvm_path/rubies"/*/bin/ruby ; do
|
570
|
+
|
571
|
+
if [[ -x "$rvm_ruby_binary" ]] ; then
|
572
|
+
|
573
|
+
rvm_ruby_string=$(dirname "$rvm_ruby_binary" \
|
574
|
+
| xargs dirname | xargs basename)
|
575
|
+
|
576
|
+
__rvm_select
|
577
|
+
|
578
|
+
__rvm_bin_script
|
579
|
+
|
580
|
+
fi
|
581
|
+
|
582
|
+
done
|
583
|
+
|
584
|
+
return 0
|
585
|
+
}
|
586
|
+
|
587
|
+
# Write the bin/ wrapper script for currently selected ruby.
|
588
|
+
# TODO: Adjust binscript to be able to handle all rubies,
|
589
|
+
# not just the standard interpreteres.
|
590
|
+
__rvm_bin_script()
|
591
|
+
{
|
592
|
+
"$rvm_path/scripts/wrapper" "$rvm_ruby_string"
|
593
|
+
|
594
|
+
return $?
|
595
|
+
}
|
596
|
+
|
597
|
+
# Add bin path if not present
|
598
|
+
__rvm_conditionally_add_bin_path()
|
599
|
+
{
|
600
|
+
if printf "${PATH//:/ }" | \grep -vqF "${rvm_bin_path:-"$rvm_path/bin"} " ; then
|
601
|
+
|
602
|
+
case "${rvm_ruby_string:-"system"}" in
|
603
|
+
system)
|
604
|
+
PATH="$PATH:${rvm_bin_path:-"$rvm_path/bin"}"
|
605
|
+
;;
|
606
|
+
*)
|
607
|
+
PATH="${rvm_bin_path:-"$rvm_path/bin"}:$PATH"
|
608
|
+
;;
|
609
|
+
esac
|
610
|
+
|
611
|
+
builtin hash -r
|
612
|
+
fi
|
613
|
+
|
614
|
+
return 0
|
615
|
+
}
|
616
|
+
|
617
|
+
# Reset any rvm gathered information about the system and its state.
|
618
|
+
# rvm will refresh the stored information the next time it is called after reset.
|
619
|
+
__rvm_reset()
|
620
|
+
{
|
621
|
+
local flag flags file files config configs variable
|
622
|
+
|
623
|
+
__rvm_remove_rvm_from_path ; __rvm_conditionally_add_bin_path
|
624
|
+
|
625
|
+
export PATH
|
626
|
+
|
627
|
+
builtin hash -r
|
628
|
+
|
629
|
+
flags=( default passenger editor )
|
630
|
+
|
631
|
+
for flag in "${flags[@]}"; do
|
632
|
+
|
633
|
+
\rm -f "${rvm_bin_path:-"$rvm_path/bin"}"/${flag}_*
|
634
|
+
|
635
|
+
done
|
636
|
+
|
637
|
+
for file in system default ; do
|
638
|
+
|
639
|
+
if [[ -f "$rvm_path/${file}" ]] ; then
|
640
|
+
\rm -f "$rvm_path/${file}"
|
641
|
+
fi
|
642
|
+
|
643
|
+
if [[ -f "$rvm_path/config/${file}" ]] ; then
|
644
|
+
\rm -f "$rvm_path/config/${file}"
|
645
|
+
fi
|
646
|
+
|
647
|
+
if [[ -f "$rvm_path/environments/${file}" ]] ; then
|
648
|
+
\rm -f "$rvm_path/environments/${file}"
|
649
|
+
fi
|
650
|
+
|
651
|
+
done
|
652
|
+
|
653
|
+
# Go back to a clean state.
|
654
|
+
__rvm_become "system"
|
655
|
+
|
656
|
+
__rvm_unset_ruby_variables
|
657
|
+
|
658
|
+
configs=(system_ruby system_gem_path system_user_gem_path)
|
659
|
+
|
660
|
+
for system_config in "${configs[@]}" ; do
|
661
|
+
|
662
|
+
"$rvm_path/scripts/db" "$rvm_path/config/user" "$system_config" "delete"
|
663
|
+
|
664
|
+
done
|
665
|
+
|
666
|
+
files=(ruby gem rake irb $(cd "${rvm_bin_path:-"$rvm_path/bin"}" ; \
|
667
|
+
find . -mindepth 1 -maxdepth 1 -iname 'default*' -type f \
|
668
|
+
| sed -e 's#./##g'))
|
669
|
+
|
670
|
+
for file in "${files[@]}"; do
|
671
|
+
|
672
|
+
if [[ -f "${rvm_bin_path:-"$rvm_path/bin"}/$file" ]] ; then
|
673
|
+
|
674
|
+
\rm -f "${rvm_bin_path:-"$rvm_path/bin"}/$file"
|
675
|
+
|
676
|
+
fi
|
677
|
+
|
678
|
+
done
|
679
|
+
|
680
|
+
return 0
|
681
|
+
}
|
682
|
+
|
683
|
+
# Implode removes the entire rvm installation under $rvm_path.
|
684
|
+
__rvm_implode()
|
685
|
+
{
|
686
|
+
while : ; do
|
687
|
+
|
688
|
+
"$rvm_path/scripts/log" "warn" \
|
689
|
+
"Are you SURE you wish for rvm to implode?\
|
690
|
+
\nThis will recursively remove $rvm_path ?\
|
691
|
+
\n(type 'yes' or 'no')> "
|
692
|
+
|
693
|
+
read response
|
694
|
+
|
695
|
+
if [[ "yes" = "$response" ]] ; then
|
696
|
+
|
697
|
+
if [[ "/" = "$rvm_path" ]] ; then
|
698
|
+
|
699
|
+
"$rvm_path/scripts/log" "error" \
|
700
|
+
"remove '/' ?!... Ni!"
|
701
|
+
|
702
|
+
else
|
703
|
+
|
704
|
+
if [[ -d "$rvm_path" ]] ; then
|
705
|
+
|
706
|
+
"$rvm_path/scripts/log" "info" \
|
707
|
+
"Hai! Removing $rvm_path"
|
708
|
+
|
709
|
+
\rm -rf "$rvm_path/"
|
710
|
+
|
711
|
+
echo "$rvm_path has been removed."
|
712
|
+
|
713
|
+
else
|
714
|
+
|
715
|
+
"$rvm_path/scripts/log" "info" \
|
716
|
+
"It appears that $rvm_path is already non existant."
|
717
|
+
|
718
|
+
fi
|
719
|
+
fi
|
720
|
+
break
|
721
|
+
|
722
|
+
elif [[ "no" = "$response" ]] ; then
|
723
|
+
|
724
|
+
"$rvm_path/scripts/log" "info" \
|
725
|
+
"Cancelling implosion, no harm done :)"
|
726
|
+
break
|
727
|
+
|
728
|
+
fi
|
729
|
+
done
|
730
|
+
|
731
|
+
return 0
|
732
|
+
}
|
733
|
+
|
734
|
+
# Output the current ruby's rvm source path.
|
735
|
+
__rvm_source_dir()
|
736
|
+
{
|
737
|
+
if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi
|
738
|
+
|
739
|
+
if [[ -z "$rvm_ruby_src_path" ]] ; then
|
740
|
+
|
741
|
+
"$rvm_path/scripts/log" "fail" \
|
742
|
+
"No source directory exists for the default implementation."
|
743
|
+
|
744
|
+
else
|
745
|
+
|
746
|
+
echo "$rvm_ruby_src_path"
|
747
|
+
|
748
|
+
fi
|
749
|
+
|
750
|
+
return 0
|
751
|
+
}
|
752
|
+
|
753
|
+
# Initialize rvm, ensuring that the path and directories are as expected.
|
754
|
+
__rvm_initialize()
|
755
|
+
{
|
756
|
+
rvm_ruby_load_path="."
|
757
|
+
rvm_ruby_require=""
|
758
|
+
|
759
|
+
__rvm_clean_path ; __rvm_conditionally_add_bin_path ; export PATH
|
760
|
+
|
761
|
+
if [[ ! -d "${rvm_tmp_path:-"$rvm_path/tmp"}" ]] ; then
|
762
|
+
\mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}"
|
763
|
+
fi
|
764
|
+
|
765
|
+
return 0
|
766
|
+
}
|
767
|
+
|
768
|
+
# Update rubygems or binscripts based on CLI selection.
|
769
|
+
__rvm_update()
|
770
|
+
{
|
771
|
+
(
|
772
|
+
builtin cd "$rvm_path"
|
773
|
+
|
774
|
+
if [[ ${rvm_head_flag:-0} -eq 1 || ${rvm_self_flag:-0} -eq 1 \
|
775
|
+
|| "update" = "${rvm_action:-""}" || ${rvm_update_flag:-0} -eq 1 ]] ; then
|
776
|
+
__rvm_version
|
777
|
+
__rvm_update_rvm
|
778
|
+
fi
|
779
|
+
|
780
|
+
if [[ ${rvm_bin_flag:-0} -eq 1 ]] ; then
|
781
|
+
__rvm_bin_scripts
|
782
|
+
fi
|
783
|
+
|
784
|
+
# Update to the latest rubygems.
|
785
|
+
if [[ ${rvm_rubygems_flag:-0} -eq 1 ]] ; then
|
786
|
+
"$rvm_path/scripts/rubygems" current
|
787
|
+
fi
|
788
|
+
)
|
789
|
+
unset rvm_update_flag rvm_action rvm_self_flag \
|
790
|
+
rvm_ruby_revision rvm_bin_flag rvm_rubygems_flag
|
791
|
+
|
792
|
+
return 0
|
793
|
+
}
|
794
|
+
|
795
|
+
# Update rvm using rubygems
|
796
|
+
# If --head was specified, update from git repository master branch.
|
797
|
+
__rvm_update_rvm()
|
798
|
+
{
|
799
|
+
(
|
800
|
+
if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}" ]] ; then
|
801
|
+
\mkdir -p "${rvm_src_path:-"$rvm_path/src"}"
|
802
|
+
fi
|
803
|
+
|
804
|
+
builtin cd "${rvm_src_path:-"$rvm_path/src"}"
|
805
|
+
|
806
|
+
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
|
807
|
+
|
808
|
+
if [[ -d "${rvm_src_path:-"$rvm_path/src"}/rvm/.git" ]] ; then
|
809
|
+
|
810
|
+
builtin cd "${rvm_src_path:-"$rvm_path/src"}/rvm/" && \
|
811
|
+
git pull origin master && \
|
812
|
+
./scripts/install
|
813
|
+
|
814
|
+
else
|
815
|
+
|
816
|
+
builtin cd "${rvm_src_path:-"$rvm_path/src"}" && \
|
817
|
+
( git clone http://github.com/wayneeseguin/rvm.git || \
|
818
|
+
git clone --depth 1 git://github.com/wayneeseguin/rvm.git ) && \
|
819
|
+
builtin cd rvm/ && ./scripts/install
|
820
|
+
fi
|
821
|
+
else
|
822
|
+
version_url="http://rvm.beginrescueend.com/releases/stable-version.txt"
|
823
|
+
|
824
|
+
stable_version="$(curl -s $version_url)"
|
825
|
+
|
826
|
+
__rvm_run "fetch" \
|
827
|
+
"$rvm_path/scripts/fetch \
|
828
|
+
'http://rvm.beginrescueend.com/releases/rvm-${stable_version}.tar.gz'" \
|
829
|
+
"fetching rvm-${stable_version}.tar.gz"
|
830
|
+
|
831
|
+
__rvm_run "extract" \
|
832
|
+
"gunzip < \
|
833
|
+
\"${rvm_archives_path:-"$rvm_path/archives"}/rvm-${stable_version}.tar.gz\" \
|
834
|
+
| tar xf - -C ${rvm_src_path:-"$rvm_path/src"}" \
|
835
|
+
"Extracting rvm-${stable_version}.tar.gz ..."
|
836
|
+
|
837
|
+
__rvm_run "install" \
|
838
|
+
"builtin cd ${rvm_src_path:-"$rvm_path/src"}/rvm-${stable_version}/;\
|
839
|
+
./install" \
|
840
|
+
"Installing rvm-${stable_version}..."
|
841
|
+
fi
|
842
|
+
)
|
843
|
+
|
844
|
+
rvm_hook="after_update" ; source "$rvm_path/scripts/hook"
|
845
|
+
|
846
|
+
return 0
|
847
|
+
}
|
848
|
+
|
849
|
+
__rvm_reboot()
|
850
|
+
{
|
851
|
+
"$rvm_path/scripts/log" "warn" \
|
852
|
+
"Do you wish to reboot rvm?\
|
853
|
+
\n('yes', or 'no')> "
|
854
|
+
|
855
|
+
local response="no"
|
856
|
+
|
857
|
+
read response
|
858
|
+
|
859
|
+
if [[ "yes" = "$response" ]] ; then
|
860
|
+
builtin cd $rvm_path
|
861
|
+
|
862
|
+
__rvm_reset
|
863
|
+
|
864
|
+
mv "$rvm_path/archives" "$HOME/.archives"
|
865
|
+
|
866
|
+
if [[ "/" = "$rvm_path" ]] ; then
|
867
|
+
"$rvm_path/scripts/log" "error" "remove '/' ?!... NO!"
|
868
|
+
else
|
869
|
+
if [[ -d "$rvm_path" ]] ; then \rm -rf "$rvm_path/" ; fi
|
870
|
+
fi
|
871
|
+
|
872
|
+
gem install rvm $rvm_gem_options
|
873
|
+
|
874
|
+
__rvm_update_rvm
|
875
|
+
|
876
|
+
source "$rvm_path/scripts/rvm"
|
877
|
+
else
|
878
|
+
"$rvm_path/scripts/log" "info" "Carry on then..."
|
879
|
+
fi
|
880
|
+
|
881
|
+
return 0
|
882
|
+
}
|
883
|
+
|
884
|
+
# Create the irbrc for the currently selected ruby installation.
|
885
|
+
__rvm_irbrc()
|
886
|
+
{
|
887
|
+
if [[ -d "$rvm_ruby_home" && ! -s "$rvm_ruby_irbrc" ]] ; then
|
888
|
+
\cp "$rvm_path/scripts/irbrc" "$rvm_ruby_irbrc"
|
889
|
+
fi
|
890
|
+
return $?
|
891
|
+
}
|
892
|
+
|
893
|
+
# Save or restore the rvm's state. This is a toggle action.
|
894
|
+
# Meant for use before and after an operation that might reset
|
895
|
+
# the currently selected ruby.
|
896
|
+
# TODO: Determine if we should a) yank this out or b) actually use it :)
|
897
|
+
__rvm_state()
|
898
|
+
{
|
899
|
+
if [[ -z "$rvm_state" ]] ; then
|
900
|
+
|
901
|
+
rvm_state="$(__rvm_environment_identifier)"
|
902
|
+
|
903
|
+
rvm_state="${rvm_state:-"system"}"
|
904
|
+
|
905
|
+
if [[ -n "$1" ]]; then
|
906
|
+
|
907
|
+
rvm_ruby_string="$1"
|
908
|
+
|
909
|
+
__rvm_select
|
910
|
+
|
911
|
+
__rvm_use
|
912
|
+
|
913
|
+
fi
|
914
|
+
|
915
|
+
else
|
916
|
+
|
917
|
+
rvm_ruby_string="$rvm_state"
|
918
|
+
|
919
|
+
__rvm_select
|
920
|
+
|
921
|
+
__rvm_use
|
922
|
+
|
923
|
+
unset rvm_state
|
924
|
+
|
925
|
+
fi
|
926
|
+
|
927
|
+
return 0
|
928
|
+
}
|
929
|
+
|
930
|
+
# Output an inspection of selected 'binary' scripts, based on CLI selection.
|
931
|
+
__rvm_inspect()
|
932
|
+
{
|
933
|
+
for binary in $rvm_ruby_args ; do
|
934
|
+
|
935
|
+
actual_file="$(unset -f gem ; command -v gem )"
|
936
|
+
|
937
|
+
"$rvm_path/scripts/log" "info" "$actual_file:"
|
938
|
+
|
939
|
+
if [[ ${rvm_shebang_flag:-0} -eq 1 ]] ; then
|
940
|
+
\head -n 1 < "$actual_file"
|
941
|
+
fi
|
942
|
+
|
943
|
+
if [[ ${rvm_env_flag:-0} -eq 1 ]] ; then
|
944
|
+
\awk '/ENV/' < "$actual_file"
|
945
|
+
fi
|
946
|
+
|
947
|
+
if [[ ${rvm_path_flag:-0} -eq 1 ]] ; then
|
948
|
+
\awk '/PATH/' < "$actual_file"
|
949
|
+
fi
|
950
|
+
|
951
|
+
if [[ ${rvm_head_flag:-0} -eq 1 ]] ; then
|
952
|
+
\head -n 5 < "$actual_file"
|
953
|
+
fi
|
954
|
+
|
955
|
+
if [[ ${rvm_tail_flag:-0} -eq 1 ]] ; then
|
956
|
+
\tail -n 5 < "$actual_file"
|
957
|
+
fi
|
958
|
+
|
959
|
+
if [[ ${rvm_all_flag:-0} -eq 1 ]] ; then
|
960
|
+
\cat $actual_file
|
961
|
+
fi
|
962
|
+
|
963
|
+
done
|
964
|
+
|
965
|
+
return 0
|
966
|
+
}
|
967
|
+
|
968
|
+
# Attempt to override the Darwin build settings for rubies
|
969
|
+
# This should only be used in extreme edge cases that
|
970
|
+
# will not work via the default way.
|
971
|
+
__rvm_make_flags()
|
972
|
+
{
|
973
|
+
# This is only an issue with Darwin :/
|
974
|
+
if [[ "Darwin" = "$(uname)" ]] ; then
|
975
|
+
# \ls /usr/lib/gcc/x86_64-apple-darwin10
|
976
|
+
|
977
|
+
# Set the build & host type
|
978
|
+
if [[ "Power Macintosh" = "$(sysctl -n hw.machine)" ]] ; then
|
979
|
+
|
980
|
+
: # Do nothing ?
|
981
|
+
|
982
|
+
elif [[ "$(sysctl -n hw.cpu64bit_capable)" = 1 \
|
983
|
+
|| "$(sysctl -n hw.optional.x86_64)" = 1 ]] ; then
|
984
|
+
|
985
|
+
# 64 bit capable
|
986
|
+
|
987
|
+
if [[ "-arch x86_64" = "${rvm_archflags:-""}" ]] ; then
|
988
|
+
|
989
|
+
rvm_configure_flags="${rvm_configure_flags} \
|
990
|
+
--build=x86_64-apple-darwin$(uname -r) \
|
991
|
+
--host=x86_64-apple-darwin$(uname -r)"
|
992
|
+
|
993
|
+
elif [[ "-arch i386" = "${rvm_archflags:-""}" ]] ; then
|
994
|
+
|
995
|
+
rvm_configure_flags="${rvm_configure_flags} \
|
996
|
+
--build=i386-apple-darwin$(uname -r) \
|
997
|
+
--host=i386-apple-darwin$(uname -r)"
|
998
|
+
|
999
|
+
else
|
1000
|
+
|
1001
|
+
rvm_archflags="-arch x86_64"
|
1002
|
+
|
1003
|
+
rvm_configure_flags="${rvm_configure_flags} \
|
1004
|
+
--build=x86_64-apple-darwin$(uname -r) \
|
1005
|
+
--host=x86_64-apple-darwin$(uname -r)"
|
1006
|
+
|
1007
|
+
fi
|
1008
|
+
|
1009
|
+
fi
|
1010
|
+
|
1011
|
+
if [[ -n "${rvm_archflags:-""}" ]] ; then
|
1012
|
+
|
1013
|
+
ARCHFLAGS="$rvm_archflags" ; export ARCHFLAGS
|
1014
|
+
|
1015
|
+
# Use the latest sdk available.
|
1016
|
+
if [[ -z "${rvm_sdk:-""}" ]] ; then
|
1017
|
+
|
1018
|
+
rvm_sdk="$(/usr/bin/basename -a /Developer/SDKs/* \
|
1019
|
+
| awk '/^M/' | \sort | \tail -n 1)"
|
1020
|
+
|
1021
|
+
fi
|
1022
|
+
|
1023
|
+
CFLAGS="${CFLAGS:-"-isysroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
|
1024
|
+
|
1025
|
+
export CFLAGS
|
1026
|
+
|
1027
|
+
LDFLAGS="${LDFLAGS:-"-Wl,-syslibroot /Developer/SDKs/$rvm_sdk $rvm_archflags"}"
|
1028
|
+
|
1029
|
+
export LDFLAGS
|
1030
|
+
|
1031
|
+
# CXXFLAGS="-mmacosx-version-min="$(sw_vers -productVersion \
|
1032
|
+
# | awk -F'.' '{print $1"."$2}')" -isysroot /Developer/SDKs/$rvm_sdk "
|
1033
|
+
# export CXXFLAGS
|
1034
|
+
|
1035
|
+
fi
|
1036
|
+
fi
|
1037
|
+
|
1038
|
+
return 0
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
__rvm_mono_env()
|
1042
|
+
{
|
1043
|
+
DYLD_LIBRARY_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib:$DYLD_LIBRARY_PATH"
|
1044
|
+
C_INCLUDE_PATH="${rvm_usr_path:-"$rvm_path/usr"}/include:$C_INCLUDE_PATH"
|
1045
|
+
ACLOCAL_PATH="${rvm_usr_path:-"$rvm_path/usr"}/share/aclocal"
|
1046
|
+
ACLOCAL_FLAGS="-I $ACLOCAL_PATH"
|
1047
|
+
PKG_CONFIG_PATH="${rvm_usr_path:-"$rvm_path/usr"}/lib/pkgconfig:$PKG_CONFIG_PATH"
|
1048
|
+
|
1049
|
+
export DYLD_LIBRARY_PATH C_INCLUDE_PATH ACLOCAL_PATH ACLOCAL_FLAGS PKG_CONFIG_PATH
|
1050
|
+
|
1051
|
+
PATH="${rvm_usr_path:-"$rvm_path/usr"}/bin:$PATH"
|
1052
|
+
|
1053
|
+
builtin hash -r
|
1054
|
+
|
1055
|
+
return 0
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
__rvm_become()
|
1059
|
+
{
|
1060
|
+
local string="$1"
|
1061
|
+
|
1062
|
+
[[ -n "$string" ]] && rvm_ruby_string="$string"
|
1063
|
+
|
1064
|
+
{ __rvm_ruby_string && __rvm_select && __rvm_use; } > /dev/null 2>&1
|
1065
|
+
|
1066
|
+
return 0
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
__rvm_ensure_has_environment_files()
|
1070
|
+
{
|
1071
|
+
local environment_id file_name directory identifier variable value variables
|
1072
|
+
|
1073
|
+
environment_id="$(__rvm_environment_identifier)"
|
1074
|
+
|
1075
|
+
file_name="${rvm_path}/environments/$environment_id"
|
1076
|
+
|
1077
|
+
if [[ ! -s "$file_name" ]] ; then
|
1078
|
+
|
1079
|
+
\mkdir -p "$rvm_path/environments"
|
1080
|
+
|
1081
|
+
printf "export PATH=\"${rvm_ruby_gem_home}/bin:${rvm_ruby_global_gems_path}/bin:${rvm_ruby_home}/bin:${rvm_bin_path:-"$rvm_path/bin"}:\$PATH\"\n" \
|
1082
|
+
> "$file_name"
|
1083
|
+
|
1084
|
+
for variable in rvm_path RUBY_VERSION GEM_HOME GEM_PATH BUNDLE_PATH \
|
1085
|
+
MY_RUBY_HOME IRBRC rvm_ruby_string rvm_gemset_name MAGLEV_HOME ; do
|
1086
|
+
|
1087
|
+
eval "export $variable"
|
1088
|
+
eval "value=\${${variable}:-""}"
|
1089
|
+
|
1090
|
+
if [[ -n "$value" ]] ; then
|
1091
|
+
|
1092
|
+
printf "${variable}='$value'\nexport ${variable}\n" \
|
1093
|
+
>> "$file_name"
|
1094
|
+
|
1095
|
+
else
|
1096
|
+
|
1097
|
+
printf "unset ${variable}\n" \
|
1098
|
+
>> "$file_name"
|
1099
|
+
|
1100
|
+
fi
|
1101
|
+
|
1102
|
+
done
|
1103
|
+
fi
|
1104
|
+
|
1105
|
+
# Next, ensure we have default wrapper files. Also, prevent it from recursing.
|
1106
|
+
if [[ ${rvm_create_default_wrappers:-0} -eq 1 \
|
1107
|
+
|| ! -f "$rvm_path/wrappers/$environment_id/ruby" ]] ; then
|
1108
|
+
|
1109
|
+
# We need to generate wrappers for both the default gemset and the global gemset.
|
1110
|
+
for identifier in "$environment_id" "${environment_id//@*/}@global" ; do
|
1111
|
+
|
1112
|
+
rvm_create_default_wrappers=1
|
1113
|
+
|
1114
|
+
directory="$rvm_path/wrappers/$identifier"
|
1115
|
+
|
1116
|
+
if [[ ! -L "$directory" && ! -d "$directory" ]]; then
|
1117
|
+
\mkdir -p "$directory"
|
1118
|
+
|
1119
|
+
"$rvm_path/scripts/wrapper" "$identifier" &> /dev/null
|
1120
|
+
fi
|
1121
|
+
|
1122
|
+
done
|
1123
|
+
|
1124
|
+
rvm_create_default_wrappers=0
|
1125
|
+
fi
|
1126
|
+
|
1127
|
+
return 0
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
# Strip whitespace and normalize it all.
|
1131
|
+
__rvm_strip()
|
1132
|
+
{
|
1133
|
+
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/[[:space:]]\{1,\}/ /g'
|
1134
|
+
return $?
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
__rvm_using_gemset_globalcache()
|
1138
|
+
{
|
1139
|
+
"$rvm_path/scripts/db" "$rvm_path/config/user" \
|
1140
|
+
"use_gemset_globalcache" | \grep -q '^true$'
|
1141
|
+
return $?
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
__rvm_current_gemcache_dir()
|
1145
|
+
{
|
1146
|
+
if __rvm_using_gemset_globalcache; then
|
1147
|
+
echo "$rvm_gems_cache_path"
|
1148
|
+
else
|
1149
|
+
echo "${rvm_ruby_gem_home:-"$GEM_HOME"}/cache"
|
1150
|
+
fi
|
1151
|
+
return 0
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
__rvm_Answer_to_the_Ultimate_Question_of_Life_the_Universe_and_Everything()
|
1155
|
+
{
|
1156
|
+
for index in {1..750} ; do sleep 0.25 ; echo -n '.' ; done ; printf "%d" 0x2A
|
1157
|
+
echo
|
1158
|
+
return 0
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
__rvm_ultimate_question()
|
1162
|
+
{
|
1163
|
+
printf "
|
1164
|
+
I do not know the Ultimate Question,
|
1165
|
+
however I can help you build a more
|
1166
|
+
powerful Ruby which can compute the
|
1167
|
+
Ultimate Question.
|
1168
|
+
|
1169
|
+
"
|
1170
|
+
return 0
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
__rvm_load_env_file()
|
1174
|
+
{
|
1175
|
+
local string="$1"
|
1176
|
+
if [[ -f "$rvm_path/environments/$string" ]]; then
|
1177
|
+
# Restore the path to it's state minus rvm
|
1178
|
+
__rvm_remove_rvm_from_path
|
1179
|
+
|
1180
|
+
# source the environment file
|
1181
|
+
\. "$rvm_path/environments/$string"
|
1182
|
+
|
1183
|
+
# clear the PATH cache
|
1184
|
+
builtin hash -r
|
1185
|
+
elif [[ -n "$string" ]] ; then
|
1186
|
+
rvm "$string"
|
1187
|
+
else
|
1188
|
+
: # TODO: This should have some error handling in the context.
|
1189
|
+
fi
|
1190
|
+
return 0
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
__rvm_md5_for()
|
1194
|
+
{
|
1195
|
+
if command -v md5 > /dev/null; then
|
1196
|
+
echo "$1" | md5
|
1197
|
+
elif command -v md5sum > /dev/null ; then
|
1198
|
+
echo "$1" | md5sum | awk '{print $1}'
|
1199
|
+
else
|
1200
|
+
"$rvm_path/scripts/log" "error" \
|
1201
|
+
"Neither md5 nor md5sum were found in the PATH"
|
1202
|
+
return 1
|
1203
|
+
fi
|
1204
|
+
|
1205
|
+
return 0
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
__rvm_rvmrc_key()
|
1209
|
+
{
|
1210
|
+
__rvm_md5_for "$1"
|
1211
|
+
return $?
|
1212
|
+
}
|
1213
|
+
|
1214
|
+
__rvm_reset_rvmrc_trust()
|
1215
|
+
{
|
1216
|
+
touch "$rvm_path/config/rvmrcs"
|
1217
|
+
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1218
|
+
"$(__rvm_rvmrc_key "$1")" "delete" >/dev/null 2>&1
|
1219
|
+
return $?
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
__rvm_trust_rvmrc()
|
1223
|
+
{
|
1224
|
+
touch "$rvm_path/config/rvmrcs"
|
1225
|
+
__rvm_reset_rvmrc_trust "$1"
|
1226
|
+
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1227
|
+
"$(__rvm_rvmrc_key "$1")" "1" >/dev/null 2>&1
|
1228
|
+
return $?
|
1229
|
+
}
|
1230
|
+
|
1231
|
+
__rvm_untrust_rvmrc()
|
1232
|
+
{
|
1233
|
+
touch "$rvm_path/config/rvmrcs"
|
1234
|
+
__rvm_reset_rvmrc_trust "$1"
|
1235
|
+
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1236
|
+
"$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
|
1237
|
+
return $?
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
__rvm_rvmrc_stored_trust()
|
1241
|
+
{
|
1242
|
+
touch "$rvm_path/config/rvmrcs"
|
1243
|
+
"$rvm_path/scripts/db" "$rvm_path/config/rvmrcs" \
|
1244
|
+
"$(__rvm_rvmrc_key "$1")"
|
1245
|
+
return $?
|
1246
|
+
}
|
1247
|
+
|
1248
|
+
__rvm_rvmrc_tools()
|
1249
|
+
{
|
1250
|
+
local rvmrc_action="$1"
|
1251
|
+
[[ $# -gt 0 ]] && shift
|
1252
|
+
local rvmrc_path="$(builtin cd "${1:-$PWD}" >/dev/null 2>&1; pwd)/.rvmrc"
|
1253
|
+
case "$rvmrc_action" in
|
1254
|
+
reset)
|
1255
|
+
__rvm_reset_rvmrc_trust "$rvmrc_path"
|
1256
|
+
echo "Reset trust for $rvmrc_path"
|
1257
|
+
;;
|
1258
|
+
trust)
|
1259
|
+
__rvm_trust_rvmrc "$rvmrc_path"
|
1260
|
+
echo "Marked $rvmrc_path as trusted"
|
1261
|
+
;;
|
1262
|
+
untrust)
|
1263
|
+
__rvm_untrust_rvmrc "$rvmrc_path"
|
1264
|
+
echo "Marked $rvmrc_path as untrusted"
|
1265
|
+
;;
|
1266
|
+
trusted)
|
1267
|
+
local trusted_value="$(__rvm_rvmrc_stored_trust "$rvmrc_path")"
|
1268
|
+
if [[ "$trusted_value" = "1" ]]; then
|
1269
|
+
echo "The rvmrc at '$rvmrc_path' is currently trusted."
|
1270
|
+
elif [[ "$trusted_value" = "0" ]]; then
|
1271
|
+
echo "The rvmrc at '$rvmrc_path' is currently untrusted."
|
1272
|
+
else
|
1273
|
+
echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
|
1274
|
+
fi
|
1275
|
+
;;
|
1276
|
+
load)
|
1277
|
+
rvm_rvmrc_cwd="" rvm_trust_rvmrcs=1 \
|
1278
|
+
__rvm_project_rvmrc "$(dirname "$rvmrc_path")"
|
1279
|
+
;;
|
1280
|
+
*)
|
1281
|
+
echo "Usage: rvm rvmrc {trust,untrust,trusted,load,reset}"
|
1282
|
+
return 1
|
1283
|
+
;;
|
1284
|
+
esac
|
1285
|
+
return $?
|
1286
|
+
}
|
1287
|
+
|
1288
|
+
__rvm_check_rvmrc_trustworthiness()
|
1289
|
+
{
|
1290
|
+
# Trust when they have the flag... of doom!
|
1291
|
+
[[ -z "$1" || "$rvm_trust_rvmrcs" = "1" ]] && return 0
|
1292
|
+
value="$(__rvm_rvmrc_stored_trust "$1")"
|
1293
|
+
if [[ -z "$value" ]] ; then
|
1294
|
+
__rvm_ask_to_trust "$1"
|
1295
|
+
else
|
1296
|
+
[[ "$value" = "1" ]]
|
1297
|
+
fi
|
1298
|
+
return $?
|
1299
|
+
}
|
1300
|
+
|
1301
|
+
__rvm_ask_to_trust()
|
1302
|
+
{
|
1303
|
+
|
1304
|
+
local trusted value
|
1305
|
+
|
1306
|
+
[[ -n "$rvm_promptless" ]] && return 2
|
1307
|
+
|
1308
|
+
printf "
|
1309
|
+
============================================================
|
1310
|
+
RVM has encountered a not yet trusted .rvmrc file in the
|
1311
|
+
current working directory which contains the following code:
|
1312
|
+
============================================================
|
1313
|
+
|
1314
|
+
$(cat $1)
|
1315
|
+
|
1316
|
+
============================================================
|
1317
|
+
Trusting an .rvmrc file means that whenever you cd into the
|
1318
|
+
directory RVM will excecute this .rvmrc script in your shell
|
1319
|
+
|
1320
|
+
Do you wish to trust this .rvmrc from now on?
|
1321
|
+
============================================================
|
1322
|
+
(y for yes, n for no)"
|
1323
|
+
|
1324
|
+
# TODO: Eliminate infinite loop possibility.
|
1325
|
+
while [[ -z "$trusted" ]] ; do
|
1326
|
+
|
1327
|
+
printf " > "
|
1328
|
+
|
1329
|
+
read -r response
|
1330
|
+
|
1331
|
+
value="$(echo "$response" | tr '[[:upper:]]' '[[:lower:]]' | __rvm_strip)"
|
1332
|
+
|
1333
|
+
if [[ "$response" = "y"* ]]; then
|
1334
|
+
trusted=1
|
1335
|
+
|
1336
|
+
elif [[ "$response" = "n"* ]]; then
|
1337
|
+
trusted=0
|
1338
|
+
fi
|
1339
|
+
done
|
1340
|
+
|
1341
|
+
if [[ ${trusted:-0} -gt 0 ]] ; then
|
1342
|
+
|
1343
|
+
__rvm_trust_rvmrc "$1"
|
1344
|
+
|
1345
|
+
return 0
|
1346
|
+
|
1347
|
+
else
|
1348
|
+
__rvm_untrust_rvmrc "$1"
|
1349
|
+
return 1
|
1350
|
+
fi
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
# Checks the rvmrc for the given directory. Note that if
|
1354
|
+
# argument is passed, it will be used instead of pwd.
|
1355
|
+
__rvm_project_rvmrc()
|
1356
|
+
{
|
1357
|
+
local cwd
|
1358
|
+
|
1359
|
+
# Get the first argument or the pwd.
|
1360
|
+
cwd="${1:-"$PWD"}"
|
1361
|
+
|
1362
|
+
while : ; do
|
1363
|
+
|
1364
|
+
if [[ -z "$cwd" || "$HOME" = "$cwd" || "/" = "$cwd" ]] ; then
|
1365
|
+
|
1366
|
+
if [[ -n "${rvm_rvmrc_cwd:-""}" ]] ; then
|
1367
|
+
|
1368
|
+
if [[ ${rvm_project_rvmrc_default:-0} -eq 1 ]]; then
|
1369
|
+
|
1370
|
+
__rvm_load_env_file "default"
|
1371
|
+
|
1372
|
+
elif [[ -n "${rvm_previous_environment:-""}" ]] ; then
|
1373
|
+
|
1374
|
+
__rvm_load_env_file "$rvm_previous_environment"
|
1375
|
+
|
1376
|
+
fi
|
1377
|
+
|
1378
|
+
unset rvm_rvmrc_cwd rvm_previous_environment
|
1379
|
+
|
1380
|
+
fi
|
1381
|
+
break
|
1382
|
+
else
|
1383
|
+
|
1384
|
+
if [[ -f "$cwd/.rvmrc" ]] ; then
|
1385
|
+
|
1386
|
+
if [[ "${rvm_rvmrc_cwd:-""}" != "$cwd" ]] ; then
|
1387
|
+
|
1388
|
+
__rvm_check_rvmrc_trustworthiness "$cwd/.rvmrc"
|
1389
|
+
|
1390
|
+
local rvm_trustworthiness_result="$?"
|
1391
|
+
|
1392
|
+
if [[ "$rvm_trustworthiness_result" = 0 ]]; then
|
1393
|
+
|
1394
|
+
rvm_previous_environment="$(__rvm_environment_identifier)"
|
1395
|
+
|
1396
|
+
rvm_rvmrc_cwd="$cwd"
|
1397
|
+
|
1398
|
+
source "$cwd/.rvmrc"
|
1399
|
+
|
1400
|
+
return 0
|
1401
|
+
else
|
1402
|
+
return "$rvm_trustworthiness_result"
|
1403
|
+
fi
|
1404
|
+
fi
|
1405
|
+
break
|
1406
|
+
|
1407
|
+
else
|
1408
|
+
cwd="$(dirname "$cwd")"
|
1409
|
+
fi
|
1410
|
+
fi
|
1411
|
+
done
|
1412
|
+
|
1413
|
+
return $?
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
__rvm_record_install()
|
1417
|
+
{
|
1418
|
+
|
1419
|
+
local recorded_ruby_name rvm_install_record_file rvm_install_command
|
1420
|
+
|
1421
|
+
[[ -z "$1" ]] && return
|
1422
|
+
|
1423
|
+
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1")"
|
1424
|
+
|
1425
|
+
rvm_install_record_file="$rvm_path/config/installs"
|
1426
|
+
|
1427
|
+
rvm_install_command=$(printf "$recorded_ruby_name $rvm_install_arguments\n")
|
1428
|
+
|
1429
|
+
\touch "$rvm_install_record_file"
|
1430
|
+
|
1431
|
+
\rm -f "$rvm_install_record_file.tmp"
|
1432
|
+
|
1433
|
+
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file" \
|
1434
|
+
> "$rvm_install_record_file.tmp"
|
1435
|
+
|
1436
|
+
echo "$rvm_install_command" >> "$rvm_install_record_file.tmp"
|
1437
|
+
|
1438
|
+
\rm -f "$rvm_install_record_file"
|
1439
|
+
|
1440
|
+
\mv "$rvm_install_record_file.tmp" "$rvm_install_record_file"
|
1441
|
+
|
1442
|
+
return 0
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
__rvm_remove_install_record()
|
1446
|
+
{
|
1447
|
+
local recorded_ruby_name rvm_install_record_file
|
1448
|
+
|
1449
|
+
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1")"
|
1450
|
+
|
1451
|
+
rvm_install_record_file="$rvm_path/config/installs"
|
1452
|
+
|
1453
|
+
if [[ -s "$rvm_install_record_file" ]]; then
|
1454
|
+
|
1455
|
+
\mv "$rvm_install_record_file" "$rvm_install_record_file.tmp"
|
1456
|
+
|
1457
|
+
\grep -v "^$recorded_ruby_name " < "$rvm_install_record_file.tmp" \
|
1458
|
+
> "$rvm_install_record_file"
|
1459
|
+
|
1460
|
+
\rm -f "$rvm_install_record_file.tmp"
|
1461
|
+
fi
|
1462
|
+
|
1463
|
+
return 0
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
__rvm_recorded_install_command()
|
1467
|
+
{
|
1468
|
+
local recorded_ruby_name recorded_ruby_match
|
1469
|
+
|
1470
|
+
recorded_ruby_name="$("$rvm_path/scripts/tools" strings "$1" \
|
1471
|
+
| awk -F"${rvm_gemset_separator:-"@"}" '{print $1}')"
|
1472
|
+
|
1473
|
+
[[ -z "$recorded_ruby_name" ]] && return 1
|
1474
|
+
|
1475
|
+
recorded_ruby_match="^$recorded_ruby_name "
|
1476
|
+
|
1477
|
+
if [[ -s "$rvm_path/config/installs" ]] \
|
1478
|
+
&& \grep -q "$recorded_ruby_match" "$rvm_path/config/installs" ; then
|
1479
|
+
|
1480
|
+
\grep "$recorded_ruby_match" < "$rvm_path/config/installs" | head -n1
|
1481
|
+
|
1482
|
+
else
|
1483
|
+
return 1
|
1484
|
+
fi
|
1485
|
+
return $?
|
1486
|
+
}
|
1487
|
+
|
1488
|
+
__rvm_environment_identifier()
|
1489
|
+
{
|
1490
|
+
local path string
|
1491
|
+
|
1492
|
+
path="${GEM_HOME:-""}"
|
1493
|
+
|
1494
|
+
string="${path//*gems\//}"
|
1495
|
+
string="${string//\/*/}"
|
1496
|
+
|
1497
|
+
printf "${string:-system}"
|
1498
|
+
|
1499
|
+
return $?
|
1500
|
+
}
|
1501
|
+
|
1502
|
+
__rvm_expand_ruby_string()
|
1503
|
+
{
|
1504
|
+
local string current_ruby
|
1505
|
+
|
1506
|
+
string="$1"
|
1507
|
+
|
1508
|
+
if [[ -z "$string" ]] ; then
|
1509
|
+
|
1510
|
+
"$rvm_path/scripts/list" strings | tr ' ' "\n"
|
1511
|
+
|
1512
|
+
return $?
|
1513
|
+
|
1514
|
+
fi
|
1515
|
+
|
1516
|
+
case "$string" in
|
1517
|
+
|
1518
|
+
all)
|
1519
|
+
"$rvm_path/scripts/list" strings | tr ' ' "\n"
|
1520
|
+
;;
|
1521
|
+
|
1522
|
+
all-gemsets)
|
1523
|
+
"$rvm_path/scripts/list" gemsets strings
|
1524
|
+
;;
|
1525
|
+
|
1526
|
+
default-with-rvmrc|rvmrc)
|
1527
|
+
"$rvm_path/scripts/tools" path-identifier "$PWD"
|
1528
|
+
;;
|
1529
|
+
|
1530
|
+
all-rubies|rubies)
|
1531
|
+
"$rvm_path/scripts/list" rubies strings
|
1532
|
+
;;
|
1533
|
+
|
1534
|
+
current-ruby|gemsets)
|
1535
|
+
current_ruby="$(__rvm_environment_identifier \
|
1536
|
+
| awk -F"${rvm_gemset_separator:-"@"}" '{print $string}')"
|
1537
|
+
|
1538
|
+
rvm_silence_logging=1 "$rvm_path/scripts/gemsets" list \
|
1539
|
+
| sed "s/^/$current_ruby${rvm_gemset_separator:-"@"}/"
|
1540
|
+
;;
|
1541
|
+
|
1542
|
+
current)
|
1543
|
+
__rvm_environment_identifier
|
1544
|
+
;;
|
1545
|
+
|
1546
|
+
aliases)
|
1547
|
+
awk -F= '{print $string}' < "$rvm_path/config/alias"
|
1548
|
+
;;
|
1549
|
+
|
1550
|
+
*)
|
1551
|
+
echo "$string" | tr "," "\n" | __rvm_strip
|
1552
|
+
;;
|
1553
|
+
|
1554
|
+
esac
|
1555
|
+
|
1556
|
+
return $?
|
1557
|
+
}
|