forked from AdoptOpenJDK/openjdk-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_latest.sh
executable file
·152 lines (137 loc) · 4.61 KB
/
build_latest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env bash
#
# 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.
#
set -o pipefail
root_dir="$PWD"
push_cmdfile=${root_dir}/push_commands.sh
target_repo="adoptopenjdk/openjdk"
version="9"
source ./common_functions.sh
source ./dockerfile_functions.sh
# Build the Docker image with the given repo, build, build type and tags.
function build_image() {
repo=$1; shift;
build=$1; shift;
btype=$1; shift;
tags=""
for tag in $*
do
tags="${tags} -t ${repo}:${tag}"
echo "docker push ${repo}:${tag}" >> ${push_cmdfile}
done
dockerfile="Dockerfile.${vm}.${build}.${btype}"
echo "#####################################################"
echo "INFO: docker build --no-cache ${tags} -f ${dockerfile} ."
echo "#####################################################"
docker build --pull --no-cache ${tags} -f ${dockerfile} .
if [ $? != 0 ]; then
echo "ERROR: Docker build of image: ${tags} from ${dockerfile} failed."
exit 1
fi
}
# Build the docker image for a given VM, OS, BUILD and BUILD_TYPE combination.
function build_dockerfile {
vm=$1; pkg=$2; os=$3; build=$4; btype=$5;
jverinfo=${shasums}[version]
eval jrel=\${$jverinfo}
# Docker image tags cannot have "+" in them, replace it with "_" instead.
rel=$(echo ${jrel} | sed 's/+/_/')
if [ "${pkg}" == "jre" ]; then
rel=$(echo ${rel} | sed 's/jdk/jre/')
fi
# The target repo is different for different VMs
if [ "${vm}" == "hotspot" ]; then
trepo=${target_repo}${version}
else
trepo=${target_repo}${version}-${vm}
fi
# Get the default tag first
tag=${current_arch}-${os}-${rel}
# Append nightly for nightly builds
if [ "${build}" == "nightly" ]; then
tag=${tag}-nightly
fi
# Append slim for slim builds
if [ "${btype}" == "slim" ]; then
tag=${tag}-slim
# Copy the script to generate slim builds.
cp slim-java* config/slim-java* ${dir}/
fi
echo "INFO: Building ${trepo} ${tag} from $file ..."
pushd ${dir} >/dev/null
build_image ${trepo} ${build} ${btype} ${tag}
popd >/dev/null
}
if [ ! -z "$1" ]; then
set_version $1
fi
# Set the OSes that will be built on based on the current arch
set_arch_os
# Script that has the push commands for the images that we are building.
echo "#!/usr/bin/env 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
#adoptopenjdk/openjdk${version}-openj9:${arch}-${os}-${rel}-nightly-slim
for vm in ${all_jvms}
do
for package in ${all_packages}
do
for os in ${oses}
do
# Build = Release or Nightly
builds=$(parse_vm_entry ${vm} ${version} ${package} ${os} "Build:")
# Type = Full or Slim
btypes=$(parse_vm_entry ${vm} ${version} ${package} ${os} "Type:")
dir=$(parse_vm_entry ${vm} ${version} ${package} ${os} "Directory:")
for build in ${builds}
do
echo "Getting latest shasum info for [ ${version} ${vm} ${package} ${build} ]"
get_shasums ${version} ${vm} ${package} ${build}
# Source the generated shasums file to access the array
if [ -f ${vm}_shasums_latest.sh ]; then
source ./${vm}_shasums_latest.sh
else
continue;
fi
# Check if the VM is supported for the current arch
shasums="${package}"_"${vm}"_"${version}"_"${build}"_sums
sup=$(vm_supported_onarch ${vm} ${shasums})
if [ -z "${sup}" ]; then
continue;
fi
# Generate all the Dockerfiles for each of the builds and build types
for btype in ${btypes}
do
file="${dir}/Dockerfile.${vm}.${build}.${btype}"
generate_dockerfile ${file} ${package} ${build} ${btype} ${os}
if [ ! -f ${file} ]; then
continue;
fi
# Build the docker images for valid Dockerfiles
build_dockerfile ${vm} ${package} ${os} ${build} ${btype}
done
done
done
done
done
chmod +x ${push_cmdfile}
echo
echo "INFO: The push commands are available in file ${push_cmdfile}"