[DRE-commits] [SCM] rbenv.git branch, master, updated. debian/0.1.2+git20100922-1-15-ga004426
Antonio Terceiro
terceiro at debian.org
Tue Jan 10 18:35:54 UTC 2012
The following commit has been merged in the master branch:
commit 0a91c1cd182cf8b49f8a7c79e519d93d4ad0d91b
Author: Antonio Terceiro <terceiro at debian.org>
Date: Tue Jan 10 14:04:24 2012 -0200
Import tarball from rbenv-alternatives plugin
diff --git a/rbenv-alternatives/README.md b/rbenv-alternatives/README.md
new file mode 100644
index 0000000..4ab2559
--- /dev/null
+++ b/rbenv-alternatives/README.md
@@ -0,0 +1,62 @@
+# rbenv-alternatives
+
+This plugin allow you to add Ruby interpreters available through the Debian
+alternatives system into rbenv. This means you can install the different Ruby
+interpreters through APT on Debian and derivative distributions, and switch
+between them using rbenv.
+
+The Ruby interpreters installed via APT will become available to use with rbenv
+in addition to any other Ruby interpreter you may have installed into
+`~/.rbenv/versions` in any other way.
+
+This plugin also install hooks that configure Rubygems to install gems inside
+~/.rbenv/${version}/gems. This way you get completely separated Ruby
+environments.
+
+## Installation
+
+Just copy `rbenv-alternatives` into any directory in your `$PATH`, after
+installing and setting up rbenv itself.
+
+If you install rbenv through APT, then it will already bring this plugin with
+it:
+
+ # apt-get install rbenv
+
+## Usage
+
+ $ rbenv alternatives
+ $ rbenv versions
+ 1.8.7-debian
+ 1.9.2-debian
+ $ rbenv global 1.9.2-debian
+ $ rbenv version
+ 1.9.2-debian (set by /home/terceiro/.rbenv/global)
+ $ ruby -v
+ ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
+
+Whenever you install a new Ruby interpreter, or uninstall a previously
+installed one, just run `rbenv alternatives` again and it will update your
+list of Debian-provided Ruby interpreters with rbenv.
+
+## Copyright
+
+Copyright © 2011-2012, Antonio Terceiro <terceiro at debian.org>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/rbenv-alternatives/bin/rbenv-alternatives b/rbenv-alternatives/bin/rbenv-alternatives
new file mode 100755
index 0000000..2bd2299
--- /dev/null
+++ b/rbenv-alternatives/bin/rbenv-alternatives
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$RBENV_DEBUG" ] && set -x
+
+if ! which update-alternatives >/dev/null; then
+ echo "Sorry, it seems like you do not have update-alternatives available on your PATH."
+ echo "Are you sure this is a Debian (or derivative) system?"
+ exit 1
+fi
+
+rm -rf ${RBENV_ROOT}/versions/*-debian
+
+update-alternatives --query ruby | sed -e '
+ 1,/^$/ d
+ /^Priority:/ d
+ /^Slaves:/ d
+ s/^Alternative: \(.*\)/master \1/
+ /\/usr\/bin/ !d
+' |
+while read command; do
+ case "$command" in
+ master*)
+ master=$(echo "$command" | awk '{print $2}')
+ version=$($master -e 'puts(((defined?(RUBY_ENGINE) && RUBY_ENGINE != "ruby") && RUBY_ENGINE + "-" || "") + (defined?(Rubinius) && Rubinius::VERSION || (defined?(JRUBY_VERSION) && JRUBY_VERSION) || RUBY_VERSION))')-debian
+ rm -rf "${RBENV_ROOT}/versions/$version"
+ mkdir -p "${RBENV_ROOT}/versions/$version/bin"
+ ln -s "$master" "${RBENV_ROOT}/versions/$version/bin/ruby"
+ ln -s "${master/ruby/gem}" "${RBENV_ROOT}/versions/$version/bin/gem"
+ echo "Added $version"
+ ;;
+ *)
+ prog=$(echo "$command" | awk '{print $1}')
+ target=$(echo "$command" | awk '{print $2}')
+ ln -s "$target" "${RBENV_ROOT}/versions/$version/bin/$prog"
+ ;;
+ esac
+done
diff --git a/rbenv-alternatives/etc/rbenv.d/exec/alternatives-gems.bash b/rbenv-alternatives/etc/rbenv.d/exec/alternatives-gems.bash
new file mode 100644
index 0000000..6c1dc9f
--- /dev/null
+++ b/rbenv-alternatives/etc/rbenv.d/exec/alternatives-gems.bash
@@ -0,0 +1,9 @@
+__current_version=$(rbenv-version-name)
+case "$__current_version" in
+ *-debian)
+ export GEM_HOME="${RBENV_ROOT}/versions/${__current_version}/gems"
+ ;;
+ *)
+ true
+ ;;
+esac
diff --git a/rbenv-alternatives/etc/rbenv.d/rehash/alternatives-gems.bash b/rbenv-alternatives/etc/rbenv.d/rehash/alternatives-gems.bash
new file mode 100644
index 0000000..10432c5
--- /dev/null
+++ b/rbenv-alternatives/etc/rbenv.d/rehash/alternatives-gems.bash
@@ -0,0 +1,11 @@
+for version in "${RBENV_ROOT}/versions/"*-debian; do
+ version_name=$(basename "$version")
+ gem_bindir="${RBENV_ROOT}/versions/${version_name}/gems/bin"
+ version_bindir="${RBENV_ROOT}/versions/${version_name}/bin"
+ if [[ -d "$gem_bindir" ]]; then
+ for program in "$gem_bindir"/*; do
+ program_name="$(basename $program)"
+ register_shim "$program_name"
+ done
+ fi
+done
diff --git a/rbenv-alternatives/etc/rbenv.d/which/alternatives-gems.bash b/rbenv-alternatives/etc/rbenv.d/which/alternatives-gems.bash
new file mode 100644
index 0000000..28eb631
--- /dev/null
+++ b/rbenv-alternatives/etc/rbenv.d/which/alternatives-gems.bash
@@ -0,0 +1,8 @@
+case "$RBENV_VERSION" in
+ *-debian)
+ command_path="${RBENV_ROOT}/versions/${RBENV_VERSION}/gems/bin/${RBENV_COMMAND}"
+ if ! [ -x "$RBENV_COMMAND_PATH" ] && [ -x "$command_path" ]; then
+ RBENV_COMMAND_PATH="$command_path"
+ fi
+ ;;
+esac
--
rbenv.git
More information about the Pkg-ruby-extras-commits
mailing list