Skip to content

Commit

Permalink
Provide a temurin-build build arg --use-adoptium-devkit <devkit_tag> (#…
Browse files Browse the repository at this point in the history
…3706)

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Add new build arg option to specify an existing folder for openjdk build output

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Build using a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Reproducible jdk21u linux build fixes and updates for debug symbols

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Use a linux devkit

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

* Update sbin/prepareWorkspace.sh

Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com>

* Update sbin/prepareWorkspace.sh

Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com>

* Update README.md

Signed-off-by: Andrew Leonard <anleonar@redhat.com>

---------

Signed-off-by: Andrew Leonard <anleonar@redhat.com>
Co-authored-by: Martijn Verburg <martijnverburg@gmail.com>
Co-authored-by: Stewart X Addison <6487691+sxa@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 28, 2024
1 parent dd22c24 commit 4c6a46b
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 14 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ For reference, OpenJDK version numbers look like 1.8.0_162-b12 (for Java 8) or
(162) or the 3rd position in the semVer version string (4).
This is typically used in conjunction with -b.

--use-adoptium-devkit <Adoptium DevKit release tag>
Download and use the given DevKit from https://github.com/adoptium/devkit-binaries/releases.
The DevKit is downloaded and unpacked to WORKSPACE_DIR/WORKING_DIR/devkit
and will add the configure arg --with-devkit=WORKSPACE_DIR/WORKING_DIR/devkit.

--use-jep319-certs
Use certs defined in JEP319 in Java 8/9. Deprecated, has no effect.

Expand Down
2 changes: 2 additions & 0 deletions build-farm/platform-specific-configurations/linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,8 @@ fi

if [[ "${CONFIGURE_ARGS}" =~ .*"--with-devkit=".* ]]; then
echo "Using gcc from DevKit toolchain specified in configure args"
elif [[ "${BUILD_ARGS}" =~ .*"--use-adoptium-devkit".* ]]; then
echo "Using gcc from Adoptium DevKit toolchain specified in --use-adoptium-devkit build args"
else
if [ "${VARIANT}" == "${BUILD_VARIANT_DRAGONWELL}" ] && [ "$JAVA_FEATURE_VERSION" -eq 11 ] && [ -r /usr/local/gcc9/ ] && [ "${ARCHITECTURE}" == "aarch64" ]; then
# GCC9 rather than 10 requested by Alibaba for now
Expand Down
8 changes: 8 additions & 0 deletions sbin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ addConfigureArgIfValueIsNotEmpty() {
fi
}

# Configure the DevKit if required
configureDevKitConfigureParameter() {
if [[ -n "${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" ]]; then
addConfigureArg "--with-devkit=" "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit"
fi
}

# Configure the boot JDK
configureBootJDKConfigureParameter() {
addConfigureArgIfValueIsNotEmpty "--with-boot-jdk=" "${BUILD_CONFIG[JDK_BOOT_DIR]}"
Expand Down Expand Up @@ -536,6 +543,7 @@ configureZlibLocation() {
configureCommandParameters() {
configureVersionStringParameter
configureBootJDKConfigureParameter
configureDevKitConfigureParameter
configureShenandoahBuildParameter
configureMacOSCodesignParameter
configureDebugParameters
Expand Down
8 changes: 8 additions & 0 deletions sbin/common/config_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ TARGET_DIR
TARGET_FILE_NAME
TMP_CONTAINER_NAME
TMP_SPACE_BUILD
USE_ADOPTIUM_DEVKIT
USE_DOCKER
USE_JEP319_CERTS
USE_SSH
Expand All @@ -122,6 +123,7 @@ WORKSPACE_DIR
# <WORKSPACE_DIR>/config Configuration /openjdk/config $(pwd)/workspace/config
# <WORKSPACE_DIR>/<WORKING_DIR> Build area /openjdk/build $(pwd)/workspace/build/
# <WORKSPACE_DIR>/<WORKING_DIR>/<OPENJDK_SOURCE_DIR> Source code /openjdk/build/src $(pwd)/workspace/build/src
# <WORKSPACE_DIR>/<WORKING_DIR>/devkit DevKit download /openjdk/build/devkit $(pwd)/workspace/build/devkit
# <WORKSPACE_DIR>/target Destination of built artifacts /openjdk/target $(pwd)/workspace/target

# Helper code to perform index lookups by name
Expand Down Expand Up @@ -356,6 +358,9 @@ function parseConfigurationArguments() {
"--use-jep319-certs" )
BUILD_CONFIG[USE_JEP319_CERTS]=true;;

"--use-adoptium-devkit")
BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]="$1"; shift;;

"--user-openjdk-build-root-directory" )
BUILD_CONFIG[USER_OPENJDK_BUILD_ROOT_DIRECTORY]="$1"; shift;;

Expand Down Expand Up @@ -600,6 +605,9 @@ function configDefaults() {

BUILD_CONFIG[CLEAN_LIBS]=false

# Default to no Adoptium DevKit
BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]=""

# By default dont backport JEP318 certs to < Java 10
BUILD_CONFIG[USE_JEP319_CERTS]=false

