Commit e9129e5a by Sam Stephenson

rbenv-install tries to install packages by default, then falls back to building

parent 972498d4
...@@ -5,4 +5,4 @@ X Better error messages ...@@ -5,4 +5,4 @@ X Better error messages
X Show 'Downloading' and 'Installing' messages a la ruby-build X Show 'Downloading' and 'Installing' messages a la ruby-build
* Rewrite RbConfig::CONFIG['CC'] on install * Rewrite RbConfig::CONFIG['CC'] on install
* Patch rbx since the rewriter doesn't work there * Patch rbx since the rewriter doesn't work there
* rbenv-install should check for binary packages before building X rbenv-install should check for binary packages before building
...@@ -2,19 +2,26 @@ ...@@ -2,19 +2,26 @@
set -e set -e
[ -n "$RBENV_DEBUG" ] && set -x [ -n "$RBENV_DEBUG" ] && set -x
# Provide rbenv completions resolve_link() {
if [ "$1" = "--complete" ]; then $(type -p greadlink readlink | head -1) $1
exec ruby-build --definitions }
fi
if [ -z "$RBENV_ROOT" ]; then abs_dirname() {
RBENV_ROOT="${HOME}/.rbenv" local cwd="$(pwd)"
fi local path="$1"
DEFINITION="$1" while [ -n "$path" ]; do
case "$DEFINITION" in cd "${path%/*}"
"" | -* ) local name="${path##*/}"
{ echo "usage: rbenv install VERSION" path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
}
usage() {
{ echo "usage: rbenv install [--force-build | --force-package] VERSION"
echo " rbenv install /path/to/definition" echo " rbenv install /path/to/definition"
echo echo
echo "Available versions:" echo "Available versions:"
...@@ -22,11 +29,54 @@ case "$DEFINITION" in ...@@ -22,11 +29,54 @@ case "$DEFINITION" in
echo echo
} >&2 } >&2
exit 1 exit 1
}
bin_dir="$(abs_dirname "$0")"
export PATH="${bin_dir}:$PATH"
# Provide rbenv completions
if [ "$1" = "--complete" ]; then
exec ruby-build --definitions
fi
force_build=""
force_package=""
if [ "$1" = "--force-build" ]; then
force_build=1
shift
elif [ "$1" = "--force-package" ]; then
force_package=1
shift
fi
definition="$1"
case "$definition" in
"" | -* )
usage
;; ;;
esac esac
VERSION_NAME="${DEFINITION##*/}" if [ -z "$RBENV_ROOT" ]; then
PREFIX="${RBENV_ROOT}/versions/${VERSION_NAME}" RBENV_ROOT="${HOME}/.rbenv"
fi
version_name="${definition##*/}"
prefix="${RBENV_ROOT}/versions/${version_name}"
package() {
ruby-package install $* "$definition" "$prefix"
}
build() {
ruby-build "$definition" "$prefix"
}
if [ -n "$force_build" ]; then
build
elif [ -n "$force_package" ]; then
package
else
package --fail-silently || build
fi
ruby-build "$DEFINITION" "$PREFIX" rbenv rehash
rbenv rehash
\ No newline at end of file
...@@ -66,7 +66,7 @@ else ...@@ -66,7 +66,7 @@ else
package_filename="${TMPDIR}/${package_name}.$$" package_filename="${TMPDIR}/${package_name}.$$"
echo "Downloading $package_url..." >&2 echo "Downloading $package_url..." >&2
download "$package_url" "$package_filename" || { download "$package_url" "$package_filename" || {
echo "error: couldn't fetch package \`$package' ($package_url)" echo "error: couldn't download package \`$package' ($package_url)"
exit 1 exit 1
} >&2 } >&2
fi fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment