rvm 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -194,9 +194,6 @@ question="\n<?>"
194
194
  cwd="$PWD"
195
195
 
196
196
  source_path="${source_path:-$cwd}"
197
- rvm_archives_path="${rvm_archives_path:-"$rvm_path/archives"}"
198
- rvm_src_path="${rvm_src_path:-"$rvm_path/src"}"
199
- rvm_log_path="${rvm_log_path:-"$rvm_path/log"}"
200
197
 
201
198
  if [[ "$rvm_selfcontained" = "0" ]] ; then
202
199
  rvm_bin_path="${rvm_bin_path:-"${rvm_prefix}bin"}"
@@ -209,9 +206,6 @@ else
209
206
  fi
210
207
 
211
208
  rvm_gems_path="${rvm_gems_path:-"$rvm_path/gems"}"
212
- rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}"
213
- rvm_config_path="${rvm_config_path:-"$rvm_path/config"}"
214
- rvm_hooks_path="${rvm_hooks_path:-"$rvm_path/hooks"}"
215
209
  rvm_tmp_path="${rvm_tmp_path:-"$rvm_path/tmp"}"
216
210
 
217
211
  printf "
@@ -230,7 +224,9 @@ else
230
224
 
231
225
  fi
232
226
 
233
- for directory in "$rvm_archives_path" "$rvm_src_path" "$rvm_log_path" "$rvm_bin_path" "$rvm_gems_path" "$rvm_rubies_path" "$rvm_config_path" "$rvm_hooks_path" "$rvm_tmp_path" ; do
227
+ directories=( "${rvm_archives_path:-"$rvm_path/archives"}" "${rvm_src_path:-"$rvm_path/src"}" "${rvm_log_path:-"$rvm_path/log"}" "$rvm_bin_path" "${rvm_gems_path:-"$rvm_path/gems"}" "${rvm_rubies_path:-"$rvm_path/rubies"}" "$rvm_path/config" "${rvm_tmp_path:-"$rvm_path/tmp"}" )
228
+
229
+ for directory in "${directories[@]}" ; do
234
230
 
235
231
  if [[ ! -d "$directory" ]] ; then
236
232
 
@@ -240,7 +236,9 @@ for directory in "$rvm_archives_path" "$rvm_src_path" "$rvm_log_path" "$rvm_bin_
240
236
 
241
237
  done
242
238
 
243
- for file in README LICENCE ; do
239
+ files=(README LICENCE)
240
+
241
+ for file in "${files[@]}"; do
244
242
 
245
243
  cp -f "$source_path/$file" "$rvm_path/"
246
244
 
@@ -265,8 +263,8 @@ for dir_name in config scripts examples lib hooks help patches; do
265
263
 
266
264
  done
267
265
 
268
- if [[ ! -s "$rvm_config_path/user" ]] ; then
269
- echo '# Users settings file, overrides db file settings and persists across installs.' >> "$rvm_config_path/user"
266
+ if [[ ! -s "$rvm_path/config/user" ]] ; then
267
+ echo '# Users settings file, overrides db file settings and persists across installs.' >> "$rvm_path/config/user"
270
268
  fi
271
269
 
272
270
  scripts=(monitor match log install color db fetch log set package)
@@ -281,15 +279,17 @@ done
281
279
  # Bin Scripts
282
280
  #
283
281
  # Cleanse and purge...
284
- for file in rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby ; do
282
+ files=(rvm-prompt rvm rvmsudo rvm-shell rvm-auto-ruby)
283
+
284
+ for file in "${files[@]}" ; do
285
285
 
286
286
  rm -f "$rvm_bin_path/$file"
287
287
 
288
- cp -f "$source_path/binscripts/$file" $rvm_bin_path/
288
+ cp -f "$source_path/binscripts/$file" "${rvm_bin_path:-"$rvm_path/bin"}/"
289
289
 
290
290
  done
291
291
 
