Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 67 additions & 90 deletions build_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,10 @@ version="9"

source ./common_functions.sh

if [ ! -z "$1" ]; then
version=$1
if [ ! -z "$(check_version $version)" ]; then
echo "ERROR: Invalid Version"
echo "Usage: $0 [${supported_versions}]"
exit 1
fi
fi

# Find the latest version and get the corresponding shasums
./generate_latest_sums.sh $version

# source the hotspot and openj9 shasums scripts
avail_jvms=""
if [ -f hotspot_shasums_latest.sh ]; then
source ./hotspot_shasums_latest.sh
avail_jvms="hotspot"
fi
if [ -f openj9_shasums_latest.sh ]; then
source ./openj9_shasums_latest.sh
avail_jvms="${avail_jvms} openj9"
fi

# Generate the Dockerfiles for the latest version
./update_multiarch.sh $version

# Build the docker images and tag it based on the arch that we are on currently
machine=`uname -m`
case $machine in
aarch64)
arch="aarch64"
oses="ubuntu"
package="jdk"
;;
ppc64le)
arch="ppc64le"
oses="ubuntu"
package="jdk"
;;
s390x)
arch="s390x"
oses="ubuntu"
package="jdk"
;;
x86_64)
arch="x86_64"
oses="ubuntu alpine"
package="jdk"
;;
*)
echo "ERROR: Unsupported arch:$machine, Exiting"
exit 1
;;
esac

function build_image() {
repo=$1
shift
repo=$1; shift;
build=$1; shift;
btype=$1; shift;

tags=""
for tag in $*
Expand All @@ -87,69 +33,100 @@ function build_image() {
echo "docker push ${repo}:${tag}" >> ${push_cmdfile}
done

if [ "${buildtype}" == "nightly" ]; then
dockerfile="Dockerfile.${vm}.nightly"
else
dockerfile="Dockerfile.${vm}"
fi
dockerfile="Dockerfile.${vm}.${build}.${btype}"

echo "#####################################################"
echo "INFO: docker build --no-cache ${tags} -f ${dockerfile} ."
echo "#####################################################"
docker build --no-cache ${tags} -f ${dockerfile} .
docker build --no-cache ${tags} -f ${dockerfile} .
if [ $? != 0 ]; then
echo "ERROR: Docker build of image: ${tags} from ${dockerfile} failed."
exit 1
fi
}

if [ ! -z "$1" ]; then
set_version $1
fi

# Set the OSes that will be built on based on the current arch
set_arch_os

# Which JVMs are available for the current version
./generate_latest_sums.sh ${version}

# Source the hotspot and openj9 shasums scripts
available_jvms=""
if [ -f hotspot_shasums_latest.sh ]; then
source ./hotspot_shasums_latest.sh
available_jvms="hotspot"
fi
if [ -f openj9_shasums_latest.sh ]; then
source ./openj9_shasums_latest.sh
available_jvms="${available_jvms} openj9"
fi

# Generate the Dockerfiles for the current version
./update_multiarch.sh ${version}

# Script that has the push commands for the images that we are building.
echo "#!/bin/bash" > ${push_cmdfile}
echo >> ${push_cmdfile}

# Valid image tags
#adoptopenjdk/openjdk${version}:${arch}-${os}-${rel}
#adoptopenjdk/openjdk${version}:${arch}-${os}-${rel}-slim
#adoptopenjdk/openjdk${version}:${arch}-${os}-${rel}-nightly
#adoptopenjdk/openjdk${version}:${arch}-${os}-${rel}-nightly-slim
#adoptopenjdk/openjdk${version}-openj9:${arch}-${os}-${rel}
#adoptopenjdk/openjdk${version}-openj9:${arch}-${os}-${rel}-slim
#adoptopenjdk/openjdk${version}-openj9:${arch}-${os}-${rel}-nightly
for os in ${oses}
#adoptopenjdk/openjdk${version}-openj9:${arch}-${os}-${rel}-nightly-slim
for vm in ${available_jvms}
do
for vm in ${avail_jvms}
for os in ${oses}
do
for buildtype in ${build_types}
# Build = Release or Nightly
builds=$(parse_vm_entry ${vm} ${version} ${os} "Build:")
# Type = Full or Slim
btypes=$(parse_vm_entry ${vm} ${version} ${os} "Type:")
dir=$(parse_vm_entry ${vm} ${version} ${os} "Directory:")

for build in ${builds}
do
shasums="${package}"_"${vm}"_"${version}"_"${buildtype}"_sums
shasums="${package}"_"${vm}"_"${version}"_"${build}"_sums
sup=$(vm_supported_onarch ${vm} ${shasums})
if [ -z "${sup}" ]; then
continue;
fi
jverinfo=${shasums}[version]
eval jrel=\${$jverinfo}
# Docker image tags cannot have "+" in them, replace it with "." instead.
rel=$(echo $jrel | sed 's/+/./')

if [ "${buildtype}" == "nightly" ]; then
file="${root_dir}/${version}/${package}/${os}/Dockerfile.${vm}.nightly"
else
file="${root_dir}/${version}/${package}/${os}/Dockerfile.${vm}"
fi
if [ ! -f ${file} ]; then
continue;
fi
ddir=`dirname ${file}`
pushd $ddir >/dev/null
if [ "${vm}" == "hotspot" ]; then
trepo=${target_repo}${version}
else
trepo=${target_repo}${version}-${vm}
fi
if [ "${buildtype}" == "nightly" ]; then
tag=${arch}-${os}-${rel}-nightly
else

for btype in ${btypes}
do
file="${dir}/Dockerfile.${vm}.${build}.${btype}"
if [ ! -f ${file} ]; then
continue;
fi
pushd ${dir} >/dev/null
if [ "${vm}" == "hotspot" ]; then
trepo=${target_repo}${version}
else
trepo=${target_repo}${version}-${vm}
fi
tag=${arch}-${os}-${rel}
fi
echo "INFO: Building ${trepo} ${tag} from $file ..."
build_image ${trepo} ${tag}
popd >/dev/null
if [ "${build}" == "nightly" ]; then
tag=${tag}-nightly
fi
if [ "${btype}" == "slim" ]; then
tag=${tag}-slim
fi
echo "INFO: Building ${trepo} ${tag} from $file ..."
build_image ${trepo} ${build} ${btype} ${tag}
popd >/dev/null
done
done
done
done
Expand Down
100 changes: 95 additions & 5 deletions common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@
# limitations under the License.
#

# Config files
tags_config_file="tags.config"
openj9_config_file="openj9.config"
hotspot_config_file="hotspot.config"

# All supported JVMs
all_jvms="hotspot openj9"

# All supported arches
all_arches="aarch64 ppc64le s390x x86_64"

# Current JVM versions supported
export supported_versions="8 9 10"

# Current build types supported
export build_types="releases nightly"
# Current builds supported
export supported_builds="releases nightly"

function check_version()
{
case $version in
function check_version() {
version=$1
case ${version} in
8|9|10)
;;
*)
Expand All @@ -30,6 +41,47 @@ function check_version()
esac
}

