Skip to content

Commit 45c9341

Browse files
committed
Updated script to add doc updates for unofficial docker repo.
Addressed earlier review comments.
1 parent 800e217 commit 45c9341

File tree

2 files changed

+260
-119
lines changed

2 files changed

+260
-119
lines changed

dockerhub_config_update.sh

Lines changed: 0 additions & 119 deletions
This file was deleted.

dockerhub_doc_config_update.sh

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
#!/bin/bash
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# Script that generates the `adoptopenjdk` config file for the official docker
16+
# image github repo and the doc updates for the unofficial docker image repo.
17+
# Process to update the official docker image repo
18+
# 1. Run ./update_all.sh to update all the dockerfiles in the current repo.
19+
# 2. Submit PR to push the newly generated dockerfiles to the current repo.
20+
# 3. After above PR is merged, git pull the latest changes.
21+
# 4. Run this command
22+
#
23+
set -o pipefail
24+
25+
source ./common_functions.sh
26+
27+
official_docker_image_file="adoptopenjdk"
28+
oses="ubuntu alpine debian windows"
29+
30+
latest_version="12"
31+
hotspot_latest_tags="hotspot, latest"
32+
openj9_latest_tags="openj9"
33+
34+
git_repo="https://github.com/AdoptOpenJDK/openjdk-docker/blob/master"
35+
36+
# Get the latest git commit of the current repo.
37+
# This is assumed to have all the latest dockerfiles already.
38+
gitcommit=$(git log | head -1 | awk '{ print $2 }')
39+
40+
print_official_text() {
41+
echo "$*" >> ${official_docker_image_file}
42+
}
43+
44+
print_unofficial_tags() {
45+
for tag in $*
46+
do
47+
echo -n "\`${tag}\`, " >> ${ver}_${vm}.txt
48+
done
49+
}
50+
51+
print_official_header() {
52+
print_official_text "# AdoptOpenJDK official images for OpenJDK with HotSpot and OpenJDK with Eclipse OpenJ9."
53+
print_official_text
54+
print_official_text "Maintainers: Dinakar Guniguntala <[email protected]> (@dinogun)"
55+
print_official_text "GitRepo: https://github.com/AdoptOpenJDK/openjdk-docker.git"
56+
}
57+
58+
function generate_unofficial_image_info() {
59+
full_version=$(grep "VERSION" ${file} | awk '{ print $3 }')
60+
full_version=$(echo ${full_version} | sed 's/+/_/')
61+
if [ "${pkg}" == "jre" ]; then
62+
full_version=$(echo ${full_version} | sed 's/jdk/jre/')
63+
fi
64+
65+
if [ "${build}" == "nightly" ]; then
66+
full_version="${full_version}-${build}"
67+
fi
68+
if [ "${btype}" == "slim" ]; then
69+
full_version="${full_version}-${btype}"
70+
fi
71+
72+
super_tags="";
73+
case ${os} in
74+
ubuntu)
75+
if [ "${pkg}" == "jre" ]; then
76+
super_tags="${pkg}";
77+
fi
78+
if [ "${build}" == "nightly" ]; then
79+
if [ "${super_tags}" == "" ]; then
80+
super_tags="${build}";
81+
else
82+
super_tags="${super_tags}-${build}"
83+
fi
84+
fi
85+
if [ "${btype}" == "slim" ]; then
86+
if [ "${super_tags}" == "" ]; then
87+
super_tags="${btype}"
88+
else
89+
super_tags="${super_tags}-${btype}"
90+
fi
91+
fi
92+
if [ "${super_tags}" == "" ]; then
93+
super_tags="latest";
94+
fi
95+
;;
96+
alpine|debian|windows)
97+
super_tags="${os}";
98+
if [ "${pkg}" == "jre" ]; then
99+
super_tags="${super_tags}-${pkg}";
100+
fi
101+
if [ "${build}" == "nightly" ]; then
102+
super_tags="${super_tags}-${build}";
103+
fi
104+
if [ "${btype}" == "slim" ]; then
105+
super_tags="${super_tags}-${btype}"
106+
fi
107+
;;
108+
esac
109+
110+
arches=$(echo $(grep ') \\' ${file} | \
111+
sed 's/\(ppc64el\|amd64\|arm64\)//g' | \
112+
sort | grep -v "*" | \
113+
sed 's/) \\//g; s/|/ /g'))
114+
if [ "${os}" == "alpine" ]; then
115+
arches=$(echo ${arches} | sed 's/\(armhf\|aarch64\|ppc64le\|s390x\)//g')
116+
fi
117+
print_unofficial_tags "${super_tags} ${full_version}"
118+
for arch in ${arches}
119+
do
120+
print_unofficial_tags "${arch}-${os}-${full_version}" >> ${ver}_${vm}.txt
121+
done
122+
file=$(echo ${file} | cut -c 3-)
123+
echo "(*${file}*)](${git_repo}/${file})" >> ${ver}_${vm}.txt
124+
}
125+
126+
function generate_official_image_tags() {
127+
# Generate the tags
128+
full_version=$(grep "VERSION" ${file} | awk '{ print $3 }')
129+
130+
ojdk_version=$(echo ${full_version} | sed 's/\(jdk\|jdk-\)//' | awk -F '_' '{ print $1 }')
131+
ojdk_version=$(echo ${ojdk_version} | sed 's/+/_/')
132+
133+
full_ver_tag="${ojdk_version}-${pkg}"
134+
# Add the openj9 version
135+
if [ "${vm}" == "openj9" ]; then
136+
openj9_version=$(echo ${full_version} | awk -F '_' '{ print $2 }')
137+
full_ver_tag="${full_ver_tag}-${openj9_version}"
138+
else
139+
full_ver_tag="${full_ver_tag}-${vm}"
140+
fi
141+
ver_tag="${ver}-${pkg}-${vm}"
142+
all_tags="${full_ver_tag}, ${ver_tag}"
143+
if [ "${pkg}" == "jdk" ]; then
144+
jdk_tag="${ver}-${vm}"
145+
all_tags="${all_tags}, ${jdk_tag}"
146+
# Add the "latest", "hotspot" and "openj9" tags for the right version
147+
if [ "${ver}" == "${latest_version}" ]; then
148+
vm_tags="${vm}_latest_tags"
149+
eval vm_tags_val=\${$vm_tags}
150+
all_tags="${all_tags}, ${vm_tags_val}"
151+
fi
152+
fi
153+
}
154+
155+
function generate_official_image_arches() {
156+
# Generate the supported arches for the above tags.
157+
arches=$(echo $(grep ') \\' ${file} | \
158+
sed 's/\(ppc64el\|x86_64\|aarch64\)//g' | \
159+
sed 's/armhf/arm32v7/' | \
160+
sed 's/arm64/arm64v8/' | \
161+
sort | grep -v "*" | \
162+
sed 's/) \\//g; s/|/ /g'))
163+
arches=$(echo ${arches} | sed 's/ /, /g')
164+
}
165+
166+
function print_official_image_file() {
167+
# Print them all
168+
echo "Tags: ${all_tags}" >> ${official_docker_image_file}
169+
echo "Architectures: ${arches}" >> ${official_docker_image_file}
170+
echo "GitCommit: ${gitcommit}" >> ${official_docker_image_file}
171+
echo "Directory: ${dfdir}" >> ${official_docker_image_file}
172+
echo "File: ${dfname}" >> ${official_docker_image_file}
173+
}
174+
175+
rm -f ${official_docker_image_file}
176+
print_official_header
177+
178+
function generate_official_image_info() {
179+
# Currently we are not pushing docker images for Alpine, Debian and Windows
180+
if [ "${os}" == "windows" -o "${os}" == "alpine" -o "${os}" == "debian" ]; then
181+
return;
182+
fi
183+
# We do not push our nightly and slim images either.
184+
if [ "${build}" == "nightly" -o "${btype}" == "slim" ]; then
185+
return;
186+
fi
187+
generate_official_image_tags
188+
generate_official_image_arches
189+
print_official_image_file
190+
}
191+
192+
# Iterate through all the VMs, for each supported version and packages to
193+
# generate the config file.
194+
for vm in ${all_jvms}
195+
do
196+
for ver in ${supported_versions}
197+
do
198+
print_official_text
199+
print_official_text "#------------------------------${vm} v${ver} images-------------------------------"
200+
for pkg in ${all_packages}
201+
do
202+
print_official_text
203+
# Iterate through each of the Dockerfiles.
204+
for file in $(find . -name "Dockerfile.*" | grep "/${ver}" | grep "${vm}" | grep "${pkg}")
205+
do
206+
# file will look like ./12/jdk/debian/Dockerfile.openj9.nightly.slim
207+
# dockerfile name
208+
dfname=$(basename ${file})
209+
# dockerfile dir
210+
dfdir=$(dirname ${file} | cut -c 3-)
211+
os=$(echo ${file} | awk -F '/' '{ print $4 }')
212+
# build = release or nightly
213+
build=$(echo ${dfname} | awk -F "." '{ print $3 }')
214+
# btype = full or slim
215+
btype=$(echo ${dfname} | awk -F "." '{ print $4 }')
216+
217+
generate_official_image_info
218+
done
219+
done
220+
done
221+
done
222+
223+
224+
for vm in ${all_jvms}
225+
do
226+
for ver in ${supported_versions}
227+
do
228+
for build in ${supported_builds}
229+
do
230+
if [ "${build}" == "releases" ]; then
231+
echo "**Release Builds**" >> ${ver}_${vm}.txt
232+
else
233+
echo "**Nightly Builds**" >> ${ver}_${vm}.txt
234+
fi
235+
for os in ${oses}
236+
do
237+
for pkg in ${all_packages}
238+
do
239+
for file in $(find . -name "Dockerfile.*" | grep "/${ver}" | grep "${vm}" | grep "${build}" | grep "${os}" | grep "${pkg}")
240+
do
241+
echo -n "- [" >> ${ver}_${vm}.txt
242+
dfname=$(basename ${file})
243+
# dockerfile dir
244+
dfdir=$(dirname ${file} | cut -c 3-)
245+
pkg=$(echo ${file} | awk -F '/' '{ print $3 }')
246+
os=$(echo ${file} | awk -F '/' '{ print $4 }')
247+
# build = release or nightly
248+
build=$(echo ${dfname} | awk -F "." '{ print $3 }')
249+
# btype = full or slim
250+
btype=$(echo ${dfname} | awk -F "." '{ print $4 }')
251+
252+
generate_unofficial_image_info
253+
done
254+
done
255+
echo >> ${ver}_${vm}.txt
256+
done
257+
echo >> ${ver}_${vm}.txt
258+
done
259+
done
260+
done

0 commit comments

Comments
 (0)