-
Notifications
You must be signed in to change notification settings - Fork 9
/
build_tools_latest.sh
executable file
·120 lines (107 loc) · 3.51 KB
/
build_tools_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
#!/bin/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
#
# http://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"
version="9"
source ./common_functions.sh
source ./dockerfile_functions.sh
if [ ! -z "$1" ]; then
set_version $1
fi
# Set the OSes that will be built on based on the current arch
set_arch_os
# Create the build tools dockerfiles
function build_tool_images() {
tool=$1;
vm=$2;
os=$3;
build=$4;
btype=$5;
# Get the tag alias to generate the build tools Dockerfiles
build_tags ${vm} ${os} ${build} ${btype}
# build_tags populates the array tag_aliases, but we just need the first element
# The first element corresponds to the tag alias
tags_arr=(${tag_aliases});
tag_alias=${tags_arr[0]};
tool_dir=$(parse_config_file ${tool} ${version} ${os} "Directory:")
file=Dockerfile.${vm}.${build}.${btype}
if [ ! -f ${tool_dir}/${file} ]; then
continue;
fi
tag=${tag_alias}
# The target repo is different for different VMs
trepo=${target_repo}/${tool}-openjdk${version}
if [ "${vm}" != "hotspot" ]; then
trepo=${trepo}-${vm}
fi
echo "INFO: Building ${trepo} ${tag} from ${file}..."
pushd ${tool_dir} >/dev/null
build_image ${file} ${trepo}:${tag}
popd >/dev/null
# Docker image has been built successfully.
# Add the command to push this image to docker hub.
echo "docker push ${trepo}:${tag}" >> ${push_cmdfile}
}
# Script that has the push commands for the images that we are building.
echo "#!/bin/bash" > ${push_cmdfile}
echo >> ${push_cmdfile}
# Loop through all the valid vm / os / build / build type combinations
# for each of the build tools.
for tool in ${all_tools}
do
for os in ${oses}
do
vms=$(parse_config_file ${tool} ${version} ${os} "Vms:")
# Build = Release or Nightly
builds=$(parse_config_file ${tool} ${version} ${os} "Build:")
# Type = Full or Slim
btypes=$(parse_config_file ${tool} ${version} ${os} "Type:")
dir=$(parse_config_file ${tool} ${version} ${os} "Directory:")
for vm in ${vms}
do
for build in ${builds}
do
echo "Getting latest shasum info for [ ${version} ${vm} ${build} ]"
get_shasums ${version} ${vm} ${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
# Generate any build tools dockerfiles that uses
# the above docker image as the base image.
create_build_tool_dockerfiles ${tool} ${vm} ${os} ${build} ${btype}
# Now build the corresponding docker images.
build_tool_images ${tool} ${vm} ${os} ${build} ${btype}
done
done
done
done
done
chmod +x ${push_cmdfile}
echo
echo "INFO: The push commands are available in file ${push_cmdfile}"