3 # see https://api.adoptopenjdk.net/swagger-ui/#/Binary/get_v3_binary_latest__feature_version___release_type___os___arch___image_type___jvm_impl___heap_size___vendor_
7 ### This is a script to download and update the JREs used in the windows, mac (and maybe linux) installations, and update channel
8 ### It creates a structure with
9 ### ./jre-VERSION-OS-ARCH/jre/...
10 ### as used by getdown
12 ### ./tgz/jre-VERSION-OS-ARCH.tgz
13 ### which is an archive of the _contents_ of ./jre-VERSION-OS-ARCH/jre/ and used by install4j for the installer
15 BASE=https://api.adoptopenjdk.net/v3/binary/latest
24 # unzip-strip from https://superuser.com/questions/518347/equivalent-to-tars-strip-components-1-in-unzip
28 local temp=$(mktemp -d) && unzip -qq -d "$temp" "$zip" && mkdir -p "$dest" &&
29 shopt -s dotglob && local f=("$temp"/*) &&
30 if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then
31 mv "$temp"/*/* "$dest"
34 fi && rmdir "$temp"/* "$temp"
37 for FEATURE_VERSION in 8 11 12 13; do
39 #for OS in linux mac windows; do
41 #for ARCH in aarch64 arm x32 x64; do
42 NAME="${IMAGE_TYPE}-${FEATURE_VERSION}-${OS}-${ARCH}"
44 echo "* Downloading ${TARFILE}"
45 URL="${BASE}/${FEATURE_VERSION}/${RELEASE_TYPE}/${OS}/${ARCH}/${IMAGE_TYPE}/${JVM_IMPL}/${HEAP_SIZE}/${VENDOR}"
46 wget -q -O "${TARFILE}" "${URL}"
47 if [ "$?" != 0 ]; then
48 echo "- No ${IMAGE_TYPE}-${FEATURE_VERSION} download for ${OS}-${ARCH} '${URL}'"
52 echo "Unpacking ${TARFILE}"
53 JREDIR="${NAME}/${IMAGE_TYPE}"
54 [ x$NAME != x -a -e "${JREDIR}" ] && $RM -rf "${JREDIR}"
56 if [ x$OS = xwindows ]; then
58 unzip-strip "${TARFILE}" "${JREDIR}"
62 tar --strip-components=1 -C "${JREDIR}" -zxf "${TARFILE}"
65 if [ "$RET" != 0 ]; then
66 echo "Error unpacking ${TARFILE}"