Expand Down
77 changes: 63 additions & 14 deletions sbin/prepareWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,21 +330,8 @@ checkingAndDownloadingAlsa() {
curl -o "alsa-lib.tar.bz2" "$ALSA_BUILD_URL"
curl -o "alsa-lib.tar.bz2.sig" "https://www.alsa-project.org/files/pub/lib/alsa-lib-${ALSA_LIB_VERSION}.tar.bz2.sig"

## This affects riscv64 & Alpine docker images and also evaluation pipelines
if ( [ -r /etc/alpine-release ] && [ "$(pwd | wc -c)" -gt 83 ] ) || \
( [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "linux" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "riscv64" ] && [ "$(pwd | wc -c)" -gt 83 ] ); then
# Use /tmp in preference to $HOME as fails gpg operation if PWD > 83 characters
# Also cannot create ~/.gpg-temp within a docker context
GNUPGHOME="$(mktemp -d /tmp/.gpg-temp.XXXXXX)"
else
GNUPGHOME="${BUILD_CONFIG[WORKSPACE_DIR]:-$PWD}/.gpg-temp"
fi
if [ ! -d "$GNUPGHOME" ]; then
mkdir -m 700 "$GNUPGHOME"
fi
export GNUPGHOME
setupGpg

echo "GNUPGHOME=$GNUPGHOME"
# Should we clear this directory up after checking?
# Would this risk removing anyone's existing dir with that name?
# Erring on the side of caution for now
Expand Down Expand Up @@ -577,6 +564,67 @@ prepareMozillaCacerts() {
fi
}

# Create and setup GNUPGHOME
setupGpg() {
## This affects riscv64 & Alpine docker images and also evaluation pipelines
if ( [ -r /etc/alpine-release ] && [ "$(pwd | wc -c)" -gt 83 ] ) || \
( [ "${BUILD_CONFIG[OS_KERNEL_NAME]}" == "linux" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "riscv64" ] && [ "$(pwd | wc -c)" -gt 83 ] ); then
# Use /tmp in preference to $HOME as fails gpg operation if PWD > 83 characters
# Also cannot create ~/.gpg-temp within a docker context
GNUPGHOME="$(mktemp -d /tmp/.gpg-temp.XXXXXX)"
else
GNUPGHOME="${BUILD_CONFIG[WORKSPACE_DIR]:-$PWD}/.gpg-temp"
fi
if [ ! -d "$GNUPGHOME" ]; then
mkdir -m 700 "$GNUPGHOME"
fi
export GNUPGHOME

echo "GNUPGHOME=$GNUPGHOME"
}

# Download the required DevKit if necessary
downloadDevkit() {
if [[ -n "${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" ]]; then
rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit"
mkdir -p "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit"

local devkit_tar="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit/devkit.tar.xz"

setupGpg

# Determine DevKit tarball to download for this arch and release
local devkitUrl="https://github.com/adoptium/devkit-binaries/releases/download/${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}"
local devkit_target="${BUILD_CONFIG[OS_ARCHITECTURE]}-linux-gnu"
local devkit="devkit-${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}-${devkit_target}"

# Download tarball and GPG sig
echo "Downloading DevKit : ${devkitUrl}/${devkit}.tar.xz"
curl -L --fail --silent --show-error -o "${devkit_tar}" "${devkitUrl}/${devkit}.tar.xz"
curl -L --fail --silent --show-error -o "${devkit_tar}.sig" "${devkitUrl}/${devkit}.tar.xz.sig"

# GPG verify
gpg --keyserver keyserver.ubuntu.com --recv-keys 3B04D753C9050D9A5D343F39843C48A565F8F04B
echo -e "5\ny\n" | gpg --batch --command-fd 0 --expert --edit-key 3B04D753C9050D9A5D343F39843C48A565F8F04B trust;
gpg --verify "${devkit_tar}.sig" "${devkit_tar}" || exit 1

tar xpJf "${devkit_tar}" -C "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit"
rm "${devkit_tar}"
rm "${devkit_tar}.sig"

# Validate devkit.info matches value passed in and current architecture
local devkitInfo="${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/devkit/devkit.info"
if ! grep "ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}" "${devkitInfo}" || ! grep "ADOPTIUM_DEVKIT_TARGET=${devkit_target}" "${devkitInfo}"; then
echo "ERROR: Devkit does not match required release and architecture:"
echo " Required: ADOPTIUM_DEVKIT_RELEASE=${BUILD_CONFIG[USE_ADOPTIUM_DEVKIT]}"
echo " Downloaded: $(grep ADOPTIUM_DEVKIT_RELEASE= "${devkitInfo}")"
echo " Required: ADOPTIUM_DEVKIT_TARGET=${devkit_target}"
echo " Downloaded: $(grep ADOPTIUM_DEVKIT_TARGET= "${devkitInfo}")"
exit 1
fi
fi
}

# Download all of the dependencies for OpenJDK (Alsa, FreeType etc.)
downloadingRequiredDependencies() {
if [[ "${BUILD_CONFIG[CLEAN_LIBS]}" == "true" ]]; then
Expand Down Expand Up @@ -695,6 +743,7 @@ function configureWorkspace() {
if [[ "${BUILD_CONFIG[ASSEMBLE_EXPLODED_IMAGE]}" != "true" ]]; then
createWorkspace
downloadingRequiredDependencies
downloadDevkit
relocateToTmpIfNeeded
checkoutAndCloneOpenJDKGitRepo
applyPatches
Expand Down

0 comments on commit 4c6a46b

Please sign in to comment.