scripts/gemsets in rvm-1.0.7 vs scripts/gemsets in rvm-1.0.8

- old
+ new

@@ -12,11 +12,11 @@ rvm gemset [action] Action: - {import,export,create,copy,empty,delete,name,dir,list,gemdir,install,pristine,clear,use,update,globalcache} + {import,export,create,copy,empty,delete,name,dir,list,gemdir,install,pristine,clear,use,update,unpack,globalcache} Description: Commands for working with and manipulating gemsets within RVM. @@ -25,11 +25,11 @@ gemset_update() { if [[ -z "$rvm_ruby_strings" ]]; then "$rvm_path/scripts/log" "info" "Running gem update for all rubies and gemsets." - rvm_ruby_strings="$(builtin cd "$rvm_gems_path" ; find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')" + rvm_ruby_strings="$(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print 2>/dev/null | grep -v '^\(doc\|cache\|@\|system\)' | \tr '\n' ',')" rvm_ruby_strings="${rvm_ruby_strings/%,}" rvm_ruby_strings="${rvm_ruby_strings//.\/}" else "$rvm_path/scripts/log" "info" "Running gem update for the specified rubies." fi @@ -60,15 +60,15 @@ elif [[ "$1" == "disable" ]]; then "$rvm_path/scripts/log" "info" "Removing the global cache (note: this will empty the caches)" - directories=($(builtin cd "$rvm_gems_path" ; find . -maxdepth 1 -mindepth 1 -type d -print)) + directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print)) for directory_name in "${directories[@]//.\/}"; do - current_cache_path="$rvm_gems_path/$directory_name/cache" + current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache" if [[ -L "$current_cache_path" && "$(readlink "$current_cache_path")" == "$rvm_gems_cache_path" ]]; then "$rvm_path/scripts/log" "info" "Reverting the gem cache for $directory_name to an empty directory." @@ -76,23 +76,23 @@ mkdir -p "$current_cache_path" 2>/dev/null fi done - "$rvm_path/scripts/db" "$rvm_config_path/user" "use_gemset_globalcache" "delete" + "$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" "delete" elif [[ "$1" == "enable" ]]; then "$rvm_path/scripts/log" "info" "Enabling global cache for gems." mkdir -p "$rvm_gems_cache_path" - directories=($(builtin cd "$rvm_gems_path" ; find . -maxdepth 1 -mindepth 1 -type d -print)) + directories=($(builtin cd "${rvm_gems_path:-"$rvm_path/gems"}" ; find . -maxdepth 1 -mindepth 1 -type d -print)) for directory_name in "${directories[@]//.\/}" ; do - current_cache_path="$rvm_gems_path/$directory_name/cache" + current_cache_path="${rvm_gems_path:-"$rvm_path/gems"}/$directory_name/cache" if [[ -d "$current_cache_path" && ! -L "$current_cache_path" ]]; then "$rvm_path/scripts/log" "info" "Moving the gem cache for $directory_name to the global cache." @@ -103,11 +103,11 @@ ln -nfs "$rvm_gems_cache_path" "$current_cache_path" fi done - "$rvm_path/scripts/db" "$rvm_config_path/user" "use_gemset_globalcache" "true" + "$rvm_path/scripts/db" "$rvm_path/config/user" "use_gemset_globalcache" "true" else printf " Usage: @@ -173,27 +173,27 @@ gemset_list() { if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi "$rvm_path/scripts/log" "info" \ - "\ngemsets for $rvm_ruby_string (found in $rvm_gems_path/$rvm_ruby_string)" + "\ngemsets for $rvm_ruby_string (found in ${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string)" - if [[ -n "${rvm_gems_path:-""}" ]] ; then + if [[ -d "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then if [[ -n "${rvm_ruby_string:-""}" ]] ; then - ls "${rvm_gems_path}/" | awk -F"${rvm_gemset_separator:-"@"}" "/${rvm_ruby_string}${rvm_gemset_separator:-"@"}/{print \$2}" 2>/dev/null + ls "${rvm_gems_path:-"$rvm_path/gems"}/" | awk -F"${rvm_gemset_separator:-"@"}" "/${rvm_ruby_string}${rvm_gemset_separator:-"@"}/{print \$2}" 2>/dev/null else "$rvm_path/scripts/log" "error" \ "\$rvm_ruby_string is not set!" return 1 fi else "$rvm_path/scripts/log" "error" \ - "\$rvm_gems_path is not set!" + "${rvm_gems_path:-"$rvm_path/gems"} does not exist!" return 1 fi printf "\n" return 0 @@ -203,11 +203,11 @@ if [[ ${rvm_ruby_selected_flag:-0} -eq 0 ]] ; then __rvm_select ; fi if [[ -n "$rvm_gemset_name" ]] ; then - gemdir="$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name" + gemdir="${rvm_gems_path:-"$rvm_path/gems"}/$rvm_ruby_string${rvm_gemset_separator:-"@"}$rvm_gemset_name" if [[ -d "$gemdir" && "$gemdir" != '/' && ${rvm_force_flag:-0} -gt 0 ]] ; then rm -rf "$gemdir" @@ -343,18 +343,61 @@ "Gems directory does not exist for $source_path ($source_path)" return 1 fi } +gemset_unpack() { + + local gems name directory version versions + + directory="${args[$__array_start]}" + + if [[ -z "$directory" ]] ; then + directory="vendor/gems" + fi + + if [[ -n "$rvm_ruby_gem_home" ]] ; then + export GEM_HOME="$rvm_ruby_gem_home" + export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin" + export BUNDLE_PATH="$rvm_ruby_gem_home" + fi + + "$rvm_path/scripts/log" "info" \ + "Unpacking current environments gemset to ${directory}\n" + + unset -f gem + + gems=($(command gem list | sed 's#[\(|\)]##g' | sed -e 's#, #,#g' -e 's/ /;/g')) + + for gem in ${gems[@]} ; do + + name="${gem/;*/}" + + versions="${gem/*;/}" ; versions=(${versions//,/ }) + + for version in "${versions[@]}" ; do + + ( command gem unpack "$name" -v"$version" --target "$directory" )& + + done + + done ; wait + + "$rvm_path/scripts/log" "info" \ + "Unpacking into ${directory} complete\n" + + return 0 +} + gemset_export() { local gems name file_name version versions rvm_file_name="${rvm_file_name:-${gems_args// }}" if [[ -n "$rvm_ruby_gem_home" ]] ; then export GEM_HOME="$rvm_ruby_gem_home" - export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator:-"@"}global/bin" + export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin" export BUNDLE_PATH="$rvm_ruby_gem_home" fi if [[ -z "$rvm_file_name" ]] ; then @@ -397,11 +440,11 @@ gemset_import() { if [[ -n "${rvm_ruby_gem_home:-""}" ]] ; then export GEM_HOME="$rvm_ruby_gem_home" - export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_gems_path/$rvm_ruby_string${rvm_gemset_separator:-"@"}global/bin" + export GEM_PATH="$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin" export BUNDLE_PATH="$rvm_ruby_gem_home" fi rvm_file_name="${gems_args}" @@ -492,11 +535,12 @@ } # Install a gem gem_install() { - local gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action + local result gem gem_prefix gem_name gem_version gem_file_name gem_postfix cache_file gem_file_name gem_string gem_action + result=0 # First we parse the gem args to pick apart the pieces. __rvm_parse_gems_args @@ -542,15 +586,15 @@ "$rvm_path/scripts/log" "info" "$gem_name $gem_version exists, skipping (--force to re-install)" else if [[ -s "$(__rvm_current_gemcache_dir)/$(basename $gem_file_name)" ]] ; then - mkdir -p "$rvm_tmp_path/$$/" + mkdir -p "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/" - mv "$(__rvm_current_gemcache_dir)/$gem_file_name" "$rvm_tmp_path/$$/$gem_file_name" + mv "$(__rvm_current_gemcache_dir)/$gem_file_name" "${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name" - gem="$rvm_tmp_path/$$/$gem_file_name -f -l" + gem="${rvm_tmp_path:-"$rvm_path/tmp"}/$$/$gem_file_name -f -l" else gem="$cache_file" fi fi fi @@ -560,13 +604,13 @@ if [[ -n "$gem" ]] ; then # TODO: Set vars if fourth field is non-empty (means that there are conditional statements to execute in the gem install line. if [[ "rvm_make_flags_flag" -eq 1 ]] ; then __rvm_make_flags ; fi - if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "$rvm_gems_path" ]] ; then + if [[ -n "$rvm_ruby_gem_home" && "$rvm_ruby_gem_home" != "${rvm_gems_path:-"$rvm_path/gems"}" ]] ; then - command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_gems_path/${rvm_ruby_string}${rvm_gemset_separator:-"@"}global/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} command gem install $gems_args $rvm_gem_options $gem_postfix $vars" + command="GEM_HOME='$rvm_ruby_gem_home' GEM_PATH='$rvm_ruby_gem_home/bin:$rvm_ruby_global_gems_path/bin' BUNDLE_PATH='${rvm_ruby_gem_home}' ${gem_prefix} command gem install $gems_args $rvm_gem_options $gem_postfix $vars" else #--ignore-dependencies command="$gem_prefix command gem install --ignore-dependencies $gems_args $rvm_gem_options -q $gem $gem_postfix $vars" @@ -653,11 +697,11 @@ return 0 } gemset_pristine() { - if command -v gem > /dev/null ; then + if ( unset -f gem ; command -v gem > /dev/null ) ; then gem pristine --all return $? @@ -671,11 +715,12 @@ } # Loads the default gemsets for the current interpreter and gemset. gemset_initial() { - "$rvm_path/scripts/log" "info" "Importing initial gemsets for $(__rvm_environment_identifier)." + "$rvm_path/scripts/log" "info" \ + "Importing initial gemsets for $(__rvm_environment_identifier)." mkdir -p "$rvm_path/gemsets/${rvm_ruby_string//-//}" 2>/dev/null for gemsets_path in $(__rvm_ruby_string_paths_under "$rvm_path/gemsets") ; do @@ -796,9 +841,12 @@ prune) gemset_prune ;; update) gemset_update + ;; + unpack) + gemset_unpack ;; globalcache) gemset_globalcache "$2" ;; clear)