292
- chmod +x "$rvm_bin_path"/* # TODO: this is quite suboptimal.
292
+ chmod +x "${rvm_bin_path:-"$rvm_path/bin"}"/* # TODO: this is quite suboptimal.
293
293
 
294
294
  #
295
295
  # RC Files
@@ -389,17 +389,15 @@ fi
389
389
  #
390
390
  # Migrate ~/.rvm/ruby-X,jruby-X,... to ~/.rvm/rubies/ for 0.1.0.
391
391
  #
392
- rvm_rubies_path="${rvm_rubies_path:-"$rvm_path/rubies"}"
393
-
394
- mkdir -p "$rvm_rubies_path/"
392
+ mkdir -p "${rvm_rubies_path:-"$rvm_path/rubies"}/"
395
393
 
396
394
  for ruby in $rvm_path/ruby-* $rvm_path/jruby-* $rvm_path/mput-* $rvm_path/rbx-* $rvm_path/maglev-* $rvm_path/ree-* ; do
397
395
 
398
396
  if [[ -d "$ruby" ]] ; then
399
397
 
400
- mv "$ruby" "$rvm_rubies_path/"
398
+ mv "$ruby" "${rvm_rubies_path:-"$rvm_path/rubies"}/"
401
399
 
402
- new_path="$rvm_rubies_path/$(basename $ruby)"
400
+ new_path="${rvm_rubies_path:-"$rvm_path/rubies"}/$(basename $ruby)"
403
401
 
404
402
  for file in gem rake ; do
405
403
 
@@ -468,9 +466,9 @@ for gemset in "$rvm_path"/gems/*\@ ; do
468
466
  done
469
467
 
470
468
  # Move from legacy defaults to the new, alias based system.
471
- if [[ -s "$rvm_config_path/default" ]]; then
469
+ if [[ -s "$rvm_path/config/default" ]]; then
472
470
 
473
- original_version="$(basename "$(grep GEM_HOME "$rvm_config_path/default" | awk -F"'" '{print $2}' | sed "s#\%#${rvm_gemset_separator:-"@"}#")")"
471
+ original_version="$(basename "$(grep GEM_HOME "$rvm_path/config/default" | awk -F"'" '{print $2}' | sed "s#\%#${rvm_gemset_separator:-"@"}#")")"
474
472
 
475
473
  if [[ -n "$original_version" ]]; then
476
474
 
@@ -478,7 +476,7 @@ if [[ -s "$rvm_config_path/default" ]]; then
478
476
 
479
477
  fi ; unset original_version
480
478
 
481
- rm -rf "$rvm_config_path/default"
479
+ rm -rf "$rvm_path/config/default"
482
480
 
483
481
  fi
484
482
 
@@ -487,11 +485,11 @@ fi
487
485
  #
488
486
  printf "\n Correct permissions for base binaries in $rvm_bin_path..."
489
487
 
490
- mkdir -p "$rvm_bin_path"
488
+ mkdir -p "${rvm_bin_path:-"$rvm_path/bin"}"
491
489
 
492
490
  for file in rvm rvmsudo rvm-shell rvm-auto-ruby ; do
493
491
 
494
- [[ -s "$rvm_bin_path/$file" ]] && chmod +x "$rvm_bin_path/$file"
492
+ [[ -s "${rvm_bin_path:-"$rvm_path/bin"}/$file" ]] && chmod +x "${rvm_bin_path:-"$rvm_path/bin"}/$file"
495
493
 
496
494
  done
497
495
 
@@ -107,7 +107,7 @@ __rvm_select() {
107
107
  rvm_ruby_package_name="${rvm_ruby_interpreter}-${rvm_ruby_version}"
108
108
  rvm_ruby_url="${rvm_ruby_url:-"$maglev_url/${rvm_ruby_package_file}.${rvm_archive_extension}"}"
109
109
  rvm_gemstone_url="${rvm_gemstone_url:-"$maglev_url/${rvm_gemstone_package_file}.${rvm_archive_extension}"}"
110
- export MAGLEV_HOME="$rvm_rubies_path/$rvm_ruby_string"
110
+ export MAGLEV_HOME="$rvm_path/rubies/$rvm_ruby_string"
111
111
  fi
112
112
  ;;
113
113
 
@@ -218,42 +218,40 @@ __rvm_select() {
218
218
  fi
219
219
 
220
220
  rvm_ruby_package_name="${rvm_ruby_package_name:-${rvm_ruby_string//-n*}}"
221
- rvm_ruby_home="$rvm_rubies_path/$rvm_ruby_string"
222
- rvm_ruby_log_path="$rvm_log_path/$rvm_ruby_string"
223
- rvm_ruby_repo_path="$rvm_repo_path/$rvm_ruby_string"
224
- rvm_ruby_src_path="$rvm_src_path/$rvm_ruby_string"
221
+ rvm_ruby_home="$rvm_path/rubies/$rvm_ruby_string"
225
222
  rvm_ruby_binary="$rvm_ruby_home/bin/ruby"
226
223
  rvm_ruby_irbrc="$rvm_ruby_home/.irbrc"
227
- rvm_ruby_gem_home="${rvm_gems_path}/${rvm_ruby_string}"
228
- rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_ruby_gem_home}@global"
229
224
 
230
225
  if [[ "maglev" = "$rvm_ruby_interpreter" ]] ; then
231
226
  export MAGLEV_HOME="$rvm_ruby_home"
232
227
  export GEMSTONE_GLOBAL_DIR=$MAGLEV_HOME
233
228
  fi
234
229
 
230
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}"
231
+
235
232
  if [[ ! -z "$rvm_gemset_name" ]] ; then
236
233
  rvm_ruby_gem_home="${rvm_ruby_gem_home}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
237
- rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_gems_path}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}global"
234
+ rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}global"
238
235
  fi
239
236
 
237
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
238
+ rvm_ruby_gem_path="${rvm_ruby_gem_home}:${rvm_ruby_global_gems_path}"
239
+
240
240
  rvm_ruby_selected_flag=1
241
241
 
242
- \mkdir -p "$rvm_ruby_log_path"
242
+ if [[ ! -d "{rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string" ]] ; then
243
+ \mkdir -p "${rvm_log_path:-"$rvm_path/log"}/$rvm_ruby_string"
244
+ fi
245
+
246
+ export rvm_head_flag $(env | awk -F= -v ORS=' ' '/^rvm_/{print $1}')
243
247
 
244
- export rvm_ruby_interpreter rvm_ruby_version rvm_ruby_repo_url rvm_ruby_package_name rvm_ruby_url rvm_ruby_patch_level rvm_ruby_configure rvm_configure_flags rvm_ruby_make rvm_ruby_make_install rvm_ruby_revision rvm_ruby_tag rvm_ruby_release_version rvm_ruby_major_version rvm_ruby_minor_version rvm_gemset_name rvm_gems_path rvm_ruby_gem_home rvm_path rvm_src_path rvm_bin_path rvm_ruby_binary rvm_ruby_home rvm_log_path rvm_ruby_log_path rvm_src_path rvm_ruby_src_path rvm_ruby_irbrc rvm_ruby_selected_flag rvm_ruby_string
245
248
  else
246
249
  rvm_ruby_interpreter="${rvm_ruby_interpreter:-system}"
247
250
  fi
248
251
  }
249
252
 
250
253
  __rvm_use() {
251
- rvm_gemset_name="${rvm_gemset_name:-""}"
252
- rvm_ruby_gem_home="${rvm_ruby_gem_home:-""}"
253
- rvm_wrapper_name="${rvm_wrapper_name:-""}"
254
- rvm_ruby_alias="${rvm_ruby_alias:-""}"
255
-
256
- local new_path binary full_binary_path
254
+ local new_path binary full_binary_path rvm_ruby_gem_home
257
255
 
258
256
  if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select "$@" ; fi
259
257
 
@@ -263,16 +261,16 @@ __rvm_use() {
263
261
 
264
262
  unset GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION IRBRC
265
263
 
266
- new_path="$rvm_bin_path:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
264
+ new_path="${rvm_bin_path:-"$rvm_path/bin"}:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
267
265
 
268
- if [[ -s $rvm_config_path/system ]] ; then
266
+ if [[ -s $rvm_path/config/system ]] ; then
269
267
 
270
- \grep "MY_RUBY_HOME='$rvm_rubies_path" "$rvm_config_path/system" > /dev/null
268
+ \grep "MY_RUBY_HOME='$rvm_path/rubies" "$rvm_path/config/system" > /dev/null
271
269
 
272
270
  if [[ $? -eq 0 ]] ; then
273
- [[ -f "$rvm_config_path/system" ]] && \rm -f $rvm_config_path/system # 'system' should *not* point to an rvm ruby.
271
+ [[ -f "$rvm_path/config/system" ]] && \rm -f $rvm_path/config/system # 'system' should *not* point to an rvm ruby.
274
272
  else
275
- source "$rvm_config_path/system"
273
+ source "$rvm_path/config/system"
276
274
  fi
277
275
  fi
278
276
 
@@ -281,7 +279,7 @@ __rvm_use() {
281
279
 
282
280
  for binary in ruby gem irb ri rdoc rake erb testrb ; do
283
281
 
284
- full_binary_path="$rvm_bin_path/$binary"
282
+ full_binary_path="${rvm_bin_path:-"$rvm_path/bin"}/$binary"
285
283
 
286
284
  [[ -L "$full_binary_path" ]] && \rm -f "$full_binary_path"
287
285
  done
@@ -295,7 +293,7 @@ __rvm_use() {
295
293
 
296
294
  else
297
295
  GEM_HOME="$rvm_ruby_gem_home"
298
- GEM_PATH="$rvm_ruby_gem_path"
296
+ GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
299
297
  BUNDLE_PATH="$rvm_ruby_gem_home"
300
298
  MY_RUBY_HOME="$rvm_ruby_home"
301
299
  RUBY_VERSION="$rvm_ruby_string"
@@ -325,7 +323,7 @@ __rvm_use() {
325
323
  "$rvm_path/scripts/log" "info" \
326
324
  "Using ${GEM_HOME/${rvm_gemset_separator:-'@'}/ with gemset }"
327
325
 
328
- new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:$rvm_bin_path:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
326
+ new_path="$GEM_HOME/bin:$rvm_ruby_global_gems_path/bin:$MY_RUBY_HOME/bin:${rvm_bin_path:-"$rvm_path/bin"}:$(__rvm_remove_rvm_from_path ; printf "$PATH")"
329
327
  fi
330
328
 
331
329
  # Export ruby string and gem set me for extrenal scripts to take advantage of them.
@@ -345,27 +343,27 @@ __rvm_use() {
345
343
 
346
344
  if [[ ${rvm_default_flag:-0} -eq 1 && "default" != "${rvm_ruby_interpreter:-""}" ]] ; then
347
345
 
348
- if [[ "${rvm_selfcontained:-""}" = "0" ]] ; then
346
+ if [[ ${rvm_selfcontained:-""} -eq 0 ]] ; then
349
347
  # Sets up the default wrappers.
350
348
  "$rvm_path/scripts/wrapper" "$rvm_ruby_string" --no-prefix
351
349
  else
352
- "$rvm_path/scripts/wrapper" "$rvm_path/scripts" "default"
350
+ "$rvm_path/scripts/wrapper" "$rvm_ruby_string" "default"
353
351
  fi
354
352
 
355
353
  if [[ "system" = "$rvm_ruby_interpreter" ]] ; then
356
354
  "$rvm_path/scripts/alias" delete default &> /dev/null
357
- \find "$rvm_bin_path" -name 'default_*' -maxdepth 0 -delete
358
- \rm -f "$rvm_config_path/default"
359
- \rm -f "$rvm_environments_path/default"
360
- \rm -rf "$rvm_wrappers_path/default"
355
+ \find "${rvm_bin_path:-"$rvm_path/bin"}" -name 'default_*' -maxdepth 0 -delete
356
+ \rm -f "$rvm_path/config/default"
357
+ \rm -f "$rvm_path/environments/default"
358
+ \rm -rf "$rvm_path/wrappers/default"
361
359
 
362
360
  else
363
361
  RUBY_VERSION="$("$rvm_ruby_home/bin/ruby" -v | sed 's#^\(.*\) (.*$#\1#')"
364
362
  export GEM_HOME GEM_PATH BUNDLE_PATH MY_RUBY_HOME RUBY_VERSION
365
363
  "$rvm_path/scripts/alias" delete default &> /dev/null
366
364
  "$rvm_path/scripts/alias" create default "$environment_id" >& /dev/null
367
- \ln -nfs "$rvm_environments_path/$environment_id" "$rvm_environments_path/default"
368
- \ln -nfs "$rvm_wrappers_path/$environment_id" "$rvm_wrappers_path/default"
365
+ \ln -nfs "$rvm_path/environments/$environment_id" "$rvm_path/environments/default"
366
+ \ln -nfs "$rvm_path/wrappers/$environment_id" "$rvm_path/wrappers/default"
369
367
  fi
370
368
  fi
371
369
 
@@ -444,8 +442,9 @@ __rvm_ruby_string() {
444
442
  if echo "${GEM_HOME:-""}" | grep -q "rvm" ; then
445
443
  # Current Ruby
446
444
  strings="${GEM_HOME##*\/}"
447
- strings=("${strings/%${rvm_gemset_separator:-"@"}*}")
448
- rvm_ruby_string=${strings[@]:(1)}
445
+ strings="${strings/%${rvm_gemset_separator:-"@"}*}"
446
+ rvm_ruby_string="$strings"
447
+ strings=(${strings//-/ })
449
448
  else
450
449
  strings=(system)
451
450
  rvm_ruby_string="system"
@@ -641,7 +640,7 @@ __rvm_gemset_select() {
641
640
 
642
641
  rvm_ruby_gem_home=${rvm_ruby_gem_home:-""}
643
642
  rvm_gemset_name=${rvm_gemset_name:-""}
644
- rvm_ruby_global_gems_path="$rvm_path/gems/${rvm_ruby_string:-""}${rvm_gemset_separator:-"@"}global"
643
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
645
644
 
646
645
  if [[ -z "${rvm_gemset_name:-""}" ]] ; then
647
646
 
@@ -660,11 +659,11 @@ __rvm_gemset_select() {
660
659
 
661
660
  if ! echo "${rvm_gemset_name:-""}" | grep -q "^[[:digit:]]\.[[:digit:]]" ; then
662
661
 
663
- rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
662
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
664
663
 
665
664
  else
666
665
  if [[ -n "${rvm_ruby_string:-""}" && "${rvm_ruby_interpreter:-""}" != "system" ]] ; then
667
- rvm_ruby_gem_home="$rvm_gems_path/$rvm_ruby_string"
666
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string"
668
667
 
669
668
  elif [[ -z "${GEM_HOME:-""}" && -n "$(command -v gem)" ]] ; then
670
669
  rvm_ruby_gem_home=$(gem env gemdir)
@@ -686,10 +685,10 @@ __rvm_gemset_select() {
686
685
  if [[ -n "${rvm_ruby_string:-""}" ]] ; then
687
686
 
688
687
  if [[ -z "${rvm_ruby_gem_home:-""}" || -n "${gemset:-""}" ]] ; then
689
- rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
688
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
690
689
 
691
690
  elif [[ -n "${gemset:-""}" && "${rvm_gemset_name:-""}" != "${gemset:-""}" ]] ; then
692
- rvm_ruby_gem_home="$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
691
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/${rvm_ruby_string}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
693
692
  fi
694
693
  else
695
694
  "$rvm_path/scripts/log" "error" "Gemsets can not be used with non rvm controlled rubies (currently)."
@@ -714,8 +713,8 @@ __rvm_gemset_select() {
714
713
  fi
715
714
 
716
715
  if [[ -z "${rvm_ruby_gem_home:-""}" && -n "${rvm_ruby_string:-""}" ]] ; then
717
- rvm_ruby_gem_home="$rvm_gems_path/$rvm_ruby_string"
718
- rvm_ruby_global_gems_path="$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator:-"@"}global"
716
+ rvm_ruby_gem_home="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string"
717
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator}*}${rvm_gemset_separator:-"@"}global"
719
718
  fi
720
719
 
721
720
  rvm_ruby_gem_path="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
@@ -759,7 +758,7 @@ __rvm_gemset_use() {
759
758
  rvm_ruby_gem_home="${GEM_HOME//${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}${rvm_gemset_name}"
760
759
  GEM_HOME="$rvm_ruby_gem_home"
761
760
  BUNDLE_PATH="$rvm_ruby_gem_home"
762
- GEM_PATH="$rvm_ruby_gem_home/bin:$(echo "$GEM_HOME" | sed 's/'${rvm_gemset_separator:-"@"}'.*$//')${rvm_gemset_separator:-"@"}global/bin"
761
+ GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
763
762
  export rvm_ruby_gem_home GEM_HOME BUNDLE_PATH GEM_PATH
764
763
 
765
764
  __rvm_use # Now ensure the selection takes effect for the environment.
@@ -771,10 +770,10 @@ __rvm_gemset_use() {
771
770
  __rvm_gemset_clear() {
772
771
  rvm_gemset_name="" ; shift # TODO: Is this shift necessary???
773
772
  rvm_ruby_gem_home="${GEM_HOME//${rvm_gemset_separator:-"@"}*}"
774
- rvm_ruby_global_gems_path="$(echo "${GEM_HOME:-""}" | sed 's/'${rvm_gemset_separator:-"@"}'.*$//')${rvm_gemset_separator:-"@"}global"
773
+ rvm_ruby_global_gems_path="${rvm_ruby_gem_home%%${rvm_gemset_separator:-"@"}*}${rvm_gemset_separator:-"@"}global"
775
774
  GEM_HOME=$rvm_ruby_gem_home
776
775
  BUNDLE_PATH="$rvm_ruby_gem_home"
777
- GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin"
776
+ GEM_PATH="$rvm_ruby_gem_home:$rvm_ruby_global_gems_path"
778
777
  export rvm_ruby_gem_home rvm_ruby_global_gems_path GEM_HOME BUNDLE_PATH GEM_PATH
779
778
  __rvm_use # Now ensure the selection takes effect for the environment.
780
779
  }
@@ -17,27 +17,42 @@ __error_on_result() {
17
17
  snapshot_save() {
18
18
 
19
19
  if [[ -z "$1" ]]; then
20
- echo "Usage: rvm snapshot save name" >&2
21
- echo "Saves a snapshot to <name>.tar.gz in the current directory." >&2
20
+
21
+ printf "
22
+
23
+ Usage:
24
+
25
+ rvm snapshot save name
26
+
27
+ Description:
28
+
29
+ Saves a snapshot describing the rvm installation
30
+ to <name>.tar.gz in the current working directory.\
31
+
32
+ " >&2
33
+
22
34
  return 1
35
+
23
36
  fi
24
37
 
25
38
  # Create the temporary directory.
26
- local snapshot_temp_path="$rvm_tmp_path/$$-snapshot"
27
- \rm -rf "$snapshot_temp_path"
28
- \mkdir -p "$snapshot_temp_path"
39
+ local snapshot_temp_path="${rvm_tmp_path:-"$rvm_path/tmp"}/$$-snapshot"
40
+
41
+ rm -rf "$snapshot_temp_path"
42
+
43
+ mkdir -p "$snapshot_temp_path"
29
44
 
30
45
  "$rvm_path/scripts/log" "info" "Backing up a list of aliases"
31
- \cp "$rvm_config_path/alias" "$snapshot_temp_path/"
46
+ cp "$rvm_path/config/alias" "$snapshot_temp_path/"
32
47
 
33
48
  "$rvm_path/scripts/log" "info" "Backing up your user preferences"
34
- \cp "$rvm_config_path/user" "$snapshot_temp_path/"
49
+ cp "$rvm_path/config/user" "$snapshot_temp_path/"
35
50
 
36
51
  "$rvm_path/scripts/log" "info" "Backing up your installed packages"
37
- sed -e 's/-//' -e 's/^lib//' < "$rvm_config_path/packages" | awk -F= '{print $1}' | sort | uniq > "$snapshot_temp_path/packages"
52
+ sed -e 's/-//' -e 's/^lib//' < "$rvm_path/config/packages" | awk -F= '{print $1}' | sort | uniq > "$snapshot_temp_path/packages"
38
53
 
39
54
  "$rvm_path/scripts/log" "info" "Backing up all of your gemsets"
40
- \mkdir -p "$snapshot_temp_path/gems"
55
+ mkdir -p "$snapshot_temp_path/gems"
41
56
 
42
57
  (
43
58
  builtin cd "$snapshot_temp_path/gems"
@@ -52,7 +67,7 @@ snapshot_save() {
52
67
 
53
68
  __error_on_result "$result" "Error exporting gemset contents for $snapshot_gemset" && return "$result"
54
69
 
55
- \mkdir -p "./$snapshot_gemset/"
70
+ mkdir -p "./$snapshot_gemset/"
56
71
 
57
72
  [[ -d "$GEM_HOME/cache/" ]] && \cp -R "$GEM_HOME/cache/" "./$snapshot_gemset/"
58
73
 
@@ -60,44 +75,65 @@ snapshot_save() {
60
75
  )
61
76
 
62
77
  "$rvm_path/scripts/log" "info" "Backing up all of your installed rubies"
78
+
63
79
  echo '#!/usr/bin/env bash -e' > "$snapshot_temp_path/install-rubies.sh"
80
+
64
81
  echo "source \"\$rvm_path/scripts/rvm\" || true" >> "$snapshot_temp_path/install-rubies.sh"
65
- local snapshot_ruby_name_file="$rvm_tmp_path/$$-rubies"
66
- local snapshot_alias_name_file="$rvm_tmp_path/$$-aliases"
67
- local snapshot_installable_file="$rvm_tmp_path/$$-installable"
82
+
83
+ local snapshot_ruby_name_file="${rvm_tmp_path:-"$rvm_path/tmp"}/$$-rubies"
84
+
85
+ local snapshot_alias_name_file="${rvm_tmp_path:-"$rvm_path/tmp"}/$$-aliases"
86
+
87
+ local snapshot_installable_file="${rvm_tmp_path:-"$rvm_path/tmp"}/$$-installable"
68
88
 
69
89
  "$rvm_path/scripts/alias" list | awk -F ' => ' '{print $1}' | sort | uniq 2>/dev/null > "$snapshot_alias_name_file"
90
+
70
91
  "$rvm_path/scripts/list" strings | \tr ' ' '\n' | sort | uniq > "$snapshot_ruby_name_file"
92
+
71
93
  comm -2 -3 "$snapshot_ruby_name_file" "$snapshot_alias_name_file" > "$snapshot_installable_file"
72
- \rm -rf "$snapshot_ruby_name_file" "$snapshot_alias_name_file"
94
+
95
+ rm -rf "$snapshot_ruby_name_file" "$snapshot_alias_name_file"
73
96
 
74
97
  local snapshot_primary_ruby="$(\grep '^\(ree\|ruby-1.8.7\)' < "$snapshot_installable_file" | \grep -v '-head$' | sort -r | head -n1)"
98
+
75
99
  local snapshot_ruby_order="$snapshot_primary_ruby $(\grep -v "$snapshot_primary_ruby" < "$snapshot_installable_file")"
100
+
76
101
  for snapshot_ruby_name in $snapshot_ruby_order ; do
102
+
77
103
  snapshot_install_command="$(__rvm_recorded_install_command "$snapshot_ruby_name")"
104
+
78
105
  if [[ -n "$snapshot_install_command" ]]; then
106
+
79
107
  echo "rvm install $snapshot_install_command" | sed "s#$rvm_path#'\\\"\$rvm_path\\\"'#" >> "$snapshot_temp_path/install-rubies.sh"
108
+
80
109
  else
110
+
81
111
  __rvm_become "$snapshot_ruby_name"
112
+
82
113
  ruby "$rvm_path/lib/rvm/install_command_dumper.rb" >> "$snapshot_temp_path/install-rubies.sh"
114
+
83
115
  fi
116
+
84
117
  unset snapshot_install_command
118
+
85
119
  done; unset snapshot_ruby_name snapshot_primary_ruby
86
120
 
87
- \rm -rf "$snapshot_installable_file"
121
+ rm -rf "$snapshot_installable_file"
88
122
 
89
123
  "$rvm_path/scripts/log" "info" "Compressing snapshotting"
124
+
90
125
  local destination_path="$PWD"
91
126
  (
92
127
  builtin cd "$snapshot_temp_path"
93
- \rm -rf "$destination_path/$1.tar.gz"
128
+ rm -rf "$destination_path/$1.tar.gz"
94
129
  tar czf "$destination_path/$1.tar.gz" .
95
130
  result="$?"
96
131
  __error_on_result "$result" "Error creating archive $destination_path/$1.tar.gz" && return "$result"
97
132
  )
98
133
 
99
134
  "$rvm_path/scripts/log" "info" "Cleaning up"
100
- \rm -rf "$snapshot_temp_path"
135
+
136
+ rm -rf "$snapshot_temp_path"
101
137
 
102
138
  "$rvm_path/scripts/log" "info" "Snapshot complete"
103
139
  }
@@ -116,7 +152,7 @@ snapshot_load() {
116
152
  return 1
117
153
  fi
118
154
 
119
- local snapshot_temp_path="$rvm_tmp_path/$$-snapshot"
155
+ local snapshot_temp_path="${rvm_tmp_path:-"$rvm_path/tmp"}/$$-snapshot"
120
156
 
121
157
  \rm -rf "$snapshot_temp_path"
122
158
  \mkdir -p "$snapshot_temp_path"
@@ -130,7 +166,7 @@ snapshot_load() {
130
166
  )
131
167
 
132
168
  "$rvm_path/scripts/log" "info" "Restoring user settings"
133
- \cp -f "$snapshot_temp_path/user" "$rvm_config_path/user"
169
+ \cp -f "$snapshot_temp_path/user" "$rvm_path/config/user"
134
170
 
135
171
  "$rvm_path/scripts/log" "info" "Installing rvm-managed packages"
136
172
  for snapshot_package in $(cat "$snapshot_temp_path/packages"); do