From a392a92c7885eafe1a62ce909110eed2816cf956 Mon Sep 17 00:00:00 2001 From: Jiri Date: Sat, 23 Mar 2024 12:09:56 +0100 Subject: [PATCH 01/14] Added feature to download boot jdk on demand currenlty only dne for linux, shoudl be easy to extend for windows, not sure what whith other platfroms. Is done via magic parameter of `download` for -J: -J download --- .../downloaders.sh | 84 +++++++++++++++++++ .../platform-specific-configurations/linux.sh | 64 +------------- makejdk-any-platform.1 | 4 +- sbin/prepareWorkspace.sh | 21 ++++- 4 files changed, 108 insertions(+), 65 deletions(-) create mode 100755 build-farm/platform-specific-configurations/downloaders.sh diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh new file mode 100755 index 000000000..2b29e4fa8 --- /dev/null +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# shellcheck disable=SC1091 + +################################################################################ +# Licensed 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 +# +# https://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. +################################################################################ + +DOWLOADERS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# this one should be swithing per (supported) oses in future +function downloadBootJDK() { + downloadLinuxBootJDK "$@" +} + +function downloadLinuxBootJDK() { + ARCH=$1 + VER=$2 + export downloadArch + case "$ARCH" in + "riscv64") downloadArch="$NATIVE_API_ARCH";; + *) downloadArch="$ARCH";; + esac + releaseType="ga" + vendor="eclipse" + apiUrlTemplate="https://api.adoptium.net/v3/binary/latest/\${VER}/\${releaseType}/linux/\${downloadArch}/jdk/hotspot/normal/\${vendor}" + apiURL=$(eval echo "${apiUrlTemplate}") + echo "Downloading GA release of boot JDK version ${VER} from ${apiURL}" + # make-adopt-build-farm.sh has 'set -e'. We need to disable that for + # the fallback mechanism, as downloading of the GA binary might fail. + set +e + curl -L -o bootjdk.tar.gz "${apiURL}" + apiSigURL=$(curl -v "${apiURL}" 2>&1 | tr -d \\r | awk '/^< Location:/{print $3 ".sig"}') + if ! grep "No releases match the request" bootjdk.tar.gz; then + curl -L -o bootjdk.tar.gz.sig "${apiSigURL}" + 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 + mkdir "$bootDir" + tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" + set -e + else + # We must be a JDK HEAD build for which no boot JDK exists other than + # nightlies? + echo "Downloading GA release of boot JDK version ${VER} failed." + # shellcheck disable=SC2034 + releaseType="ea" + # shellcheck disable=SC2034 + vendor="adoptium" + apiURL=$(eval echo ${apiUrlTemplate}) + echo "Attempting to download EA release of boot JDK version ${VER} from ${apiURL}" + set +e + curl -L -o bootjdk.tar.gz "${apiURL}" + if ! grep "No releases match the request" bootjdk.tar.gz; then + apiSigURL=$(curl -v "${apiURL}" 2>&1 | tr -d \\r | awk '/^< Location:/{print $3 ".sig"}') + curl -L -o bootjdk.tar.gz.sig "${apiSigURL}" + 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 + mkdir "$bootDir" + tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" + else + # If no binaries are available then try from adoptopenjdk + echo "Downloading Temurin release of boot JDK version ${VER} failed." + # shellcheck disable=SC2034 + releaseType="ga" + # shellcheck disable=SC2034 + vendor="adoptium" + apiURL=$(eval echo ${apiUrlTemplate}) + echo "Attempting to download GA release of boot JDK version ${VER} from ${apiURL}" + curl -L "${apiURL}" | tar xpzf - --strip-components=1 -C "$bootDir" + fi + fi +} + diff --git a/build-farm/platform-specific-configurations/linux.sh b/build-farm/platform-specific-configurations/linux.sh index dca182588..9264fa598 100755 --- a/build-farm/platform-specific-configurations/linux.sh +++ b/build-farm/platform-specific-configurations/linux.sh @@ -16,6 +16,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # shellcheck source=sbin/common/constants.sh source "$SCRIPT_DIR/../../sbin/common/constants.sh" +source "$SCRIPT_DIR/downloaders.sh" if [[ "$JAVA_FEATURE_VERSION" -ge 21 ]]; then # jdk-21+ uses "bundled" FreeType @@ -143,67 +144,6 @@ function setCrossCompilerEnvironment() fi } -function downloadBootJDK() -{ - ARCH=$1 - VER=$2 - export downloadArch - case "$ARCH" in - "riscv64") downloadArch="$NATIVE_API_ARCH";; - *) downloadArch="$ARCH";; - esac - releaseType="ga" - vendor="eclipse" - apiUrlTemplate="https://api.adoptium.net/v3/binary/latest/\${VER}/\${releaseType}/linux/\${downloadArch}/jdk/hotspot/normal/\${vendor}" - apiURL=$(eval echo "${apiUrlTemplate}") - echo "Downloading GA release of boot JDK version ${VER} from ${apiURL}" - # make-adopt-build-farm.sh has 'set -e'. We need to disable that for - # the fallback mechanism, as downloading of the GA binary might fail. - set +e - curl -L -o bootjdk.tar.gz "${apiURL}" - apiSigURL=$(curl -v "${apiURL}" 2>&1 | tr -d \\r | awk '/^< Location:/{print $3 ".sig"}') - if ! grep "No releases match the request" bootjdk.tar.gz; then - curl -L -o bootjdk.tar.gz.sig "${apiSigURL}" - 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 - mkdir "$bootDir" - tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" - set -e - else - # We must be a JDK HEAD build for which no boot JDK exists other than - # nightlies? - echo "Downloading GA release of boot JDK version ${VER} failed." - # shellcheck disable=SC2034 - releaseType="ea" - # shellcheck disable=SC2034 - vendor="adoptium" - apiURL=$(eval echo ${apiUrlTemplate}) - echo "Attempting to download EA release of boot JDK version ${VER} from ${apiURL}" - set +e - curl -L -o bootjdk.tar.gz "${apiURL}" - if ! grep "No releases match the request" bootjdk.tar.gz; then - apiSigURL=$(curl -v "${apiURL}" 2>&1 | tr -d \\r | awk '/^< Location:/{print $3 ".sig"}') - curl -L -o bootjdk.tar.gz.sig "${apiSigURL}" - 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 - mkdir "$bootDir" - tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" - else - # If no binaries are available then try from adoptopenjdk - echo "Downloading Temurin release of boot JDK version ${VER} failed." - # shellcheck disable=SC2034 - releaseType="ga" - # shellcheck disable=SC2034 - vendor="adoptium" - apiURL=$(eval echo ${apiUrlTemplate}) - echo "Attempting to download GA release of boot JDK version ${VER} from ${apiURL}" - curl -L "${apiURL}" | tar xpzf - --strip-components=1 -C "$bootDir" - fi - fi -} - if [ "${ARCHITECTURE}" == "x64" ] then export PATH=/opt/rh/devtoolset-2/root/usr/bin:$PATH @@ -314,7 +254,7 @@ if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then # shellcheck disable=SC2140 export "${BOOT_JDK_VARIABLE}"="/usr/lib/jvm/jdk-${JDK_BOOT_VERSION}" elif [ "$JDK_BOOT_VERSION" -ge 8 ]; then # Adoptium has no build pre-8 - downloadBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" + downloadLinuxBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" fi fi fi diff --git a/makejdk-any-platform.1 b/makejdk-any-platform.1 index f52f95f31..bdf8dfd23 100755 --- a/makejdk-any-platform.1 +++ b/makejdk-any-platform.1 @@ -117,7 +117,9 @@ ignore the existing docker container if you have one already. specify the JDK boot dir. For reference, OpenJDK needs the previous version of a JDK in order to build itself. You should select the path to a JDK install that is N-1 versions below -the one you are trying to build. +the one you are trying to build. On some platforms, you can use magic keyword +of `download`, and boot jdk will be downloaded for you in best attempt. It will +be reused as long as you keep workspace or clean libs. .TP .BR \-k ", " \-\-keep if using docker, keep the container after the build. diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index edc3a4e5f..9d72f9091 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -623,15 +623,32 @@ downloadDevkit() { fi } -# Download all of the dependencies for OpenJDK (Alsa, FreeType etc.) +downloadBootJdkIfNeeded () { + if [[ "${BUILD_CONFIG[JDK_BOOT_DIR]}" == "download" ]]; then + # the bootDir is used by refactored downloaders.sh methods; it would benice to change in future + bootDir="${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" + if [ -e "$bootDir" ] ; then + echo "Reusing $bootDir" + else + source "$SCRIPT_DIR/../build-farm/platform-specific-configurations/downloaders.sh" + echo "Downloading to $bootDir" + downloadBootJDK $(uname -m) ${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]} + fi + BUILD_CONFIG[JDK_BOOT_DIR]="${bootDir}" + fi +} + +# Download all of the dependencies for OpenJDK (Alsa, FreeType, boot-jdk etc.) downloadingRequiredDependencies() { if [[ "${BUILD_CONFIG[CLEAN_LIBS]}" == "true" ]]; then rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/freetype" || true - rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedalsa" || true rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/${BUILD_CONFIG[WORKING_DIR]}/installedfreetype" || true + rm -rf "${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" || true fi + downloadBootJdkIfNeeded + mkdir -p "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/" || exit cd "${BUILD_CONFIG[WORKSPACE_DIR]}/libs/" || exit From 2747543ae43b6bb4f4128cf82d79c803c9310f20 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Mon, 25 Mar 2024 18:22:55 +0100 Subject: [PATCH 02/14] removed unused variabble --- build-farm/platform-specific-configurations/downloaders.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 2b29e4fa8..c16ac46ff 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -15,8 +15,6 @@ # limitations under the License. ################################################################################ -DOWLOADERS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - # this one should be swithing per (supported) oses in future function downloadBootJDK() { downloadLinuxBootJDK "$@" From 6e6bbad8f80e58115383981ab7ad508040516fa2 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Tue, 26 Mar 2024 16:40:12 +0100 Subject: [PATCH 03/14] Refactor also for windows --- .../downloaders.sh | 62 ++++++++++++++++++- .../windows.sh | 51 +-------------- 2 files changed, 63 insertions(+), 50 deletions(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index c16ac46ff..160b15538 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -17,7 +17,14 @@ # this one should be swithing per (supported) oses in future function downloadBootJDK() { - downloadLinuxBootJDK "$@" + if uname -o | grep -i -e Linux ; then + downloadLinuxBootJDK "$@" + elif uname -o | grep -i -e Cygwin -e Windows ; then + downloadWindowsBootJDK "$@" + else + echo "Unsupported platfrom for direct download of boot jdk: `uname -m` `uname -o`" + exit 1 + fi } function downloadLinuxBootJDK() { @@ -80,3 +87,56 @@ function downloadLinuxBootJDK() { fi } +function downloadWindowsBootJDK() { + ARCHITECTURE="${1}" + VER=${2} + # This is needed to convert x86-32 to x32 which is what the API uses + export downloadArch + case "$ARCHITECTURE" in + "x86-32") downloadArch="x32";; + "aarch64") downloadArch="x64";; + *) downloadArch="$ARCHITECTURE";; + esac + releaseType="ga" + vendor="eclipse" + api="adoptium" + apiUrlTemplate="https://api.\${api}.net/v3/binary/latest/\${VER}/\${releaseType}/windows/\${downloadArch}/jdk/hotspot/normal/\${vendor}" + apiURL=$(eval echo ${apiUrlTemplate}) + echo "Downloading GA release of boot JDK version ${VER} from ${apiURL}" + # make-adopt-build-farm.sh has 'set -e'. We need to disable that for + # the fallback mechanism, as downloading of the GA binary might fail + set +e + wget -q "${apiURL}" -O openjdk.zip + retVal=$? + set -e + if [ $retVal -ne 0 ]; then + # We must be a JDK HEAD build for which no boot JDK exists other than + # nightlies? + echo "Downloading GA release of boot JDK version ${VER} failed." + # shellcheck disable=SC2034 + releaseType="ea" + # shellcheck disable=SC2034 + vendor="adoptium" + apiURL=$(eval echo ${apiUrlTemplate}) + echo "Attempting to download EA release of boot JDK version ${VER} from ${apiURL}" + set +e + wget -q "${apiURL}" -O openjdk.zip + retVal=$? + set -e + if [ $retVal -ne 0 ]; then + # If no binaries are available then try from adoptopenjdk + echo "Downloading Temurin release of boot JDK version ${VER} failed." + # shellcheck disable=SC2034 + releaseType="ga" + # shellcheck disable=SC2034 + vendor="adoptopenjdk" + # shellcheck disable=SC2034 + api="adoptopenjdk" + apiURL=$(eval echo ${apiUrlTemplate}) + echo "Attempting to download GA release of boot JDK version ${VER} from ${apiURL}" + wget -q "${apiURL}" -O openjdk.zip + fi + fi + unzip -q openjdk.zip + mv "$(ls -d jdk-"${VER}"*)" "$bootDir" +} diff --git a/build-farm/platform-specific-configurations/windows.sh b/build-farm/platform-specific-configurations/windows.sh index f91daaec8..a3abc1530 100755 --- a/build-farm/platform-specific-configurations/windows.sh +++ b/build-farm/platform-specific-configurations/windows.sh @@ -16,6 +16,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # shellcheck source=sbin/common/constants.sh source "$SCRIPT_DIR/../../sbin/common/constants.sh" +source "$SCRIPT_DIR/downloaders.sh" export ANT_HOME=/cygdrive/C/Projects/OpenJDK/apache-ant-1.10.1 export DRAGONWELL8_BOOTSTRAP=/cygdrive/C/openjdk/dragonwell-bootstrap/jdk8u272-ga @@ -43,55 +44,7 @@ if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then # shellcheck disable=SC2140 export "${BOOT_JDK_VARIABLE}"="/cygdrive/c/openjdk/jdk-${JDK_BOOT_VERSION}" elif [ "$JDK_BOOT_VERSION" -ge 8 ]; then # Adoptium has no build pre-8 - # This is needed to convert x86-32 to x32 which is what the API uses - export downloadArch - case "$ARCHITECTURE" in - "x86-32") downloadArch="x32";; - "aarch64") downloadArch="x64";; - *) downloadArch="$ARCHITECTURE";; - esac - releaseType="ga" - vendor="eclipse" - api="adoptium" - apiUrlTemplate="https://api.\${api}.net/v3/binary/latest/\${JDK_BOOT_VERSION}/\${releaseType}/windows/\${downloadArch}/jdk/hotspot/normal/\${vendor}" - apiURL=$(eval echo ${apiUrlTemplate}) - echo "Downloading GA release of boot JDK version ${JDK_BOOT_VERSION} from ${apiURL}" - # make-adopt-build-farm.sh has 'set -e'. We need to disable that for - # the fallback mechanism, as downloading of the GA binary might fail - set +e - wget -q "${apiURL}" -O openjdk.zip - retVal=$? - set -e - if [ $retVal -ne 0 ]; then - # We must be a JDK HEAD build for which no boot JDK exists other than - # nightlies? - echo "Downloading GA release of boot JDK version ${JDK_BOOT_VERSION} failed." - # shellcheck disable=SC2034 - releaseType="ea" - # shellcheck disable=SC2034 - vendor="adoptium" - apiURL=$(eval echo ${apiUrlTemplate}) - echo "Attempting to download EA release of boot JDK version ${JDK_BOOT_VERSION} from ${apiURL}" - set +e - wget -q "${apiURL}" -O openjdk.zip - retVal=$? - set -e - if [ $retVal -ne 0 ]; then - # If no binaries are available then try from adoptopenjdk - echo "Downloading Temurin release of boot JDK version ${JDK_BOOT_VERSION} failed." - # shellcheck disable=SC2034 - releaseType="ga" - # shellcheck disable=SC2034 - vendor="adoptopenjdk" - # shellcheck disable=SC2034 - api="adoptopenjdk" - apiURL=$(eval echo ${apiUrlTemplate}) - echo "Attempting to download GA release of boot JDK version ${JDK_BOOT_VERSION} from ${apiURL}" - wget -q "${apiURL}" -O openjdk.zip - fi - fi - unzip -q openjdk.zip - mv "$(ls -d jdk-"${JDK_BOOT_VERSION}"*)" "$bootDir" + downloadWindowsBootJDK ${ARCHITECTURE} ${JDK_BOOT_VERSION} fi fi fi From a60a4f71b217b79cc8f36fe651a0c87771c14d1d Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Tue, 26 Mar 2024 17:05:59 +0100 Subject: [PATCH 04/14] Changed mask for finding the jdk dir It seems that the directory was changed in recent times from jdk-8... to jdk8... --- build-farm/platform-specific-configurations/downloaders.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 160b15538..beb9e4daa 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -138,5 +138,5 @@ function downloadWindowsBootJDK() { fi fi unzip -q openjdk.zip - mv "$(ls -d jdk-"${VER}"*)" "$bootDir" + mv "$(ls -d jdk*"${VER}"*)" "$bootDir" } From cb770b303f32d9ea2109fd3a649afce194c66f18 Mon Sep 17 00:00:00 2001 From: Jiri Vanek Date: Wed, 27 Mar 2024 17:35:52 +0100 Subject: [PATCH 05/14] Added small readme to the downloader.sh --- build-farm/platform-specific-configurations/downloaders.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index beb9e4daa..508789a36 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -15,6 +15,11 @@ # limitations under the License. ################################################################################ +#################################################################################### +# This file is gathering all download boot jdk functions, so they can b reused later +# On long run, the methods - due theirs simialrity - should converge to one +#################################################################################### + # this one should be swithing per (supported) oses in future function downloadBootJDK() { if uname -o | grep -i -e Linux ; then From 92b5dcb68e53190c270868ca5ae4eb65d968958d Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 1 Apr 2024 15:34:15 +0200 Subject: [PATCH 06/14] More quoting to make bash lint happy --- build-farm/platform-specific-configurations/downloaders.sh | 2 +- build-farm/platform-specific-configurations/windows.sh | 2 +- sbin/prepareWorkspace.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 508789a36..97a64949d 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -27,7 +27,7 @@ function downloadBootJDK() { elif uname -o | grep -i -e Cygwin -e Windows ; then downloadWindowsBootJDK "$@" else - echo "Unsupported platfrom for direct download of boot jdk: `uname -m` `uname -o`" + echo "Unsupported platfrom for direct download of boot jdk: $(uname -m) $(uname -o)" exit 1 fi } diff --git a/build-farm/platform-specific-configurations/windows.sh b/build-farm/platform-specific-configurations/windows.sh index a3abc1530..3f449315d 100755 --- a/build-farm/platform-specific-configurations/windows.sh +++ b/build-farm/platform-specific-configurations/windows.sh @@ -44,7 +44,7 @@ if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then # shellcheck disable=SC2140 export "${BOOT_JDK_VARIABLE}"="/cygdrive/c/openjdk/jdk-${JDK_BOOT_VERSION}" elif [ "$JDK_BOOT_VERSION" -ge 8 ]; then # Adoptium has no build pre-8 - downloadWindowsBootJDK ${ARCHITECTURE} ${JDK_BOOT_VERSION} + downloadWindowsBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" fi fi fi diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 9d72f9091..613a85096 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -632,7 +632,7 @@ downloadBootJdkIfNeeded () { else source "$SCRIPT_DIR/../build-farm/platform-specific-configurations/downloaders.sh" echo "Downloading to $bootDir" - downloadBootJDK $(uname -m) ${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]} + downloadBootJDK "$(uname -m)" "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" fi BUILD_CONFIG[JDK_BOOT_DIR]="${bootDir}" fi From 280a8ebb3375e3ec97adf3b625dc547354116667 Mon Sep 17 00:00:00 2001 From: judovana Date: Mon, 1 Apr 2024 15:35:19 +0200 Subject: [PATCH 07/14] Update sbin/prepareWorkspace.sh Co-authored-by: Martijn Verburg --- sbin/prepareWorkspace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 613a85096..c79b4ec30 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -625,7 +625,7 @@ downloadDevkit() { downloadBootJdkIfNeeded () { if [[ "${BUILD_CONFIG[JDK_BOOT_DIR]}" == "download" ]]; then - # the bootDir is used by refactored downloaders.sh methods; it would benice to change in future + # The bootDir is used by downloaders.sh methods; it would be nice to change in future bootDir="${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" if [ -e "$bootDir" ] ; then echo "Reusing $bootDir" From 58fc2f94b601a5e42810f04771c040b3518aa669 Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 1 Apr 2024 15:37:06 +0200 Subject: [PATCH 08/14] Finished wording of comment about downloaders.sh --- sbin/prepareWorkspace.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index c79b4ec30..c22a96d54 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -625,7 +625,7 @@ downloadDevkit() { downloadBootJdkIfNeeded () { if [[ "${BUILD_CONFIG[JDK_BOOT_DIR]}" == "download" ]]; then - # The bootDir is used by downloaders.sh methods; it would be nice to change in future + # The bootDir is used by downloaders.sh methods; it would be nice to change it in future so the download method is unified bootDir="${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" if [ -e "$bootDir" ] ; then echo "Reusing $bootDir" From 6c57490a8e36bab354d6fd314fc332732f6bad8b Mon Sep 17 00:00:00 2001 From: Jiri Date: Mon, 1 Apr 2024 15:42:32 +0200 Subject: [PATCH 09/14] Mentioned download on -J/--jdk-boot-dir man line --- makejdk-any-platform.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makejdk-any-platform.1 b/makejdk-any-platform.1 index bdf8dfd23..7a4e0673e 100755 --- a/makejdk-any-platform.1 +++ b/makejdk-any-platform.1 @@ -113,7 +113,7 @@ print this help. .BR \-i ", " \-\-ignore-container ignore the existing docker container if you have one already. .TP -.BR \-J ", " \-\-jdk-boot-dir " " \fI\fR +.BR \-J ", " \-\-jdk-boot-dir " " \fI\fR "; " \-J ", " \-\-jdk-boot-dir " " \fIdownload\fR specify the JDK boot dir. For reference, OpenJDK needs the previous version of a JDK in order to build itself. You should select the path to a JDK install that is N-1 versions below From 10bc5b5b32e121f03e3fd773d9cadb395b98a896 Mon Sep 17 00:00:00 2001 From: judovana Date: Mon, 1 Apr 2024 15:44:13 +0200 Subject: [PATCH 10/14] Update build-farm/platform-specific-configurations/downloaders.sh Co-authored-by: Martijn Verburg --- build-farm/platform-specific-configurations/downloaders.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 97a64949d..3240baefd 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -20,7 +20,7 @@ # On long run, the methods - due theirs simialrity - should converge to one #################################################################################### -# this one should be swithing per (supported) oses in future +# This function switches logic based on the (supported) os function downloadBootJDK() { if uname -o | grep -i -e Linux ; then downloadLinuxBootJDK "$@" From 661f1bcbd26e96b356315e7e64b4823f7052ac2f Mon Sep 17 00:00:00 2001 From: Jiri Date: Wed, 3 Apr 2024 12:44:04 +0200 Subject: [PATCH 11/14] relying on $bootDir being set - shellcheck disable=SC2154 --- .../platform-specific-configurations/downloaders.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 3240baefd..457226874 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -17,10 +17,11 @@ #################################################################################### # This file is gathering all download boot jdk functions, so they can b reused later -# On long run, the methods - due theirs simialrity - should converge to one +# On long run, the methods - due theirs similarity - should converge to one #################################################################################### # This function switches logic based on the (supported) os +# It is currently relying on $bootDir being set. This should be fixed later function downloadBootJDK() { if uname -o | grep -i -e Linux ; then downloadLinuxBootJDK "$@" @@ -55,7 +56,9 @@ function downloadLinuxBootJDK() { 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 + # shellcheck disable=SC2154 mkdir "$bootDir" + # shellcheck disable=SC2154 tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" set -e else @@ -76,7 +79,9 @@ function downloadLinuxBootJDK() { 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 + # shellcheck disable=SC2154 mkdir "$bootDir" + # shellcheck disable=SC2154 tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" else # If no binaries are available then try from adoptopenjdk @@ -143,5 +148,6 @@ function downloadWindowsBootJDK() { fi fi unzip -q openjdk.zip + # shellcheck disable=SC2154 mv "$(ls -d jdk*"${VER}"*)" "$bootDir" } From 763c02b25a5d2c4e904559b30ed109fa62f9df58 Mon Sep 17 00:00:00 2001 From: Jiri Date: Wed, 3 Apr 2024 16:16:26 +0200 Subject: [PATCH 12/14] Fixed coyrigth header --- .../downloaders.sh | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 457226874..15f432059 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -1,19 +1,18 @@ #!/bin/bash # shellcheck disable=SC1091 -################################################################################ -# Licensed 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 +# ******************************************************************************** +# Copyright (c) 2018 Contributors to the Eclipse Foundation # -# https://www.apache.org/licenses/LICENSE-2.0 +# See the NOTICE file(s) with this work for additional +# information regarding copyright ownership. # -# 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 program and the accompanying materials are made +# available under the terms of the Apache Software License 2.0 +# which is available at https://www.apache.org/licenses/LICENSE-2.0. +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************** #################################################################################### # This file is gathering all download boot jdk functions, so they can b reused later From 00b599c20d3fee1e035a3f23b1f497b51eb2ebcb Mon Sep 17 00:00:00 2001 From: Jiri Date: Wed, 3 Apr 2024 16:29:17 +0200 Subject: [PATCH 13/14] No longer using global bootDir --- .../downloaders.sh | 18 +++++++----------- .../platform-specific-configurations/linux.sh | 2 +- .../windows.sh | 2 +- sbin/prepareWorkspace.sh | 13 ++++++------- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/build-farm/platform-specific-configurations/downloaders.sh index 15f432059..e1203e54d 100755 --- a/build-farm/platform-specific-configurations/downloaders.sh +++ b/build-farm/platform-specific-configurations/downloaders.sh @@ -20,21 +20,21 @@ #################################################################################### # This function switches logic based on the (supported) os -# It is currently relying on $bootDir being set. This should be fixed later function downloadBootJDK() { if uname -o | grep -i -e Linux ; then downloadLinuxBootJDK "$@" elif uname -o | grep -i -e Cygwin -e Windows ; then downloadWindowsBootJDK "$@" else - echo "Unsupported platfrom for direct download of boot jdk: $(uname -m) $(uname -o)" + echo "Unsupported platform for direct download of boot jdk: $(uname -m) $(uname -o)" exit 1 fi } function downloadLinuxBootJDK() { - ARCH=$1 - VER=$2 + local ARCH="${1}" + local VER="${2}" + local bootDir="${3}" export downloadArch case "$ARCH" in "riscv64") downloadArch="$NATIVE_API_ARCH";; @@ -55,9 +55,7 @@ function downloadLinuxBootJDK() { 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 - # shellcheck disable=SC2154 mkdir "$bootDir" - # shellcheck disable=SC2154 tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" set -e else @@ -78,9 +76,7 @@ function downloadLinuxBootJDK() { 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 bootjdk.tar.gz.sig bootjdk.tar.gz || exit 1 - # shellcheck disable=SC2154 mkdir "$bootDir" - # shellcheck disable=SC2154 tar xpzf bootjdk.tar.gz --strip-components=1 -C "$bootDir" else # If no binaries are available then try from adoptopenjdk @@ -97,8 +93,9 @@ function downloadLinuxBootJDK() { } function downloadWindowsBootJDK() { - ARCHITECTURE="${1}" - VER=${2} + local ARCHITECTURE="${1}" + local VER="${2}" + local bootDir="${3}" # This is needed to convert x86-32 to x32 which is what the API uses export downloadArch case "$ARCHITECTURE" in @@ -147,6 +144,5 @@ function downloadWindowsBootJDK() { fi fi unzip -q openjdk.zip - # shellcheck disable=SC2154 mv "$(ls -d jdk*"${VER}"*)" "$bootDir" } diff --git a/build-farm/platform-specific-configurations/linux.sh b/build-farm/platform-specific-configurations/linux.sh index 9264fa598..2a6ed9a8b 100755 --- a/build-farm/platform-specific-configurations/linux.sh +++ b/build-farm/platform-specific-configurations/linux.sh @@ -254,7 +254,7 @@ if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then # shellcheck disable=SC2140 export "${BOOT_JDK_VARIABLE}"="/usr/lib/jvm/jdk-${JDK_BOOT_VERSION}" elif [ "$JDK_BOOT_VERSION" -ge 8 ]; then # Adoptium has no build pre-8 - downloadLinuxBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" + downloadLinuxBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" "$bootDir" fi fi fi diff --git a/build-farm/platform-specific-configurations/windows.sh b/build-farm/platform-specific-configurations/windows.sh index 3f449315d..8e1c14e94 100755 --- a/build-farm/platform-specific-configurations/windows.sh +++ b/build-farm/platform-specific-configurations/windows.sh @@ -44,7 +44,7 @@ if [ ! -d "$(eval echo "\$$BOOT_JDK_VARIABLE")" ]; then # shellcheck disable=SC2140 export "${BOOT_JDK_VARIABLE}"="/cygdrive/c/openjdk/jdk-${JDK_BOOT_VERSION}" elif [ "$JDK_BOOT_VERSION" -ge 8 ]; then # Adoptium has no build pre-8 - downloadWindowsBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" + downloadWindowsBootJDK "${ARCHITECTURE}" "${JDK_BOOT_VERSION}" "$bootDir" fi fi fi diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index c22a96d54..cf2f2b6de 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -625,16 +625,15 @@ downloadDevkit() { downloadBootJdkIfNeeded () { if [[ "${BUILD_CONFIG[JDK_BOOT_DIR]}" == "download" ]]; then - # The bootDir is used by downloaders.sh methods; it would be nice to change it in future so the download method is unified - bootDir="${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" - if [ -e "$bootDir" ] ; then - echo "Reusing $bootDir" + local futureBootDir="${BUILD_CONFIG[WORKSPACE_DIR]}/downloaded-boot-jdk-${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" + if [ -e "$futureBootDir" ] ; then + echo "Reusing $futureBootDir" else source "$SCRIPT_DIR/../build-farm/platform-specific-configurations/downloaders.sh" - echo "Downloading to $bootDir" - downloadBootJDK "$(uname -m)" "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" + echo "Downloading to $futureBootDir" + downloadBootJDK "$(uname -m)" "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" "${futureBootDir}" fi - BUILD_CONFIG[JDK_BOOT_DIR]="${bootDir}" + BUILD_CONFIG[JDK_BOOT_DIR]="${futureBootDir}" fi } From 47f9cf2cbc9e7236c15bc5073f937ef5884f0272 Mon Sep 17 00:00:00 2001 From: Jiri Date: Tue, 7 May 2024 11:02:04 +0200 Subject: [PATCH 14/14] moved downloaders.sh to sbin/common/ build-farm/platform-specific-configurations/downloaders.sh -> sbin/common/downloaders.sh --- build-farm/platform-specific-configurations/linux.sh | 2 +- build-farm/platform-specific-configurations/windows.sh | 2 +- .../common}/downloaders.sh | 0 sbin/prepareWorkspace.sh | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename {build-farm/platform-specific-configurations => sbin/common}/downloaders.sh (100%) diff --git a/build-farm/platform-specific-configurations/linux.sh b/build-farm/platform-specific-configurations/linux.sh index fb1f83a4c..482d51f84 100755 --- a/build-farm/platform-specific-configurations/linux.sh +++ b/build-farm/platform-specific-configurations/linux.sh @@ -16,7 +16,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # shellcheck source=sbin/common/constants.sh source "$SCRIPT_DIR/../../sbin/common/constants.sh" -source "$SCRIPT_DIR/downloaders.sh" +source "$SCRIPT_DIR/../../sbin/common/downloaders.sh" if [[ "$JAVA_FEATURE_VERSION" -ge 21 ]]; then # jdk-21+ uses "bundled" FreeType diff --git a/build-farm/platform-specific-configurations/windows.sh b/build-farm/platform-specific-configurations/windows.sh index 8e1c14e94..9b9265fe0 100755 --- a/build-farm/platform-specific-configurations/windows.sh +++ b/build-farm/platform-specific-configurations/windows.sh @@ -16,7 +16,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # shellcheck source=sbin/common/constants.sh source "$SCRIPT_DIR/../../sbin/common/constants.sh" -source "$SCRIPT_DIR/downloaders.sh" +source "$SCRIPT_DIR/../../sbin/common/downloaders.sh" export ANT_HOME=/cygdrive/C/Projects/OpenJDK/apache-ant-1.10.1 export DRAGONWELL8_BOOTSTRAP=/cygdrive/C/openjdk/dragonwell-bootstrap/jdk8u272-ga diff --git a/build-farm/platform-specific-configurations/downloaders.sh b/sbin/common/downloaders.sh similarity index 100% rename from build-farm/platform-specific-configurations/downloaders.sh rename to sbin/common/downloaders.sh diff --git a/sbin/prepareWorkspace.sh b/sbin/prepareWorkspace.sh index 1f5be11f7..ece9e6147 100644 --- a/sbin/prepareWorkspace.sh +++ b/sbin/prepareWorkspace.sh @@ -658,7 +658,7 @@ downloadBootJdkIfNeeded () { if [ -e "$futureBootDir" ] ; then echo "Reusing $futureBootDir" else - source "$SCRIPT_DIR/../build-farm/platform-specific-configurations/downloaders.sh" + source "$SCRIPT_DIR/common/downloaders.sh" echo "Downloading to $futureBootDir" downloadBootJDK "$(uname -m)" "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" "${futureBootDir}" fi