From 77778bb3f1ef9a73f068dfb5681234ec5ea153ab Mon Sep 17 00:00:00 2001 From: Michal Papis Date: Tue, 21 Aug 2012 04:13:33 +0200 Subject: [PATCH] make __rvm_run to use __rvm_log_command ... prepare for better code --- scripts/functions/manage/base | 2 +- scripts/functions/manage/ree | 4 +- scripts/functions/manage/rubinius | 2 +- scripts/functions/pkg | 2 +- scripts/functions/utility | 61 +++++-------------------------- scripts/rubygems | 2 +- 6 files changed, 16 insertions(+), 57 deletions(-) diff --git a/scripts/functions/manage/base b/scripts/functions/manage/base index 10f659e8c2..e7fa2e702e 100644 --- a/scripts/functions/manage/base +++ b/scripts/functions/manage/base @@ -70,7 +70,7 @@ __rvm_apply_patches() if [[ -f "$full_patch_path" ]] then __rvm_run "patch.apply.${patch_name/*\/}" \ - "patch -F $patch_fuzziness -p$patch_level -N -f <\"$full_patch_path\"" \ + "patch -F $patch_fuzziness -p$patch_level -N -f -i \"$full_patch_path\"" \ "Applying patch '$patch_name' (located at $full_patch_path)" if (( $? > 0 )) then diff --git a/scripts/functions/manage/ree b/scripts/functions/manage/ree index bbf52e0169..de901783d0 100644 --- a/scripts/functions/manage/ree +++ b/scripts/functions/manage/ree @@ -28,7 +28,7 @@ ree_install() __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string" __rvm_run "extract" \ - "gunzip < \"${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension\" | $rvm_tar_command xf - -C ${rvm_src_path} ${rvm_tar_options:-}" \ + "$rvm_tar_command xzf \"${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension\" -C ${rvm_src_path} ${rvm_tar_options:-}" \ "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" result=$? @@ -70,7 +70,7 @@ ree_install() full_patch_path="$(__rvm_lookup_full_patch_path lib64)" cd "${rvm_src_path}/$rvm_ruby_string" __rvm_run "patch.apply.lib64" \ - "patch -F 3 -p1 -N -f <\"$full_patch_path\"" \ + "patch -F 3 -p1 -N -f -i \"$full_patch_path\"" \ "Applying patch 'lib64' (located at $full_patch_path)" ) result=$? diff --git a/scripts/functions/manage/rubinius b/scripts/functions/manage/rubinius index 4a44ee8832..31dd498591 100644 --- a/scripts/functions/manage/rubinius +++ b/scripts/functions/manage/rubinius @@ -105,7 +105,7 @@ rbx_install() exit $result fi __rvm_run "extract" \ - "gunzip < \"${rvm_archives_path}/$(basename ${rvm_ruby_package_file})\" | $rvm_tar_command xf - -C ${rvm_src_path} ${rvm_tar_options:-}" \ + "$rvm_tar_command xzf \"${rvm_archives_path}/$(basename ${rvm_ruby_package_file})\" -C ${rvm_src_path} ${rvm_tar_options:-}" \ "$rvm_ruby_string - #extracting" result=$? diff --git a/scripts/functions/pkg b/scripts/functions/pkg index ac2d1f9226..09ac64151f 100755 --- a/scripts/functions/pkg +++ b/scripts/functions/pkg @@ -55,7 +55,7 @@ install_package() if [[ ! -z "$patches" ]] ; then for patch in $(echo $patches | \tr ',' ' ') ; do - __rvm_run "$package/patch" "patch -p0 -f < $patch" "Applying patch '$patch'..." + __rvm_run "$package/patch" "patch -p0 -f -i $patch" "Applying patch '$patch'..." if [[ $? -gt 0 ]] ; then rvm_error "Patch $patch did not apply cleanly... back to the patching board :(" ; exit 1 fi diff --git a/scripts/functions/utility b/scripts/functions/utility index 432f976a09..7fef6ad588 100644 --- a/scripts/functions/utility +++ b/scripts/functions/utility @@ -102,59 +102,18 @@ __rvm_ruby_string_paths_under() # Run a specified command and log it. __rvm_run() { - typeset name log temp_log_path _command message - true ${rvm_debug_flag:=0} ${rvm_niceness:=0} + typeset name message + typeset -a _command_array name="${1:-}" - _command="${2:-}" +echo "1:$2" >&2 + _command_array=( ${2:-} ) +echo "2:${#_command_array[*]}:${_command_array[*]}" >&2 + eval "_command_array=( ${2:-} )" +echo "3:${#_command_array[*]}:${_command_array[*]}" >&2 message="${3:-}" - if [[ -n "$message" ]] - then - rvm_log "$message" - fi - - if (( rvm_debug_flag > 0 )) - then - rvm_debug "Executing: $_command" - fi - - if [[ -n "${rvm_ruby_string:-}" ]] - then - temp_log_path="${rvm_log_path}/$rvm_ruby_string" - else - temp_log_path="${rvm_log_path}" - fi - - log="$temp_log_path/$name.log" - - if [[ ! -d "${log%\/*}" ]] - then - \mkdir -p "${log%\/*}" - fi - - if [[ ! -f "$log" ]] - then - \touch "$log" # for zsh :( - fi - - # TODO: Allow an 'append_flag' setting? - printf "%b" "[$(date +'%Y-%m-%d %H:%M:%S')] $_command\n" > "$log" - - if (( rvm_niceness > 0 )) - then - _command="nice -n $rvm_niceness $_command" - fi - - eval "$_command" >> "$log" 2>&1 - result=$? - - if (( result > 0 )) - then - rvm_error "Error running '$_command', please read $log" - fi - - return ${result} + __rvm_log_command "$name" "$message" "${_command_array[@]}" || return $? } # Run a specified command and log it. @@ -189,12 +148,12 @@ __rvm_log_command() log="$temp_log_path/$name.log" [[ -d "${log%\/*}" ]] || \mkdir -p "${log%\/*}" - [[ -f "$log" ]] || \touch "$log" # for zsh :( + [[ -f "$log" ]] || \touch "$log" # for zsh :( # TODO: Allow an 'append_flag' setting? printf "%b" "[$(date +'%Y-%m-%d %H:%M:%S')] $*\n" > "$log" - "${_command[@]}" >> "$log" 2>&1 + env "${_command[@]}" >> "$log" 2>&1 result=$? if (( result > 0 )) diff --git a/scripts/rubygems b/scripts/rubygems index 2884d4d20c..f31d0a1c9e 100755 --- a/scripts/rubygems +++ b/scripts/rubygems @@ -154,7 +154,7 @@ rubygems_setup() fi __rvm_run "rubygems.extract" \ - "gunzip < ${rvm_archives_path}/$rvm_gem_package_name.tgz | $rvm_tar_command xf - -C ${rvm_src_path}" \ + "$rvm_tar_command xzf ${rvm_archives_path}/$rvm_gem_package_name.tgz -C ${rvm_src_path}" \ "Extracting $rvm_gem_package_name ..." fi