JAL-3130 Improved locations of AdoptOpenJDK JRE downloads \(locally and on build...
authorBen Soares <bsoares@dundee.ac.uk>
Thu, 23 Jan 2020 17:05:23 +0000 (17:05 +0000)
committerBen Soares <bsoares@dundee.ac.uk>
Thu, 23 Jan 2020 17:05:23 +0000 (17:05 +0000)
build.gradle
gradle.properties
utils/install4j/download_jres.sh [new file with mode: 0755]
utils/install4j/install4j8_template.install4j

index 916d1d0..a6fcf8b 100644 (file)
@@ -292,10 +292,16 @@ ext {
   // for install4j
   JAVA_MIN_VERSION = JAVA_VERSION
   JAVA_MAX_VERSION = JAVA_VERSION
-  macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
-  macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
-  windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
-  windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
+  def jreInstallsDir = string(jre_installs_dir)
+  if (jreInstallsDir.startsWith("~/")) {
+    jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
+  }
+  macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
+  macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
+  windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
+  windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
+  linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
+  linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
   install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
   install4jConfFileName = string("jalview-install4j-conf.install4j")
   install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
@@ -715,7 +721,8 @@ task convertBuildingMD(type: Exec) {
   }
 
   def hostname = "hostname".execute().text.trim()
-  if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
+  def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
+  if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
     pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
   }
 
@@ -1289,6 +1296,7 @@ task installers(type: com.install4j.gradle.Install4jTask) {
   }
   def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
 
+  println("WINDOWS_JAVA_VM_TGZ=${windowsJavaVMTgz}")
   variables = [
     'OSX_KEYSTORE': OSX_KEYSTORE,
     'JSIGN_SH': JSIGN_SH,
@@ -1301,9 +1309,11 @@ task installers(type: com.install4j.gradle.Install4jTask) {
     'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
     'VERSION': JALVIEW_VERSION,
     'MACOS_JAVA_VM_DIR': macosJavaVMDir,
-    'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
     'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
+    'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
+    'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
     'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
+    'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
     'COPYRIGHT_MESSAGE': install4j_copyright_message,
     'MACOS_BUNDLE_ID': install4j_macOS_bundle_id,
     'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
index 2bac743..c5deb83 100644 (file)
@@ -100,13 +100,7 @@ getdown_alt_java11_min_version = 11000000
 getdown_alt_java11_max_version =
 #getdown_alt_java11_txt_multi_java_location = [windows-amd64] /getdown/jre/windows-jre11.jar,[linux-amd64] /getdown/jre/linux-jre11.tgz,[mac os x] /getdown/jre/macos-jre11.tgz
 #getdown_alt_java8_txt_multi_java_location = [windows-amd64] /getdown/jre/windows-jre1.8.tgz,[linux-amd64] /getdown/jre/linux-jre1.8.tgz,[mac os x] /getdown/jre/macos-jre1.8.tgz
-JRE_installs = /Users/bsoares/Java/installs
-Windows_JRE8 = OpenJDK8U-jdk_x64_windows_hotspot_8u202b08/jdk8u202-b08
-Mac_JRE8 = OpenJDK8U-jre_x64_mac_hotspot_8u202b08/jdk8u202-b08-jre/Contents/Home
-Linux_JRE8 = OpenJDK8U-jre_x64_linux_hotspot_8u202b08/jdk8u202-b08-jre
-Windows_JRE11 = OpenJDK11-jre_x64_windows_hotspot_11_28/jdk-11+28-jre
-Mac_JRE11 = OpenJDK11-jre_x64_mac_hotspot_11_28/jdk-11+28-jre/Contents/Home
-Linux_JRE11 = OpenJDK11-jre_x64_linux_hotspot_11_28/jdk-11+28-jre
+jre_installs_dir = ~/buildtools/jre
 
 j8libDir = j8lib
 j11libDir = j11lib
diff --git a/utils/install4j/download_jres.sh b/utils/install4j/download_jres.sh
new file mode 100755 (executable)
index 0000000..0a1cf9f
--- /dev/null
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+
+# 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_
+
+
+### bs 2020-01-22
+### This is a script to download and update the JREs used in the windows, mac (and maybe linux) installations, and update channel
+### It creates a structure with
+### ./jre-VERSION-OS-ARCH/jre/...
+### as used by getdown
+### and
+### ./tgz/jre-VERSION-OS-ARCH.tgz
+### which is an archive of the _contents_ of ./jre-VERSION-OS-ARCH/jre/ and used by install4j for the installer
+
+BASE=https://api.adoptopenjdk.net/v3/binary/latest
+RELEASE_TYPE=ga
+JVM_IMPL=hotspot
+HEAP_SIZE=normal
+VENDOR=adoptopenjdk
+IMAGE_TYPE=jre
+
+RM=/bin/rm
+
+# unzip-strip from https://superuser.com/questions/518347/equivalent-to-tars-strip-components-1-in-unzip
+unzip-strip() (
+  local zip=$1
+  local dest=${2:-.}
+  local temp=$(mktemp -d) && unzip -qq -d "$temp" "$zip" && mkdir -p "$dest" &&
+  shopt -s dotglob && local f=("$temp"/*) &&
+  if (( ${#f[@]} == 1 )) && [[ -d "${f[0]}" ]] ; then
+    mv "$temp"/*/* "$dest"
+  else
+    mv "$temp"/* "$dest"
+  fi && rmdir "$temp"/* "$temp"
+)
+
+for FEATURE_VERSION in 8 11; do
+  for OS in linux mac windows; do
+    for ARCH in x64 x32 arm; do
+      #for ARCH in aarch64 arm x32 x64; do
+      NAME="${IMAGE_TYPE}-${FEATURE_VERSION}-${OS}-${ARCH}"
+      TARFILE="${NAME}.tgz"
+      echo "* Downloading ${TARFILE}"
+      URL="${BASE}/${FEATURE_VERSION}/${RELEASE_TYPE}/${OS}/${ARCH}/${IMAGE_TYPE}/${JVM_IMPL}/${HEAP_SIZE}/${VENDOR}"
+      wget -q -O "${TARFILE}" "${URL}"
+      if [ "$?" != 0 ]; then
+        echo "- No ${IMAGE_TYPE}-${FEATURE_VERSION} download for ${OS}-${ARCH} '${URL}'"
+        $RM -f "${TARFILE}"
+        continue;
+      fi
+      echo "Unpacking ${TARFILE}"
+      JREDIR="${NAME}/jre"
+      [ x$NAME != x -a -e "${JREDIR}" ] && $RM -rf "${JREDIR}"
+      mkdir -p "${JREDIR}"
+      if [ x$OS = xwindows ]; then
+        echo "using unzip"
+        unzip-strip "${TARFILE}" "${JREDIR}"
+        RET=$?
+      else
+        echo "using tar"
+        tar --strip-components=1 -C "${JREDIR}" -zxf "${TARFILE}"
+        RET=$?
+      fi
+      if [ "$RET" != 0 ]; then
+        echo "Error unpacking ${TARFILE}"
+        exit 1
+      fi
+      $RM "${TARFILE}"
+      echo "Creating .tar.gz for install4j bundling and updates"
+      TGZDIR=tgz
+      mkdir -p "${TGZDIR}"
+      tar -C "${JREDIR}" -zcf "${TGZDIR}/${NAME}.tar.gz" .
+    done
+  done
+done
+
index 3d39720..6508ed7 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<install4j version="8.0.3" transformSequenceNumber="8">
+<install4j version="8.0.4" transformSequenceNumber="8">
   <directoryPresets config="." />
-  <application name="Jalview" applicationId="6595-2347-1923-0725" mediaDir="../../build/install4j" lzmaCompression="true" shortName="Jalview" publisher="University of Dundee" publisherWeb="https://www.jalview.org/" version="${compiler:JALVIEW_VERSION}" allPathsRelative="true" macVolumeId="5aac4968c304f65" javaMinVersion="${compiler:JAVA_MIN_VERSION}" javaMaxVersion="9999999999${compiler:JAVA_MAX_VERSION}" allowBetaVM="true" jdkMode="jdk" jdkName="JDK 11.0">
+  <application name="Jalview" applicationId="6595-2347-1923-0725" mediaDir="${compiler:BUILD_DIR}" lzmaCompression="true" shortName="Jalview" publisher="University of Dundee" publisherWeb="https://www.jalview.org/" version="${compiler:JALVIEW_VERSION}" allPathsRelative="true" macVolumeId="5aac4968c304f65" javaMinVersion="${compiler:JAVA_MIN_VERSION}" javaMaxVersion="9999999999${compiler:JAVA_MAX_VERSION}" allowBetaVM="true" jdkMode="jdk" jdkName="JDK 11.0">
     <searchSequence>
       <directory location="${compiler:JRE_DIR}" />
       <registry />
       <variable name="JAVA_VERSION" value="11" />
       <variable name="JAVA_INTEGER_VERSION" value="11" />
       <variable name="VERSION" value="DEVELOPMENT" />
-      <variable name="MACOS_JAVA_VM_DIR" value="~/buildtools/jre/openjdk-java_vm/getdown/macos-jre11/jre" />
-      <variable name="MACOS_JAVA_VM_TGZ" value="~/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre11.tar.gz" />
-      <variable name="WINDOWS_JAVA_VM_DIR" value="~/buildtools/jre/openjdk-java_vm/getdown/windows-jre11/jre" />
-      <variable name="WINDOWS_JAVA_VM_TGZ" value="~/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre11.tar.gz" />
+      <variable name="MACOS_JAVA_VM_DIR" value="~/buildtools/jre/jre-${compiler:JAVA_INTEGER_VERSION}-mac-x64/jre" />
+      <variable name="WINDOWS_JAVA_VM_DIR" value="~/buildtools/jre/jre-${compiler:JAVA_INTEGER_VERSION}-windows-x64/jre" />
+      <variable name="LINUX_JAVA_VM_DIR" value="~/buildtools/jre/jre-${compiler:JAVA_INTEGER_VERSION}-linux-x64/jre" />
+      <variable name="MACOS_JAVA_VM_TGZ" value="~/buildtools/jre/tgz/jre-${compiler:JAVA_INTEGER_VERSION}-mac-x64.tar.gz" />
+      <variable name="WINDOWS_JAVA_VM_TGZ" value="~/buildtools/jre/tgz/jre-${compiler:JAVA_INTEGER_VERSION}-windows-x64.tar.gz" />
+      <variable name="LINUX_JAVA_VM_TGZ" value="~/buildtools/jre/tgz/jre-${compiler:JAVA_INTEGER_VERSION}-linux-x64.tar.gz" />
       <variable name="COPYRIGHT_MESSAGE" value="..." />
       <variable name="MACOS_BUNDLE_ID" value="org.jalview.jalview-desktop" />
       <variable name="GETDOWN_RESOURCE_DIR" value="resource" />
@@ -29,6 +31,7 @@
       <variable name="GETDOWN_ALT_DIR" value="alt" />
       <variable name="GETDOWN_INSTALL_DIR" value="install" />
       <variable name="INFO_PLIST_FILE_ASSOCIATIONS_FILE" value="file_associations_auto-Info_plist.xml" />
+      <variable name="BUILD_DIR" value="../../build/install4j" />
     </variables>
     <codeSigning macEnabled="true" macPkcs12File="${compiler:OSX_KEYSTORE}" />
   </application>
@@ -1166,6 +1169,7 @@ return console.askYesNo(message, true);
         <entry filesetId="1873" />
         <entry filesetId="2105" />
       </exclude>
+      <jreBundle jreBundleSource="preCreated" includedJre="${compiler:LINUX_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixInstaller>
     <unixArchive name="Unix .tar.gz Archive" id="1596" mediaFileName="${compiler:sys.shortName}-${compiler:JALVIEW_VERSION}-${compiler:sys.platform}-java_${compiler:JAVA_INTEGER_VERSION}">
       <excludedComponents>
@@ -1181,6 +1185,7 @@ return console.askYesNo(message, true);
         <entry filesetId="882" />
         <entry filesetId="1873" />
       </exclude>
+      <jreBundle jreBundleSource="preCreated" includedJre="${compiler:LINUX_JAVA_VM_TGZ}" manualJreEntry="true" />
     </unixArchive>
   </mediaSets>
   <buildIds>