Files
impala/bin/bootstrap_build.sh
Michael Smith d217b9ecc6 IMPALA-14450: Simplify Java version selection
Removes IMPALA_JAVA_HOME_OVERRIDE and updates version selection. In
order of priority
1. If IMPALA_JDK_VERSION is set, use the OS JDK version from a known
   location. This is primarily used when also installing the JDK as part
   of automated builds.
2. If JAVA_HOME is set, use it.
3. Look for the system default JDK.

The IMPALA_JDK_VERSION variable is no longer modified to avoid issues
when sourcing impala-config.sh multiple times. JAVA_HOME will be
modified if IMPALA_JDK_VERSION is set; both must be unset to restore
using the system default Java.

If switching between JDKs, now prefer setting JAVA_HOME. If relying on
system Java, unset JAVA_HOME after e.g. update-java-alternatives.

The detected Java version is set in IMPALA_JAVA_TARGET, which is used to
add Java 9+ options and configure the Java compilation target.

Eliminates IMPALA_JDK_VERSION_NUM as it's value was always identical to
IMPALA_JAVA_TARGET.

Stops printing from impala-config-java.sh. It made the output from
impala-config.sh look strange, and the decisions can all be clearly
determined from impala-config.sh printed variables later or the packages
installed in bootstrap_system.sh.

Fixes JAVA_HOME in bootstrap_build.sh on ARM64 systems.

Change-Id: I68435ca69522f8310221a0f3050f13d86568b9da
Reviewed-on: http://gerrit.cloudera.org:8080/23434
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2025-09-19 01:51:47 +00:00

94 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# This script builds Impala from scratch. It is known to work on Ubuntu versions 16.04,
# 18.04, 20.04, 22.04 and 24.04. To run it you need to have:
#
# 1. At least 8GB of free disk space
# 4. A connection to the internet (parts of the build download dependencies)
#
# To bootstrap a more complete development environment that includes not only building
# Impala but also running and testing it, see bootstrap_development.sh in this directory.
# Set up some logging and exit conditions:
set -euxo pipefail
# Install non-java dependencies:
# Kerberos setup would pop up dialog boxes without this
export DEBIAN_FRONTEND=noninteractive
sudo -E apt-get --quiet update
# unversioned python-dev and python-setuptools are not available on newer releases
# that don't support Python 2. Add them only when they exist for the platform,
# otherwise set Python 3 to be the default Python version.
PACKAGES='g++ gcc git libsasl2-dev libssl-dev make
python3-dev python3-setuptools python3-venv libffi-dev language-pack-en
libkrb5-dev krb5-admin-server krb5-kdc krb5-user libxml2-dev libxslt-dev wget'
if sudo apt-get --quiet install -s python-dev python-setuptools > /dev/null 2>&1; then
PACKAGES="${PACKAGES} python-dev python-setuptools"
else
PACKAGES="${PACKAGES} python-is-python3 python-dev-is-python3"
fi
sudo -E apt-get --yes --quiet install ${PACKAGES}
source /etc/lsb-release
# Ubuntu 20's Python 2.7.18-1~20.04.5 version has a bug in its tarfile support.
# If we detect the affected tarfile.py, download a patched version and overwrite it.
if [[ $DISTRIB_ID == Ubuntu && $DISTRIB_RELEASE == 20.04 ]]; then
if [[ -f /usr/lib/python2.7/tarfile.py ]]; then
TARFILE_PY_HASH=$(sha1sum /usr/lib/python2.7/tarfile.py | cut -d' ' -f1)
if [[ "${TARFILE_PY_HASH}" == "6e1a6d9ea2a535cbb17fe266ed9ac76eb5e27b89" ]]; then
TMP_DIR=$(mktemp -d)
pushd $TMP_DIR
wget -nv https://launchpadlibrarian.net/759546541/tarfile.py
sudo cp tarfile.py /usr/lib/python2.7/tarfile.py
popd
rm -rf $TMP_DIR
fi
fi
fi
JDK_VERSION=17
if [[ "$(uname -p)" == 'aarch64' ]]; then
PACKAGE_ARCH='arm64'
else
PACKAGE_ARCH='amd64'
fi
sudo apt-get --yes --quiet install openjdk-${JDK_VERSION}-jdk openjdk-${JDK_VERSION}-source
export JAVA_HOME=/usr/lib/jvm/java-${JDK_VERSION}-openjdk-${PACKAGE_ARCH}
# Download Maven since the packaged version is pretty old.
: ${IMPALA_TOOLCHAIN_HOST:=native-toolchain.s3.amazonaws.com}
MVN_VERSION="3.9.8"
if [ ! -d "/usr/local/apache-maven-${MVN_VERSION}" ]; then
sudo wget -nv \
"https://${IMPALA_TOOLCHAIN_HOST}/maven/apache-maven-${MVN_VERSION}-bin.tar.gz"
sha512sum -c - <<< "7d171def9b85846bf757a2cec94b7529371068a0670df14682447224e57983528e97a6d1b850327e4ca02b139abaab7fcb93c4315119e6f0ffb3f0cbc0d0b9a2 apache-maven-${MVN_VERSION}-bin.tar.gz"
sudo tar -C /usr/local -xzf apache-maven-${MVN_VERSION}-bin.tar.gz
sudo ln -s /usr/local/apache-maven-${MVN_VERSION}/bin/mvn /usr/local/bin
fi
# Try to prepopulate the m2 directory to save time
if ! bin/jenkins/populate_m2_directory.py ; then
echo "Failed to prepopulate the m2 directory. Continuing..."
fi
./buildall.sh -notests -so