diff --git a/README.md b/README.md index d4df9e6b8..f9ced9753 100644 --- a/README.md +++ b/README.md @@ -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 +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. diff --git a/build-farm/platform-specific-configurations/linux.sh b/build-farm/platform-specific-configurations/linux.sh index 5125c9c09..5606ad73d 100755 --- a/build-farm/platform-specific-configurations/linux.sh +++ b/build-farm/platform-specific-configurations/linux.sh @@ -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 diff --git a/sbin/build.sh b/sbin/build.sh index cb27358e2..928e6d30e 100755 --- a/sbin/build.sh +++ b/sbin/build.sh @@ -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]}" @@ -536,6 +543,7 @@ configureZlibLocation() { configureCommandParameters() { configureVersionStringParameter configureBootJDKConfigureParameter + configureDevKitConfigureParameter configureShenandoahBuildParameter configureMacOSCodesignParameter configureDebugParameters diff --git a/sbin/common/config_init.sh b/sbin/common/config_init.sh index 3ee88244f..64cdd23d5 100755 --- a/sbin/common/config_init.sh +++ b/sbin/common/config_init.sh @@ -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 @@ -122,6 +123,7 @@ WORKSPACE_DIR # /config Configuration /openjdk/config $(pwd)/workspace/config # / Build area /openjdk/build $(pwd)/workspace/build/ # // Source code /openjdk/build/src $(pwd)/workspace/build/src +# //devkit DevKit download /openjdk/build/devkit $(pwd)/workspace/build/devkit # /target Destination of built artifacts /openjdk/target $(pwd)/workspace/target # Helper code to perform index lookups by name @@ -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;; @@ -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 diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 022a0b297..7eb462e53 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -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 @@ -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 @@ -695,6 +743,7 @@ function configureWorkspace() { if [[ "${BUILD_CONFIG[ASSEMBLE_EXPLODED_IMAGE]}" != "true" ]]; then createWorkspace downloadingRequiredDependencies + downloadDevkit relocateToTmpIfNeeded checkoutAndCloneOpenJDKGitRepo applyPatches