Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure it is safe to remove the prefix path for TruffleRuby or error #1784

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions bin/ruby-build
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,15 @@ fix_jruby_shebangs() {
}

build_package_truffleruby() {
clean_prefix_path_truffleruby || return $?
build_package_copy

cd "${PREFIX_PATH}"
"${PREFIX_PATH}/lib/truffle/post_install_hook.sh"
}

build_package_truffleruby_graalvm() {
clean_prefix_path
clean_prefix_path_truffleruby || return $?
build_package_copy_to "${PREFIX_PATH}/graalvm"

cd "${PREFIX_PATH}/graalvm"
Expand Down Expand Up @@ -792,7 +793,15 @@ remove_windows_files() {
rm -f bin/*.exe bin/*.dll bin/*.bat bin/jruby.sh
}

clean_prefix_path() {
clean_prefix_path_truffleruby() {
if [ -d "$PREFIX_PATH" ] && [ ! -e "$PREFIX_PATH/bin/truffleruby" ]; then
echo
echo "ERROR: cannot install TruffleRuby to $PREFIX_PATH, which does not look like a valid TruffleRuby prefix" >&2
echo "TruffleRuby only supports being installed to a not existing directory or replacing an existing TruffleRuby installation"
echo "See https://github.com/oracle/truffleruby/issues/1389 for details" >&2
return 1
fi

# Make sure there are no leftover files in $PREFIX_PATH
rm -rf "$PREFIX_PATH"
}
Expand All @@ -804,7 +813,6 @@ build_package_copy_to() {
}

build_package_copy() {
clean_prefix_path
build_package_copy_to "$PREFIX_PATH"
}

Expand Down
1 change: 1 addition & 0 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ DEF
}

@test "TruffleRuby post-install hook" {
rmdir "$INSTALL_ROOT"
executable "${RUBY_BUILD_CACHE_PATH}/truffleruby-test/lib/truffle/post_install_hook.sh" <<OUT
echo Running post-install hook
OUT
Expand Down