/** * Given a tgz/zip file, extracts it to the given target directory, if necessary. * * <p> * This method is a convenience method designed for installing a binary package to a location * that supports upgrade and downgrade. Specifically, * * <ul> * <li>If the target directory doesn't exist {@linkplain #mkdirs() it will be created}. * <li>The timestamp of the archive is left in the installation directory upon extraction. * <li>If the timestamp left in the directory does not match the timestamp of the current archive file, * the directory contents will be discarded and the archive file will be re-extracted. * <li>If the connection is refused but the target directory already exists, it is left alone. * </ul> * * @param archive * The resource that represents the tgz/zip file. This URL must support the {@code Last-Modified} header. * (For example, you could use {@link ClassLoader#getResource}.) * @param listener * If non-null, a message will be printed to this listener once this method decides to * extract an archive, or if there is any issue. * @param message a message to be printed in case extraction will proceed. * @return * true if the archive was extracted. false if the extraction was skipped because the target directory * was considered up to date. * @since 1.299 */ public boolean installIfNecessaryFrom(@Nonnull URL archive, @CheckForNull TaskListener listener, @Nonnull String message) throws IOException, InterruptedException { return installIfNecessaryFrom(archive, listener, message, MAX_REDIRECTS); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
String location = httpCon.getHeaderField("Location"); listener.getLogger().println("Following redirect " + archive.toExternalForm() + " -> " + location); return installIfNecessaryFrom(getUrlFactory().newURL(location), listener, message, maxRedirects - 1); } else { listener.getLogger().println("Skipping installation of " + archive + " to " + remote + " due to too many redirects.");
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if (inst instanceof NodeSpecific) { inst = (Installable) ((NodeSpecific) inst).forNode(node, log); } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public Boolean invoke(File f, VirtualChannel channel) throws InterruptedException, IOException { String msg = Messages.DOWNLOADING_SDK_FROM(downloadUrl); return toolsSubdir.installIfNecessaryFrom(downloadUrl, listener, msg); } private static final long serialVersionUID = 1L;
/** * Given a tgz/zip file, extracts it to the given target directory, if necessary. * * <p> * This method is a convenience method designed for installing a binary package to a location * that supports upgrade and downgrade. Specifically, * * <ul> * <li>If the target directory doesn't exist {@linkplain #mkdirs() it will be created}. * <li>The timestamp of the archive is left in the installation directory upon extraction. * <li>If the timestamp left in the directory does not match the timestamp of the current archive file, * the directory contents will be discarded and the archive file will be re-extracted. * <li>If the connection is refused but the target directory already exists, it is left alone. * </ul> * * @param archive * The resource that represents the tgz/zip file. This URL must support the {@code Last-Modified} header. * (For example, you could use {@link ClassLoader#getResource}.) * @param listener * If non-null, a message will be printed to this listener once this method decides to * extract an archive, or if there is any issue. * @param message a message to be printed in case extraction will proceed. * @return * true if the archive was extracted. false if the extraction was skipped because the target directory * was considered up to date. * @since 1.299 */ public boolean installIfNecessaryFrom(@Nonnull URL archive, @CheckForNull TaskListener listener, @Nonnull String message) throws IOException, InterruptedException { return installIfNecessaryFrom(archive, listener, message, MAX_REDIRECTS); }
private boolean install(final FilePath root, TaskListener listener) throws IOException, InterruptedException { assert root != null; if (listener == null) { listener = TaskListener.NULL; } String resource = BUNDLE_ARCHIVE; URL url = SlaveBundleInstaller.class.getResource(resource); if (url == null) { throw new RuntimeException("Unable to install Maven 3 slave " + "bundle; missing resource: " + resource); } FilePath dir = new FilePath(root, BASE_PATH); dir.mkdirs(); log.debug("Maven slave bundle installation directory: {}", dir); return dir.installIfNecessaryFrom(url, listener, "Installing: " + resource); }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath dir = preferredLocation(tool, node); if (dir.installIfNecessaryFrom(new URL(url), log, "Unpacking " + url + " to " + dir + " on " + node.getDisplayName())) { dir.act(new ChmodRecAPlusX()); } if (subdir == null) { return dir; } else { return dir.child(subdir); } }
String location = httpCon.getHeaderField("Location"); listener.getLogger().println("Following redirect " + archive.toExternalForm() + " -> " + location); return installIfNecessaryFrom(getUrlFactory().newURL(location), listener, message, maxRedirects - 1); } else { listener.getLogger().println("Skipping installation of " + archive + " to " + remote + " due to too many redirects.");
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if (inst == null) { log.getLogger().println("Invalid tool ID " + id); return expected; } if (isUpToDate(expected, inst)) { return expected; } if (expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if (base != null && base != expected) { base.moveAllChildrenTo(expected); } // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url, "UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expected = preferredLocation(tool, node); Installable inst = getInstallable(); if(inst==null) { log.getLogger().println("Invalid tool ID "+id); return expected; } if (inst instanceof NodeSpecific) { inst = (Installable) ((NodeSpecific) inst).forNode(node, log); } if(isUpToDate(expected,inst)) return expected; if(expected.installIfNecessaryFrom(new URL(inst.url), log, "Unpacking " + inst.url + " to " + expected + " on " + node.getDisplayName())) { expected.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expected); if(base!=null && base!=expected) base.moveAllChildrenTo(expected); // leave a record for the next up-to-date check expected.child(".installedFrom").write(inst.url,"UTF-8"); expected.act(new ZipExtractionInstaller.ChmodRecAPlusX()); } return expected; }
public FilePath performInstallation(ToolInstallation tool, Node node, TaskListener log) throws IOException, InterruptedException { FilePath expectedPath = preferredLocation(tool, node); Installable installable; try { installable = getInstallable(node); } catch (InstallationFailedException e) { throw new InstallationFailedException(Messages.CouldNotInstallGo(e.getMessage())); } if (installable == null) { log.getLogger().println(Messages.UnrecognisedReleaseId(id)); return expectedPath; } if (isUpToDate(expectedPath, installable)) { return expectedPath; } String message = Messages.InstallingGoOnNode(installable.url, expectedPath, node.getDisplayName()); if (expectedPath.installIfNecessaryFrom(new URL(installable.url), log, message)) { expectedPath.child(".timestamp").delete(); // we don't use the timestamp FilePath base = findPullUpDirectory(expectedPath); if (base != null && base != expectedPath) base.moveAllChildrenTo(expectedPath); // leave a record for the next up-to-date check expectedPath.child(".installedFrom").write(installable.url, "UTF-8"); } return expectedPath; }
install.installIfNecessaryFrom(tgz, listener, "Unpacking " + tgz + " to " + install + " on " + node.getDisplayName());