Skip to content

Commit

Permalink
UnixPB: Add Zulu7 for JDK8 Build bootstrap, make buildJDK.sh use JDK7 (
Browse files Browse the repository at this point in the history
…#1325)

* UnixPB: Add Zulu7 for JDK8 Build bootstrap

* Remove unnecessary mkdir /usr/lib/jvm task

* Update Zulu7 conditions & make buildJDK.sh use JDK7

* Make conditions use comparisons instead

* Use unarchive module and create symlink

* Fix conditions + add in /usr/lib/jvm check

* Remove SUSE/SLES12 from Conditions
  • Loading branch information
Willsparker authored May 18, 2020
1 parent 42c4526 commit 975c944
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 30 deletions.
52 changes: 22 additions & 30 deletions ansible/pbTestScripts/buildJDK.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,26 @@ checkJDKVersion() {
}

setBootJDK() {
local buildJDKNumber=$(echo ${JAVA_TO_BUILD//[!0-9]/})
local bootJDKNumber=$(($buildJDKNumber - 1));
# if building JDK8/9 look for 'jdk8u', not 'jdk-x'
if [[ $buildJDKNumber -eq 8 || $buildJDKNumber -eq 9 ]]; then
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name *jdk8*)
return
else
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name *jdk-$bootJDKNumber*)
fi

if [ -z "${JDK_BOOT_DIR}" ]
then
echo "Can't find jdk$bootJDKNumber to build JDK, looking for jdk$buildJDKNumber"
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name *jdk-$buildJDKNumber*)
fi
local buildJDKNumber=$(echo ${JAVA_TO_BUILD//[!0-9]/})
local bootJDKNumber=$(($buildJDKNumber - 1));
[[ $bootJDKNumber != "8" ]] && bootJDKNumber="-$bootJDKNumber"
if [[ $buildJDKNumber -eq 8 ]]; then
# CentOS JDK7
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name java-1.7.0-openjdk.x86_64)
# Ubuntu JDK7
[[ -z "$JDK_BOOT_DIR" ]] && export JDK_BOOT_DIR=$(find /usr/lib/jvm/ -maxdepth 1 -name java-1.7.0-openjdk-\*)
# Zulu-7 for OSs without JDK7
[[ -z "$JDK_BOOT_DIR" ]] && export JDK_BOOT_DIR=$(find /usr/lib/jvm/ -maxdepth 1 -name zulu7)
else
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name *jdk$bootJDKNumber*)
fi
# If JDK (jdkToBuild - 1) can't be found, look for equal boot and build jdk
if [ -z "${JDK_BOOT_DIR}" ]
then
[[ $buildJDKNumber != "8" ]] && buildJDKNumber="-$buildJDKNumber"
echo "Can't find jdk$bootJDKNumber to build JDK, looking for jdk$buildJDKNumber"
export JDK_BOOT_DIR=$(find /usr/lib/jvm -maxdepth 1 -name *jdk$buildJDKNumber*)
fi
}

cloneRepo() {
Expand Down Expand Up @@ -139,21 +144,8 @@ if [[ ${unameOutput} != "x86_64" ]]; then
export ARCHITECTURE=${unameOutput}
fi

# Differences in openJDK7 name between OSs. Search for CentOS one
export JDK7_BOOT_DIR=$(find /usr/lib/jvm/ -name java-1.7.0-openjdk.x86_64)
# If the CentOS JDK7 can't be found, search for the Ubuntu one
[[ -z "$JDK7_BOOT_DIR" ]] && export JDK7_BOOT_DIR=$(find /usr/lib/jvm/ -name java-1.7.0-openjdk-\*)

# Differences in openJDK8 name between Ubuntu and CentOS
export JAVA_HOME=$(find /usr/lib/jvm/ -name java-1.8.0-openjdk-\*)
if [ -z "$JAVA_HOME" ]; then
export JAVA_HOME=$(ls -1d /usr/lib/jvm/adoptopenjdk-8-* | head -1)
fi

if grep 'openSUSE' /etc/os-release >/dev/null 2>&1; then
echo "Running on openSUSE"
JAVA_HOME=$(find /usr/lib/jvm/ -name jdk8u*)
fi
# Use the JDK8 installed with the adoptopenjdk_install role to run Gradle with.
export JAVA_HOME=$(find /usr/lib/jvm -maxdepth 1 -name *jdk8*)

# Only build Hotspot on FreeBSD
if [[ $(uname) == "FreeBSD" ]]; then
Expand Down
1 change: 1 addition & 0 deletions ansible/playbooks/AdoptOpenJDK_Unix_Playbook/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- role: nasm # OpenJ9
when: ansible_architecture == 'x86_64'
tags: [build_tools, build_tools_openj9]
- zulu7 # JDK8 Build Bootstrap
- role: adoptopenjdk_install
jdk_version: 8
tags: build_tools
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
##########
# ZULU-7 #
##########

# Install zulu-7 for OSs that don't have openjdk-7 available in their package manager:
# CentOS/RHEL 8, Debian 10, Ubuntu1804, openSUSE/SLES 12 (only tested for x86_64)

- name: Checking for /usr/lib/jvm
stat: path=/usr/lib/jvm
register: usr_lib_jvm_exists
when:
- ansible_os_family != "Darwin"
tags: zulu7

- name: Creating /usr/lib/jvm if not found
file:
path: /usr/lib/jvm
state: directory
owner: root
mode: 0755
when:
- not usr_lib_jvm_exists.stat.exists
- ansible_os_family != "Darwin"
tags: zulu7

- name: Check if Zulu-7 is already installed in the target location
shell: ls -ld /usr/lib/jvm/zulu7 2>&1
ignore_errors: yes
register: zulu7_installed
when:
- ansible_os_family != "Darwin"
- ansible_architecture == "x86_64"
- ((ansible_distribution == "Redhat" or ansible_distribution == "CentOS") and (ansible_distribution_major_version|int >= 8)) or
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 18) or
(ansible_distribution == "Debian" and ansible_distribution_major_version|int >= 10)
tags: zulu7

- name: Install latest release if not already installed
unarchive:
src: https://cdn.azul.com/zulu/bin/zulu7.38.0.11-ca-jdk7.0.262-linux_x64.tar.gz
dest: /usr/lib/jvm/
remote_src: yes
when:
- ansible_os_family != "Darwin"
- ansible_architecture == "x86_64"
- ((ansible_distribution == "Redhat" or ansible_distribution == "CentOS") and (ansible_distribution_major_version|int >= 8)) or
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 18) or
(ansible_distribution == "Debian" and ansible_distribution_major_version|int >= 10)
- zulu7_installed.rc != 0
tags: zulu7

- name: Create symlink to point at zulu-7
file:
src: /usr/lib/jvm/zulu7.38.0.11-ca-jdk7.0.262-linux_x64
dest: /usr/lib/jvm/zulu7
state: link
when:
- ansible_os_family != "Darwin"
- ansible_architecture == "x86_64"
- ((ansible_distribution == "Redhat" or ansible_distribution == "CentOS") and (ansible_distribution_major_version|int >= 8)) or
(ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 18) or
(ansible_distribution == "Debian" and ansible_distribution_major_version|int >= 10)
- zulu7_installed.rc != 0
tags: zulu7

0 comments on commit 975c944

Please sign in to comment.