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
25 STRIP_MAC_APP_BUNDLING=false
26 CREATE_ARCHIVES="zip tgz"
27 # need zip with top-level jre dir for getdown updates. need tgz without top-level jre dir for install4j bundling
31 # unzip-strip from https://superuser.com/questions/518347/equivalent-to-tars-strip-components-1-in-unzip
35 local temp=$(mktemp -d) && $UNZIP -qq -d "$temp" "$zip" && mkdir -p "$dest" &&
36 shopt -s dotglob && local f=("$temp"/*) &&
37 if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then
38 mv "$temp"/*/* "$dest"
41 fi && rmdir "$temp"/* "$temp"
44 for FEATURE_VERSION in 8 11; do
45 for OS in linux mac windows; do
46 for ARCH in x64 x32 arm; do
47 #for ARCH in aarch64 arm x32 x64; do
48 NAME="${IMAGE_TYPE}-${FEATURE_VERSION}-${OS}-${ARCH}"
50 echo "* Downloading ${TARFILE}"
51 URL="${BASE}/${FEATURE_VERSION}/${RELEASE_TYPE}/${OS}/${ARCH}/${IMAGE_TYPE}/${JVM_IMPL}/${HEAP_SIZE}/${VENDOR}"
52 wget -q -O "${TARFILE}" "${URL}"
53 if [ "$?" != 0 ]; then
54 echo "- No ${IMAGE_TYPE}-${FEATURE_VERSION} download for ${OS}-${ARCH} '${URL}'"
58 echo "Unpacking ${TARFILE}"
59 JREDIR="${NAME}/${IMAGE_TYPE}"
60 [ x$NAME != x -a -e "${JREDIR}" ] && $RM -rf "${JREDIR}"
62 if [ x$OS = xwindows ]; then
64 unzip-strip "${TARFILE}" "${JREDIR}"
68 if [ x$OS = xmac -a x$STRIP_MAC_APP_BUNDLING = xtrue ]; then
69 $TAR --strip-components=3 -C "${JREDIR}" -zxf "${TARFILE}" "*/Contents/Home"
72 $TAR --strip-components=1 -C "${JREDIR}" -zxf "${TARFILE}"
76 if [ "$RET" != 0 ]; then
77 echo "Error unpacking ${TARFILE}"
81 if [ \! -z "$CREATE_ARCHIVES" ]; then
82 for CREATEARCHIVE in ${CREATE_ARCHIVES}; do
83 ARCHIVEDIR=$CREATEARCHIVE
84 case $CREATEARCHIVE in
87 echo "Creating ${NAME}.${EXT} for getdown updates"
88 [ \! -d ${ARCHIVEDIR} ] && mkdir -p "${ARCHIVEDIR}"
89 ABSARCHIVEDIR="${PWD}/$ARCHIVEDIR"
90 ZIPFILE="${ABSARCHIVEDIR}/${NAME}.${CREATEARCHIVE}"
91 [ -e "${ZIPFILE}" ] && $RM "${ZIPFILE}"
93 $ZIP -X -r "${ZIPFILE}" "${IMAGE_TYPE}"
98 echo "Creating ${NAME}.${EXT} for install4j bundling"
99 [ \! -d ${ARCHIVEDIR} ] && mkdir -p "${ARCHIVEDIR}"
100 $TAR -C "${JREDIR}" -zcf "${ARCHIVEDIR}/${NAME}.${EXT}" .
103 echo "Archiving as '${CREATEARCHIVE}' file not supported"