scripts/snapshot in rvm-1.0.11 vs scripts/snapshot in rvm-1.0.13
- old
+ new
@@ -3,21 +3,22 @@
unset GREP_COLOR
unset GREP_OPTIONS
source "$rvm_path/scripts/base"
-__error_on_result() {
+__error_on_result()
+{
if [[ "$1" -gt 0 ]]; then
"$rvm_path/scripts/log" "fail" "$2 - Aborting now."
return 0
else
return 1
fi
}
-snapshot_save() {
-
+snapshot_save()
+{
if [[ -z "$1" ]]; then
printf "
Usage:
@@ -136,11 +137,14 @@
rm -rf "$snapshot_temp_path"
"$rvm_path/scripts/log" "info" "Snapshot complete"
}
-snapshot_load() {
+snapshot_load()
+{
+ local package_info
+
if [[ -z "$1" ]]; then
echo "Usage: rvm snapshot load name" >&2
echo "Loads a snapshot from <name>.tar.gz in the current directory." >&2
return 1
fi
@@ -174,17 +178,22 @@
result="$?"
__error_on_result "$result" "Error installing package '$snapshot_package'" && return "$result"
done; unset snapshot_package
"$rvm_path/scripts/log" "info" "Installing rubies"
+
chmod +x "$snapshot_temp_path/install-rubies.sh"
+
"$snapshot_temp_path/install-rubies.sh"
result="$?"
+
__error_on_result "$result" "Error importing rubies." && return "$result"
export rvm_create_flag=1
+
"$rvm_path/scripts/log" "info" "Setting up gemsets"
+
(
builtin cd "$snapshot_temp_path/gems"
gems=($(find . -mindepth 0 -maxdepth 0 -type f -iname '*.gems' | sed 's/.gems$//'))
@@ -211,10 +220,11 @@
"Error importing gemset for $snapshot_gemset" && return "$result"
done
)
"$rvm_path/scripts/log" "info" "Restoring aliases"
+
while read -r package_info; do
# Note: this assumes an '=' int the input...
local alias_name="${package_info/=*}"
local alias_ruby="${package_info/*=}"
@@ -223,18 +233,18 @@
(source "$rvm_path/scripts/rvm" && rvm use "$alias_ruby" --default) >/dev/null 2>&1
result="$?"
__error_on_result "$result" "Error setting default to $alias_ruby" && return "$result"
fi
done < "$snapshot_temp_path/alias"
- unset package_info
"$rvm_path/scripts/log" "info" "Cleaning up load process"
\rm -rf "$snapshot_temp_path"
"$rvm_path/scripts/log" "info" "Loaded snapshot from $(basename "$snapshot_archive")"
}
-snapshot_usage() {
+snapshot_usage()
+{
echo "Usage: rvm snapshot {save,load} file" >&2
return 1
}