@Override
 public void preInstall() {
   resolver = Entities.newDownloader(this);
   String subpath = entity.getConfig(BrooklynNode.SUBPATH_IN_ARCHIVE);
   if (subpath == null) {
     // assume the dir name is `basename-VERSION` where download link is
     // `basename-VERSION-dist.tar.gz`
     String uploadUrl = entity.getConfig(BrooklynNode.DISTRO_UPLOAD_URL);
     String origDownloadName = uploadUrl;
     if (origDownloadName == null)
       origDownloadName = entity.getAttribute(BrooklynNode.DOWNLOAD_URL);
     if (origDownloadName != null) {
       // BasicDownloadResolver makes it crazy hard to get the template-evaluated value of
       // DOWNLOAD_URL
       origDownloadName =
           DownloadSubstituters.substitute(
               origDownloadName, DownloadSubstituters.getBasicEntitySubstitutions(this));
       origDownloadName = Urls.decode(origDownloadName);
       origDownloadName = Urls.getBasename(origDownloadName);
       String downloadName = origDownloadName;
       downloadName = Strings.removeFromEnd(downloadName, ".tar.gz");
       downloadName = Strings.removeFromEnd(downloadName, ".tgz");
       downloadName = Strings.removeFromEnd(downloadName, ".zip");
       if (!downloadName.equals(origDownloadName)) {
         downloadName = Strings.removeFromEnd(downloadName, "-dist");
         subpath = downloadName;
       }
     }
   }
   if (subpath == null) subpath = format("brooklyn-dist-%s", getVersion());
   setExpandedInstallDir(
       Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(subpath)));
 }