# Set a valid version
function set_version() {
version=$1
if [ ! -z "$(check_version ${version})" ]; then
echo "ERROR: Invalid Version: ${version}"
echo "Usage: $0 [${supported_versions}]"
exit 1
fi
}

# Set the valid OSes for the current architecure.
function set_arch_os() {
machine=`uname -m`
case ${machine} in
aarch64)
arch="aarch64"
oses="ubuntu"
package="jdk"
;;
ppc64el|ppc64le)
arch="ppc64le"
oses="ubuntu"
package="jdk"
;;
s390x)
arch="s390x"
oses="ubuntu"
package="jdk"
;;
amd64|x86_64)
arch="x86_64"
oses="ubuntu alpine"
package="jdk"
;;
*)
echo "ERROR: Unsupported arch:${machine}, Exiting"
exit 1
;;
esac
}

# Get the supported architectures for a given VM (Hotspot, OpenJ9).
# This is based on the hotspot_shasums_latest.sh/openj9_shasums_latest.sh
function get_arches() {
Expand Down Expand Up @@ -68,3 +120,41 @@ function cleanup_manifest() {
# Currently there is no way to do this using the tool.
rm -rf ~/.docker/manifests
}

# Parse the openj9.config / hotspot.config file for an entry as specified by $4
# $1 = VM
# $2 = Version
# $3 = OS
# $4 = String to look for.
function parse_vm_entry() {
entry=$(cat ${1}.config | grep -B 4 "$2\/.*\/$3" | grep "$4" | sed "s/$4 //")
echo ${entry}
}

# Read the tags file and parse the specific tag.
# $1 = OS
# $2 = Build (releases / nightly)
# $3 = Type (full / slim)
function parse_tag_entry() {
tag="$1-$2-$3-tags:"
entry=$(cat ${tags_config_file} | grep ${tag} | sed "s/${tag} //")
echo ${entry}
}

# Where is the manifest tool installed?"
# Manifest tool (docker with manifest support) needs to be added from here
# https://github.com/clnperez/cli
# $ cd /opt/manifest_tool
# $ git clone -b manifest-cmd https://github.com/clnperez/cli.git
# $ cd cli
# $ make -f docker.Makefile cross
manifest_tool_dir="/opt/manifest_tool"
manifest_tool=${manifest_tool_dir}/cli/build/docker

function check_manifest_tool() {
if [ ! -f ${manifest_tool} ]; then
echo
echo "ERROR: Docker with manifest support not found at path ${manifest_tool}"
exit 1
fi
}
Loading