Skip to content

Commit 021280a

Browse files
committed
Automatically look for built-in definitions
1 parent db8d713 commit 021280a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

bin/ruby-build

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
set -e
44

5+
abs_dirname() {
6+
local cwd="$(pwd)"
7+
local path="$1"
8+
9+
while [ -n "$path" ]; do
10+
cd "${path%/*}"
11+
local name="${path##*/}"
12+
path="$(readlink "$name" || true)"
13+
done
14+
15+
pwd
16+
cd "$cwd"
17+
}
18+
519
install_package() {
620
local cwd="$(pwd)"
721
local package_name="$1"
@@ -96,12 +110,19 @@ usage() {
96110
}
97111

98112

113+
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
114+
99115
DEFINITION_PATH="$1"
100116
if [ -z "$DEFINITION_PATH" ]; then
101117
usage
102118
elif [ ! -e "$DEFINITION_PATH" ]; then
103-
echo "ruby-build: definition not found: ${DEFINITION_PATH}" >&2
104-
exit 1
119+
BUILTIN_DEFINITION_PATH="${RUBY_BUILD_ROOT}/share/ruby-build/${DEFINITION_PATH}"
120+
if [ -e "$BUILTIN_DEFINITION_PATH" ]; then
121+
DEFINITION_PATH="$BUILTIN_DEFINITION_PATH"
122+
else
123+
echo "ruby-build: definition not found: ${DEFINITION_PATH}" >&2
124+
exit 1
125+
fi
105126
fi
106127

107128
PREFIX_PATH="$2"

0 commit comments

Comments
 (0)