Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
88 changes: 48 additions & 40 deletions build_latest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ source ./common_functions.sh

if [ ! -z "$1" ]; then
version=$1
if [ ! -z "$(check_version $version)" ]; then
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
./generate_latest_sums.sh ${version}

# source the hotspot and openj9 shasums scripts
# Source the hotspot and openj9 shasums scripts
avail_jvms=""
if [ -f hotspot_shasums_latest.sh ]; then
source ./hotspot_shasums_latest.sh
Expand All @@ -45,7 +45,7 @@ if [ -f openj9_shasums_latest.sh ]; then
fi

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

# Build the docker images and tag it based on the arch that we are on currently
machine=`uname -m`
Expand All @@ -71,14 +71,15 @@ x86_64)
package="jdk"
;;
*)
echo "ERROR: Unsupported arch:$machine, Exiting"
echo "ERROR: Unsupported arch:${machine}, Exiting"
exit 1
;;
esac

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

tags=""
for tag in $*
Expand All @@ -87,16 +88,12 @@ 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}.${typ}"

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
Expand All @@ -109,47 +106,58 @@ 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 ${avail_jvms}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract more logic to functions?

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
types=$(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 typ in ${types}
do
file="${dir}/Dockerfile.${vm}.${build}.${typ}"
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 [ "${typ}" == "slim" ]; then
tag=${tag}-slim
fi
echo "INFO: Building ${trepo} ${tag} from $file ..."
build_image ${trepo} ${build} ${typ} ${tag}
popd >/dev/null
done
done
done
done
Expand Down
31 changes: 28 additions & 3 deletions common_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,20 @@
# limitations under the License.
#

tags_config_file="tags.config"
openj9_config_file="openj9.config"
hotspot_config_file="hotspot.config"

# 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
version=$1
case ${version} in
8|9|10)
;;
*)
Expand Down Expand Up @@ -68,3 +73,23 @@ 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}
}
43 changes: 21 additions & 22 deletions generate_latest_sums.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ source ./common_functions.sh

if [ ! -z "$1" ]; then
version=$1
if [ ! -z "$(check_version $version)" ]; then
if [ ! -z "$(check_version ${version})" ]; then
echo "ERROR: Invalid Version"
echo "Usage: $0 [${supported_versions}]"
exit 1
Expand All @@ -35,47 +35,49 @@ function get_shasums() {
vm=$2
ofile="${rootdir}/${vm}_shasums_latest.sh"

if [ "$vm" == "openj9" ]; then
reldir="openjdk${ver}-openj9"
else
reldir="openjdk${ver}"
reldir="openjdk${ver}"
if [ "${vm}" != "hotspot" ]; then
reldir="${reldir}-${vm}"
fi
for buildtype in ${build_types}
for build in ${supported_builds}
do
info_url="https://api.adoptopenjdk.net/${reldir}/${buildtype}/x64_linux/latest"
info_url="https://api.adoptopenjdk.net/${reldir}/${build}/x64_linux/latest"
info=$(curl -Ls ${info_url})
err=$(echo ${info} | grep -e "Error" -e "No matches")
if [ "${err}" != "" ]; then
continue;
fi
full_version=$(echo ${info} | grep "release_name" | awk -F'"' '{ print $4 }');
if [ "${buildtype}" == "nightly" ]; then
# remove date at the end of full_version for nightly builds
full_version=$(echo ${full_version} | sed 's/-[0-9]\{4\}[0-9]\{2\}[0-9]\{2\}$//')
if [ "${build}" == "nightly" ]; then
# remove date and time at the end of full_version for nightly builds
full_version=$(echo ${full_version} | sed 's/-[0-9]\{4\}[0-9]\{2\}[0-9]\{2\}[0-9]\{4\}$//')
fi
printf "declare -A jdk_%s_%s_%s_sums=(\n" ${vm} ${ver} ${buildtype} >> ${ofile}
# Declare the array with the proper name and write to the vm output file.
printf "declare -A jdk_%s_%s_%s_sums=(\n" ${vm} ${ver} ${build} >> ${ofile}
# Capture the full version according to adoptopenjdk
printf "\t[version]=\"%s\"\n" ${full_version} >> ${ofile}
for arch in ${arches}
do
case ${arch} in
aarch64)
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${buildtype}/aarch64_linux/latest";
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${build}/aarch64_linux/latest";
;;
ppc64le)
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${buildtype}/ppc64le_linux/latest";
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${build}/ppc64le_linux/latest";
;;
s390x)
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${buildtype}/s390x_linux/latest";
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${build}/s390x_linux/latest";
;;
x86_64)
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${buildtype}/x64_linux/latest";
LATEST_URL="https://api.adoptopenjdk.net/${reldir}/${build}/x64_linux/latest";
;;
*)
echo "Unsupported arch: ${arch}"
esac
shasum_file="${arch}_${buildtype}_latest"
shasum_file="${arch}_${build}_latest"
curl -Lso ${shasum_file} ${LATEST_URL};
availability=$(grep "No matches" ${shasum_file});
# Print the arch and the corresponding shasums to the vm output file
if [ -z "${availability}" ]; then
shasums_url=$(cat ${shasum_file} | grep "checksum_link" | awk -F'"' '{ print $4 }');
shasum=$(curl -Ls ${shasums_url} | sed -e 's/<[^>]*>//g' | awk '{ print $1 }');
Expand All @@ -86,18 +88,15 @@ function get_shasums() {
printf ")\n" >> ${ofile}

echo
echo "sha256sums for the version ${full_version} for build type \"${buildtype}\" is now available in ${ofile}"
echo "sha256sums for the version ${full_version} for build type \"${build}\" is now available in ${ofile}"
echo
done
chmod +x ${ofile}
}


echo "Getting latest shasum info for major version: $version"
for ver in ${version}
for vm in ${jvms}
do
for vm in ${jvms}
do
get_shasums ${ver} ${vm}
done
get_shasums ${version} ${vm}
done
Loading