Commit ff75ca72 by Mislav Marohnić

Support changing RUBY_BUILD_ROOT

This is to allow specifying an alternate path where `share/ruby-build/*`
definitions reside. Useful in tests as well.
parent 4e2177d5
...@@ -118,6 +118,8 @@ You can set certain environment variables to control the build process. ...@@ -118,6 +118,8 @@ You can set certain environment variables to control the build process.
choosing. choosing.
* `RUBY_BUILD_SKIP_MIRROR`, if set, forces ruby-build to download packages from * `RUBY_BUILD_SKIP_MIRROR`, if set, forces ruby-build to download packages from
their original source URLs instead of using a mirror. their original source URLs instead of using a mirror.
* `RUBY_BUILD_ROOT` overrides the default location from where build definitions
in `share/ruby-build/` are looked up.
* `CC` sets the path to the C compiler. * `CC` sets the path to the C compiler.
* `RUBY_CFLAGS` lets you pass additional options to the default `CFLAGS`. Use * `RUBY_CFLAGS` lets you pass additional options to the default `CFLAGS`. Use
this to override, for instance, the `-O3` option. this to override, for instance, the `-O3` option.
......
...@@ -907,10 +907,12 @@ usage() { ...@@ -907,10 +907,12 @@ usage() {
} }
list_definitions() { list_definitions() {
shopt -s nullglob
{ for definition in "${RUBY_BUILD_ROOT}/share/ruby-build/"*; do { for definition in "${RUBY_BUILD_ROOT}/share/ruby-build/"*; do
echo "${definition##*/}" echo "${definition##*/}"
done done
} | sort } | sort
shopt -u nullglob
} }
...@@ -918,7 +920,10 @@ list_definitions() { ...@@ -918,7 +920,10 @@ list_definitions() {
unset VERBOSE unset VERBOSE
unset KEEP_BUILD_PATH unset KEEP_BUILD_PATH
unset HAS_PATCH unset HAS_PATCH
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
if [ -z "$RUBY_BUILD_ROOT" ]; then
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
fi
parse_options "$@" parse_options "$@"
......
...@@ -11,6 +11,21 @@ NUM_DEFINITIONS="$(ls "$BATS_TEST_DIRNAME"/../share/ruby-build | wc -l)" ...@@ -11,6 +11,21 @@ NUM_DEFINITIONS="$(ls "$BATS_TEST_DIRNAME"/../share/ruby-build | wc -l)"
assert [ "${#lines[*]}" -eq "$NUM_DEFINITIONS" ] assert [ "${#lines[*]}" -eq "$NUM_DEFINITIONS" ]
} }
@test "custom RUBY_BUILD_ROOT: nonexistent" {
export RUBY_BUILD_ROOT="$TMP"
assert [ ! -e "${RUBY_BUILD_ROOT}/share/ruby-build" ]
run ruby-build --definitions
assert_success ""
}
@test "custom RUBY_BUILD_ROOT: single definition" {
export RUBY_BUILD_ROOT="$TMP"
mkdir -p "${RUBY_BUILD_ROOT}/share/ruby-build"
touch "${RUBY_BUILD_ROOT}/share/ruby-build/1.9.3-test"
run ruby-build --definitions
assert_success "1.9.3-test"
}
@test "installing nonexistent definition" { @test "installing nonexistent definition" {
run ruby-build "nonexistent" "${TMP}/install" run ruby-build "nonexistent" "${TMP}/install"
assert [ "$status" -eq 2 ] assert [ "$status" -eq 2 ]
......
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