forked from AdoptOpenJDK/openjdk-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_functions.sh
executable file
·633 lines (581 loc) · 20.4 KB
/
common_functions.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#!/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.
#
# Config files
tags_config_file="config/tags.config"
# shellcheck disable=SC2034
openj9_config_file="config/openj9.config"
# shellcheck disable=SC2034
hotspot_config_file="config/hotspot.config"
# Test lists
# shellcheck disable=SC2034
test_image_types_file="config/test_image_types.list"
# shellcheck disable=SC2034
test_image_types_all_file="config/test_image_types_all.list"
# shellcheck disable=SC2034
test_buckets_file="config/test_buckets.list"
# All supported JVMs
# shellcheck disable=SC2034 # used externally
all_jvms="hotspot openj9"
# All supported arches
all_arches="aarch64 armv7l ppc64le s390x x86_64 windows-amd windows-nano"
# All supported packages
# shellcheck disable=SC2034 # used externally
all_packages="jdk jre"
# Current JVM versions supported
export supported_versions="8 11 14"
export latest_version="14"
# Current builds supported
export supported_builds="releases nightly"
function check_version() {
version=$1
case ${version} in
8|9|10|11|12|13|14)
;;
*)
echo "ERROR: Invalid version"
;;
esac
}
# Set a valid version
function set_version() {
version=$1
if [ -n "$(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() {
if [ ! -z "$TARGET_ARCHITECTURE" ]; then
# Use buildx environment for build https://www.docker.com/blog/multi-platform-docker-builds/
echo "overiding machine to $TARGET_ARCHITECTURE"
machine="$TARGET_ARCHITECTURE"
else
machine=$(uname -m)
fi
case ${machine} in
armv7l|linux/arm/v7)
current_arch="armv7l"
oses="ubuntu debian debianslim centos leap tumbleweed"
os_family="linux"
;;
aarch64)
current_arch="aarch64"
oses="ubuntu debian debianslim ubi ubi-minimal centos leap tumbleweed"
os_family="linux"
;;
ppc64el|ppc64le)
current_arch="ppc64le"
oses="ubuntu debian debianslim ubi ubi-minimal centos leap tumbleweed"
os_family="linux"
;;
s390x)
current_arch="s390x"
oses="ubuntu debian debianslim ubi ubi-minimal clefos tumbleweed"
os_family="linux"
;;
amd64|x86_64)
case $(uname) in
MINGW64*|MSYS_NT*)
current_arch="x86_64"
# windowsservercore-1809 windowsservercore-1803 are not included as Adopt can't build them
oses="windowsservercore-ltsc2016"
# this variable will only be set when running under GitHub Actions
if [ -n "${BUILD_OS}" ]; then
case ${BUILD_OS} in
windows-2019)
oses="windowsservercore-1809 nanoserver-1809 windowsservercore-1909 nanoserver-1909 windowsservercore-ltsc2019"
;;
windows-2016)
oses="windowsservercore-ltsc2016"
;;
esac
fi
os_family="windows"
;;
*)
# shellcheck disable=SC2034 # used externally
current_arch="x86_64"
# shellcheck disable=SC2034 # used externally
oses="ubuntu alpine debian debianslim ubi ubi-minimal centos leap tumbleweed"
# shellcheck disable=SC2034 # used externally
os_family="linux"
;;
esac
;;
*)
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() {
# Check if the array has been defined. Array might be undefined if the
# corresponding build combination does not exist.
# Eg. jdk_openj9_10_releases_sums does not exist as we do not have any
# release builds for version 10 (Only nightly builds).
if ! declare -p "$1" 2>/dev/null; then
return;
fi
archsums="$(declare -p "$1")";
eval "declare -A sums=""${archsums#*=}";
for arch in "${!sums[@]}";
do
if [[ "${arch}" == version* ]] ; then
continue;
fi
# Arch is supported only if the shasum is not empty !
# shellcheck disable=SC2154,SC1083
shasum=$(sarray=$1[${arch}]; eval esum=\${"$sarray"}; echo "${esum}");
if [ -n "${shasum}" ]; then
echo "${arch} "
fi
done
}
# Check if the given VM is supported on the current architecture.
# This is based on the hotspot_shasums_latest.sh/openj9_shasums_latest.sh
function vm_supported_onarch() {
local vm=$1
local sums=$2
if [ -n "$3" ]; then
test_arch=$3;
else
test_arch=$(uname -m)
fi
suparches=$(get_arches "${sums}")
sup=$(echo "${suparches}" | grep "${test_arch}")
echo "${sup}"
}
function cleanup_images() {
# Delete any old containers that have exited.
docker rm "$(docker ps -a | grep -e 'Exited' | awk '{ print $1 }')" 2>/dev/null
docker container prune -f 2>/dev/null
# Delete any old images for our target_repo on localhost.
for image in $(docker images | grep -e 'adoptopenjdk' | awk -v OFS=':' '{ print $1, $2 }');
do
docker rmi -f "${image}";
done
# Remove any dangling images
docker image prune -f 2>/dev/null
}
function cleanup_manifest() {
# Remove any previously created manifest lists.
# Currently there is no way to do this using the tool.
rm -rf ~/.docker/manifests
}
# Check if a given docker image exists on the server.
# This script errors out if the image does not exist.
function check_image() {
local img=$1
docker pull "${img}" >/dev/null
ret=$?
echo ${ret}
}
# Parse the openj9.config / hotspot.config file for an entry as specified by $4
# $1 = VM
# $2 = Version
# $3 = Package
# $4 = OS
# $5 = String to look for.
function parse_vm_entry() {
entry=$( < config/"$1".config grep -B 4 -E "$2\/$3\/$4$|$2\/$3\/windows\/$4$" | grep "$5" | sed "s/$5 //")
echo "${entry}"
}
# Parse the openj9.config / hotspot.config file for the supported OSes
# $1 = VM
function parse_os_entry() {
entry=$( < config/"$1".config grep "^OS:" | sed "s/OS: //")
echo "${entry}"
}
# Read the tags file and parse the specific tag.
# $1 = OS
# $2 = Package
# $3 = Build (releases / nightly)
# $4 = Type (full / slim)
function parse_tag_entry() {
tag="$1-$2-$3-$4-tags:"
entry=$( < "${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 docker manifest 2>/dev/null; then
echo "INFO: Docker manifest found at $(command -v docker)"
manifest_tool=$(command -v docker)
else
if [ ! -f "${manifest_tool}" ]; then
echo
echo "ERROR: Docker with manifest support not found at path ${manifest_tool}"
exit 1
fi
fi
}
# Build valid image tags using the tags.config file as the base
function build_tags() {
local vm=$1; shift
local ver=$1; shift;
local pkg=$1; shift;
local rel=$1; shift;
local os=$1; shift;
local build=$1; shift;
local rawtags=$*
local tmpfile=raw_arch_tags.$$.tmp
# For jre builds, replace the version tag to distinguish it from the jdk
if [ "${pkg}" == "jre" ]; then
rel="${rel//jdk/jre}"
fi
# Get the list of supported arches for this vm / ver /os combo
arches=$(parse_vm_entry "${vm}" "${ver}" "${pkg}" "${os}" "Architectures:")
# Replace the proper version string in the tags
rtags=$(echo "${rawtags}" | sed "s/{{ JDK_${build}_VER }}/${rel}/gI; s/{{ OS }}/${os}/gI;");
echo "${rtags}" | sed "s/{{ *ARCH *}}/{{ARCH}}/" |
# Separate the arch and the generic alias tags
awk '{ a=0; n=0;
for (i=1; i<=NF; i++) {
if (match($i, "ARCH") > 0) {
atags[a++]=sprintf(" %s", $i);
} else {
natags[n++]=sprintf(" %s", $i);
}
}
} END {
printf("arch_tags: "); for (key in atags) { printf"%s ", atags[key] }; printf"\n";
printf("tag_aliases: "); for (key in natags) { printf"%s ", natags[key] }; printf"\n";
}' > ${tmpfile}
# shellcheck disable=SC2034 # used externally
tag_aliases=$( < "${tmpfile}" grep "^tag_aliases:" | sed "s/tag_aliases: //")
raw_arch_tags=$( < "${tmpfile}" grep "^arch_tags:" | sed "s/arch_tags: //")
arch_tags=""
# Iterate through the arch tags and expand to add the supported arches.
for tag in ${raw_arch_tags}
do
for arch in ${arches}
do
windows_pat="windows.*"
if [[ "$arch" =~ ${windows_pat} ]]; then
arch="x86_64"
fi
# Check if all the supported arches are available for this build.
# shellcheck disable=SC2154 #declared externally
supported=$(vm_supported_onarch "${vm}" "${shasums}" "${arch}")
if [ -z "${supported}" ]; then
continue;
fi
# shellcheck disable=SC2001
atag=$(echo "${tag}" | sed "s/{{ARCH}}/${arch}"/g)
arch_tags="${arch_tags} ${atag}"
done
done
rm -f ${tmpfile}
}
# Build the URL using adoptopenjdk.net v2 api based on the given parameters
# request_type = info / binary
# release_type = releases / nightly
# url_impl = hotspot / openj9
# url_arch = aarch64 / ppc64le / s390x / x64
# url_pkg = jdk / jre
# url_rel = latest / ${version}
function get_v2_url() {
local request_type=$1
local release_type=$2
local url_impl=$3
local url_pkg=$4
local url_rel=$5
local url_arch=$6
local url_heapsize=normal
local url_version=openjdk${version}
baseurl="https://api.adoptopenjdk.net/v2/${request_type}/${release_type}/${url_version}"
specifiers="openjdk_impl=${url_impl}&type=${url_pkg}&release=${url_rel}&heap_size=${url_heapsize}"
windows_pat="windows.*"
if [ -n "${url_arch}" ]; then
if [[ "${url_arch}" =~ ${windows_pat} ]]; then
specifiers="${specifiers}&arch=x64&os=windows"
else
specifiers="${specifiers}&os=linux&arch=${url_arch}"
fi
else
specifiers="${specifiers}&os=linux"
fi
echo "${baseurl}?${specifiers}"
}
# Get the binary github link for a release given a V2 API URL
function get_v2_binary_url() {
local v2_url=$1
local info_file=/tmp/info_$$.json
if ! curl -Lso ${info_file} "${v2_url}" || [ ! -s ${info_file} ]; then
rm -f ${info_file}
return;
fi
< ${info_file} grep "binary_link" | awk -F '"' '{ print $4 }'
rm -f ${info_file}
}
# Get the installer github link for a release given a V2 API URL
function get_v2_installer_url() {
local v2_url=$1
local info_file=/tmp/info_$$.json
if ! curl -Lso ${info_file} "${v2_url}" || [ ! -s ${info_file} ]; then
rm -f ${info_file}
return;
fi
< ${info_file} grep "installer_link" | awk -F '"' '{ print $4 }'
rm -f ${info_file}
}
# Build the URL using adoptopenjdk.net v3 api based on the given parameters
# request_type = feature_releases
# release_type = ga / ea
# url_impl = hotspot / openj9
# url_arch = aarch64 / ppc64le / s390x / x64
# url_pkg = jdk / jre
# https://api.adoptopenjdk.net/v3/assets/feature_releases/11/ga?page=0&page_size=1&release_type=ga&sort_order=DESC&vendor=adoptopenjdk&jvm_impl=openj9&heap_size=normal&architecture=x64&os=linux&image_type=jdk
function get_v3_url() {
local request_type=$1
local release_type=$2
local url_impl=$3
local url_pkg=$4
local url_arch=$5
local url_heapsize="normal"
if [ "${release_type}" == "releases" ]; then
rel_type="ga"
else
rel_type="ea"
fi
baseurl="https://api.adoptopenjdk.net/v3/assets/${request_type}/${version}/${rel_type}"
specifiers="page=0&page_size=1&sort_order=DESC&vendor=adoptopenjdk"
specifiers="${specifiers}&jvm_impl=${url_impl}&image_type=${url_pkg}&heap_size=${url_heapsize}"
windows_pat="windows.*"
if [ -n "${url_arch}" ]; then
if [[ "${url_arch}" =~ ${windows_pat} ]]; then
specifiers="${specifiers}&os=windows&architecture=x64"
else
specifiers="${specifiers}&os=linux&architecture=${url_arch}"
fi
else
specifiers="${specifiers}&os=linux"
fi
echo "${baseurl}?${specifiers}"
}
# Get the binary github link for a release given a V3 API URL
function get_v3_binary_url() {
local v3_url=$1
local info_file=/tmp/info_$$.json
if ! curl -Lso ${info_file} "${v3_url}" || [ ! -s ${info_file} ]; then
rm -f ${info_file}
return;
fi
python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['package']['link'])" < "${info_file}"
rm -f ${info_file}
}
# Get the installer github link for a release given a V3 API URL
function get_v3_installer_url() {
local v3_url=$1
local info_file=/tmp/info_$$.json
if ! curl -Lso "${info_file}" "${v3_url}" || [ ! -s ${info_file} ]; then
rm -f ${info_file}
return;
fi
python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['installer']['link'])" < "${info_file}"
rm -f ${info_file}
}
# Get the short build version from the full version for this specific arch
# $1 = full version
function get_nightly_short_version() {
local arch_build=$1
local arch_full_version=$2
if [ "${arch_build}" = "nightly" ]; then
# Remove date and time at the end of full_version for nightly builds.
# Handle both the old and new date-time formats used by the Adopt build system.
# Older date-time format - 201809270034
# shellcheck disable=SC2001
arch_version=$(echo "${arch_full_version}" | sed 's/-[0-9]\{4\}[0-9]\{2\}[0-9]\{2\}[0-9]\{4\}$//')
# New date-time format - 2018-09-27-00-34
# shellcheck disable=SC2001
arch_version=$(echo "${arch_version}" | sed 's/-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}$//')
else
arch_version=${arch_full_version}
fi
echo "${arch_version}"
}
# Get the shasums for the given specific build and arch combination.
function get_sums_for_build_arch() {
local ver=$1
local vm=$2
local pkg=$3
local build=$4
local arch=$5
case ${arch} in
armv7l)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" arm);
;;
aarch64)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" aarch64);
;;
ppc64le)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" ppc64le);
;;
s390x)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" s390x);
;;
x86_64)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" x64);
;;
windows-amd|windows-nano)
LATEST_URL=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}" windows);
;;
*)
echo "Unsupported arch: ${arch}"
esac
while :
do
shasum_file="${arch}_${build}_latest"
# Bad builds cause the latest url to return an empty file or sometimes curl fails
if ! curl -Lso "${shasum_file}" "${LATEST_URL}" || [ ! -s "${shasum_file}" ]; then
echo "Latest url not available at url: ${LATEST_URL}"
break;
fi
# Even if the file is not empty, it might just say "No matches"
availability=$(grep -e "No matches" -e "Not found" "${shasum_file}");
# Print the arch and the corresponding shasums to the vm output file
if [ -z "${availability}" ]; then
# If there are multiple builds for a single version, then pick the latest one.
if [ "${arch}" == "windows-amd" ]; then
shasums_url=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['installer']['checksum_link'])" < "${shasum_file}")
if [ -z "$shasums_url" ]; then
shasums_url=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['package']['checksum_link'])" < "${shasum_file}")
fi
else
shasums_url=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['binaries'][0]['package']['checksum_link'])" < "${shasum_file}")
fi
shasum=$(curl -Ls "${shasums_url}" | sed -e 's/<[^>]*>//g' | awk '{ print $1 }');
# Sometimes shasum files are missing, check for error and do not print on error.
shasum_available=$(echo "${shasum}" | grep -e "No" -e "Not");
if [ -n "${shasum_available}" ]; then
echo "shasum file not available at url: ${shasums_url}"
break;
fi
# Get the release version for this arch from the info file
arch_build_version=$(python3 -c "import sys, json; print(json.load(sys.stdin)[0]['release_name'])" < "${shasum_file}")
# For nightly builds get the short version without the date/time stamp
arch_build_version=$(get_nightly_short_version "${build}" "${arch_build_version}")
# We compare the JDK version info separately from the VM type info because we may have dot releases
arch_build_base_version=$(echo "${arch_build_version}" | cut -d_ -f1)
arch_build_vm_type=$(echo "${arch_build_version}" | cut -s -d_ -f2)
full_version_base_version=$(echo "${full_version}" | cut -d_ -f1)
full_version_vm_type=$(echo "${full_version}" | cut -s -d_ -f2)
# If the latest for the current arch does not match with the latest for the parent arch,
# then skip this arch.
# Parent version in this case would be the "full_version" from function get_sums_for_build
# The parent version will automatically be the latest for all arches as returned by the v2 API
if [[ "${arch_build_base_version}" != "${full_version_base_version}"* || "${arch_build_vm_type}" != "${full_version_vm_type}" ]]; then
echo "Parent version not matching for arch ${arch}: ${arch_build_version}, ${full_version}"
break;
fi
# Get the build date for this arch tarball
arch_last_build_date="$(curl -Lv "${shasums_url}" 2>&1 | grep "Last-Modified" | sed 's/< Last-Modified: //')"
# Convert to time since 1-1-1970
arch_last_build_time="$(date --date "${arch_last_build_date}" +%s)"
# Only print the entry if the shasum is not empty
if [ -n "${shasum}" ]; then
printf "\t[version-%s]=\"%s\"\n" "${arch}" "${arch_build_version}" >> "${ofile_sums}"
printf "\t[version-%s]=\"%s\"\n" "${arch}" "${arch_build_version}" >> "${ofile_build_time}"
printf "\t[%s]=\"%s\"\n" "${arch}" "${shasum}" >> "${ofile_sums}"
printf "\t[%s]=\"%s\"\n" "${arch}" "${arch_last_build_time}" >> "${ofile_build_time}"
fi
fi
break;
done
rm -f "${shasum_file}"
}
# Get shasums for the build and arch combination given
# If no arch given, generate for all valid arches
function get_sums_for_build() {
local ver=$1
local vm=$2
local pkg=$3
local build=$4
local arch=$5
info_url=$(get_v3_url feature_releases "${build}" "${vm}" "${pkg}");
# Repeated requests from a script triggers a error threshold on adoptopenjdk.net
sleep 1;
info=$(curl -Ls "${info_url}")
err=$(echo "${info}" | grep -e "Error" -e "No matches" -e "Not found")
if [ -n "${err}" ]; then
return;
fi
full_version=$(echo "${info}" | python3 -c "import sys, json; print(json.load(sys.stdin)[0]['release_name'])")
full_version=$(get_nightly_short_version "${build}" "${full_version}")
# Declare the array with the proper name for shasums and write to the vm output file.
printf "declare -A %s_%s_%s_%s_sums=(\n" "${pkg}" "${vm}" "${ver}" "${build}" >> "${ofile_sums}"
# We have another array for storing the last build time for each arch
printf "declare -A %s_%s_%s_%s_build_time=(\n" "${pkg}" "${vm}" "${ver}" "${build}" >> "${ofile_build_time}"
# Capture the full version according to adoptopenjdk
printf "\t[version]=\"%s\"\n" "${full_version}" >> "${ofile_sums}"
printf "\t[version]=\"%s\"\n" "${full_version}" >> "${ofile_build_time}"
if [ -n "${arch}" ]; then
get_sums_for_build_arch "${ver}" "${vm}" "${pkg}" "${build}" "${arch}"
else
for arch in ${all_arches}
do
get_sums_for_build_arch "${ver}" "${vm}" "${pkg}" "${build}" "${arch}"
done
fi
printf ")\n" >> "${ofile_sums}"
printf ")\n" >> "${ofile_build_time}"
echo
echo "sha256sums for the version ${full_version} for build type \"${build}\" is now available in ${ofile_sums}"
echo
}
# get sha256sums for the specific builds and arches given.
# If no build or arch specified, do it for all valid ones.
function get_shasums() {
local ver=$1
local vm=$2
local pkg=$3
local build=$4
local arch=$5
local ofile_sums="${vm}_shasums_latest.sh"
local ofile_build_time="${vm}_build_time_latest.sh"
# Dont build the shasums array it already exists for the Ver/VM/Pkg/Build combination
if [ -f "${ofile_sums}" ]; then
# shellcheck disable=SC1090
source ./"${vm}"_shasums_latest.sh
sums="${pkg}_${vm}_${ver}_${build}_sums"
# File exists, which means shasums for the VM exists.
# Now check for the specific Ver/VM/Pg/Build combo
suparches=$(get_arches "${sums}")
if [ -n "${suparches}" ]; then
return;
fi
fi
if [ -n "${build}" ]; then
get_sums_for_build "${ver}" "${vm}" "${pkg}" "${build}" "${arch}"
else
for build in ${supported_builds}
do
get_sums_for_build "${ver}" "${vm}" "${pkg}" "${build}" "${arch}"
done
fi
chmod +x "${ofile_sums}" "${ofile_build_time}"
}