Permalink
Browse files

split __rvm_package into smaller functions

  • Loading branch information...
1 parent 06f7d2e commit 3f7d808d297c75df718eb13b95ad9d5a34d46e43 @mpapis mpapis committed Jan 24, 2013
View
8 scripts/external
@@ -271,10 +271,10 @@ external_import_validate_archive()
typeset -a downloaded_names path_to_bin_ruby
__rvm_read_lines path_to_bin_ruby < <(
- __rvm_package list "$rvm_archives_path/${rvm_ruby_package_file}" | grep "bin/ruby$"
+ __rvm_package_list "$rvm_archives_path/${rvm_ruby_package_file}" | grep "bin/ruby$"
)
__rvm_read_lines downloaded_names < <(
- __rvm_package list "$rvm_archives_path/${rvm_ruby_package_file}" | awk -F/ '{print $1}' | sort -u
+ __rvm_package_list "$rvm_archives_path/${rvm_ruby_package_file}" | awk -F/ '{print $1}' | sort -u
)
if
[[ "${#path_to_bin_ruby[*]}" -eq 1 ]]
@@ -298,7 +298,7 @@ external_import_extract()
{
rm -rf "${rvm_rubies_path}/${rvm_ruby_string}"
mkdir -p "${rvm_rubies_path}/${rvm_ruby_string}"
- __rvm_package extract "$rvm_archives_path/${rvm_ruby_package_file}" "${rvm_rubies_path}/${rvm_ruby_string}" || {
+ __rvm_package_extract "$rvm_archives_path/${rvm_ruby_package_file}" "${rvm_rubies_path}/${rvm_ruby_string}" || {
$err_command "Unpacking ${rvm_ruby_package_file} failed."
return 6
}
@@ -450,7 +450,7 @@ external_prepare_package()
rvm_log "Preparing ${rvm_ruby_string} ..."
if
- __rvm_package create "${file_name}" "${rvm_rubies_path}" "${rvm_ruby_string}"
+ __rvm_package_create "${file_name}" "${rvm_rubies_path}" "${rvm_ruby_string}"
then
rvm_log "Prepared ${file_name}."
else
View
2 scripts/functions/manage/base
@@ -583,7 +583,7 @@ __rvm_fetch_ruby()
mkdir -p "${rvm_tmp_path:-/tmp}/rvm_src_$$"
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
- __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
+ __rvm_package_extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
2 scripts/functions/manage/ironruby
@@ -65,7 +65,7 @@ ironruby_install()
mkdir -p "${rvm_src_path}/$rvm_ruby_string" "$rvm_ruby_home"
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
- __rvm_package extract "${rvm_archives_path}/${rvm_ruby_package_file}" "${rvm_src_path}/$rvm_ruby_string" ||
+ __rvm_package_extract "${rvm_archives_path}/${rvm_ruby_package_file}" "${rvm_src_path}/$rvm_ruby_string" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
2 scripts/functions/manage/maglev
@@ -72,7 +72,7 @@ maglev_install()
fi
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_gemstone_package_file to ${rvm_src_path}" \
- __rvm_package extract "${rvm_archives_path}/$rvm_gemstone_package_file.$rvm_archive_extension" "${rvm_src_path}" ||
+ __rvm_package_extract "${rvm_archives_path}/$rvm_gemstone_package_file.$rvm_archive_extension" "${rvm_src_path}" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
2 scripts/functions/manage/ree
@@ -39,7 +39,7 @@ ree_install()
fi
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
- __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_src_path}/" ||
+ __rvm_package_extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_src_path}/" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
2 scripts/functions/manage/rubinius
@@ -104,7 +104,7 @@ rubinius_install()
fi
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
- __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
+ __rvm_package_extract "${rvm_archives_path}/$rvm_ruby_package_file" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
2 scripts/functions/pkg
@@ -10,7 +10,7 @@ install_package()
"$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $?
__rvm_log_command "$package/extract" "Extracting ${package} to $rvm_src_path/$package-$version" \
- __rvm_package extract "$rvm_archives_path/$package-$version.$archive_format" "$rvm_src_path" ||
+ __rvm_package_extract "$rvm_archives_path/$package-$version.$archive_format" "$rvm_src_path" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
View
76 scripts/functions/utility
@@ -732,43 +732,63 @@ __rvm_fix_group_permissions()
fi
}
-# params: action archive_file [path [path2]]
-__rvm_package()
+# params: archive_file
+__rvm_package_list()
{
- rvm_debug __rvm_package:$#: "$@"
- case "$1-$2" in
- list-*.zip)
- unzip -Z -1 "$2"
+ rvm_debug __rvm_package_list:$#: "$@"
+ case "$1" in
+ *.zip)
+ unzip -Z -1 "$1"
;;
- extract-*.zip)
- [[ -d "$3" ]] || mkdir -p "$3"
- unzip -q -o "$2" -d "$3"
+ *.tar.bz2)
+ ${rvm_tar_command:-tar} tjf "$1"
;;
- list-*.tar.bz2)
- ${rvm_tar_command:-tar} tjf "$2"
+ *.tar.gz|list-*.tgz)
+ ${rvm_tar_command:-tar} tzf "$1"
;;
- create-*.tar.bz2)
- if [[ -z "${4:-}" ]]
- then ${rvm_tar_command:-tar} cjf "$2" "$3"
- else ${rvm_tar_command:-tar} cjf "$2" -C "$3" "$4"
- fi
+ *)
+ return 199
+ ;;
+ esac
+}
+
+# params: archive_file [path]
+__rvm_package_extract()
+{
+ rvm_debug __rvm_package_extract:$#: "$@"
+ [[ -d "$2" ]] || mkdir -p "$2"
+ case "$1" in
+ *.zip)
+ unzip -q -o "$1" -d "$2"
;;
- extract-*.tar.bz2)
- [[ -d "$3" ]] || mkdir -p "$3"
- ${rvm_tar_command:-tar} xjf "$2" -C "$3" ${rvm_tar_options:-}
+ *.tar.bz2)
+ ${rvm_tar_command:-tar} xjf "$1" -C "$2" ${rvm_tar_options:-}
;;
- list-*.tar.gz|list-*.tgz)
- ${rvm_tar_command:-tar} tzf "$2"
+ *.tar.gz|extract-*.tgz)
+ ${rvm_tar_command:-tar} xzf "$1" -C "$2" ${rvm_tar_options:-}
;;
- create-*.tar.gz|create-*.tgz)
- if [[ -z "${4:-}" ]]
- then ${rvm_tar_command:-tar} czf "$2" "$3"
- else ${rvm_tar_command:-tar} czf "$2" -C "$3" "$4"
+ *)
+ return 199
+ ;;
+ esac
+}
+
+# params: archive_file [path [path2]]
+__rvm_package_create()
+{
+ rvm_debug __rvm_package_create:$#: "$@"
+ case "$1" in
+ *.tar.bz2)
+ if [[ -z "${3:-}" ]]
+ then ${rvm_tar_command:-tar} cjf "$1" "$2"
+ else ${rvm_tar_command:-tar} cjf "$1" -C "$2" "$3"
fi
;;
- extract-*.tar.gz|extract-*.tgz)
- [[ -d "$3" ]] || mkdir -p "$3"
- ${rvm_tar_command:-tar} xzf "$2" -C "$3" ${rvm_tar_options:-}
+ *.tar.gz|create-*.tgz)
+ if [[ -z "${3:-}" ]]
+ then ${rvm_tar_command:-tar} czf "$1" "$2"
+ else ${rvm_tar_command:-tar} czf "$1" -C "$2" "$3"
+ fi
;;
*)
return 199
View
2 scripts/rubygems
@@ -183,7 +183,7 @@ rubygems_setup()
\mkdir -p "${rvm_src_path}/$rvm_gem_package_name"
__rvm_log_command "rubygems.extract" "Extracting $rvm_gem_package_name ..." \
- __rvm_package extract "${rvm_archives_path}/$rvm_gem_package_name.tgz" "${rvm_src_path}"
+ __rvm_package_extract "${rvm_archives_path}/$rvm_gem_package_name.tgz" "${rvm_src_path}"
fi
rubygems_remove # Remove old gems.

0 comments on commit 3f7d808

Please sign in to comment.