Autodetect JAVA_HOME on RPM-based systems

Author: Matthew Farrellee <matt@redhat.com>

Closes #1185 from mattf/master-1 and squashes the following commits:

42150fc [Matthew Farrellee] Autodetect JAVA_HOME on RPM-based systems
This commit is contained in:
Matthew Farrellee 2014-06-24 19:31:20 -07:00 committed by Patrick Wendell
parent 133495d826
commit 54055fb2b7

View file

@ -84,6 +84,17 @@ while (( "$#" )); do
shift
done
if [ -z "$JAVA_HOME" ]; then
# Fall back on JAVA_HOME from rpm, if found
if which rpm &>/dev/null; then
RPM_JAVA_HOME=$(rpm -E %java_home 2>/dev/null)
if [ "$RPM_JAVA_HOME" != "%java_home" ]; then
JAVA_HOME=$RPM_JAVA_HOME
echo "No JAVA_HOME set, proceeding with '$JAVA_HOME' learned from rpm"
fi
fi
fi
if [ -z "$JAVA_HOME" ]; then
echo "Error: JAVA_HOME is not set, cannot proceed."
exit -1