commands.add("cd " + targetDir); String sourcePath = Os.mergePathsUnix(sourceDir, fileName); switch (ArchiveType.of(fileName)) { case TAR: commands.add("tar xvf " + sourcePath);
/** * Set the location of the generated archive file. */ public ArchiveBuilder named(String name) { checkNotNull(name); String ext = Files.getFileExtension(name); if (ext.isEmpty()) { name = name + "." + type.toString(); } else if (type != ArchiveType.of(name)) { throw new IllegalArgumentException(String.format("Extension for '%s' did not match archive type of %s", ext, type)); } this.archive = new File(Os.tidyPath(name)); return this; }
throw new IllegalStateException(format("Failed to expand archive %s on %s", archiveUrl, machine)); return ArchiveType.of(destFile)!=ArchiveType.UNKNOWN; } finally { machine.releaseMutex("installing");
if (ArchiveType.of(cookbookArchiveUrl)==ArchiveType.UNKNOWN) { destName = cookbookName + ".tgz"; log.debug("Assuming TGZ type for chef cookbook url "+cookbookArchiveUrl+"; it will be downloaded as "+destName);
if (ArchiveType.of(cookbookArchiveUrl)==ArchiveType.UNKNOWN) { destName = cookbookName + ".tgz"; log.debug("Assuming TGZ type for chef cookbook url "+cookbookArchiveUrl+"; it will be downloaded as "+destName);
/** * Generates the archive. * <p> * If no name has been specified, the archive will be created as a temporary file with * a unique name, that is deleted on exit. Otherwise, the given name will be used. */ public File create() { if (archive == null) { File temp = Os.newTempFile("brooklyn-archive", type.toString()); temp.deleteOnExit(); named(temp); } try { OutputStream output = new FileOutputStream(archive); stream(output); output.close(); } catch (IOException ioe) { throw Exceptions.propagate(ioe); } return archive; }
/** * Returns the list of commands used to install support for an archive with the given name. */ public static List<String> installCommands(String fileName) { List<String> commands = new LinkedList<String>(); switch (ArchiveType.of(fileName)) { case TAR: case TGZ: case TBZ: commands.add(BashCommands.INSTALL_TAR); break; case ZIP: commands.add(BashCommands.INSTALL_UNZIP); break; case JAR: case WAR: case EAR: case UNKNOWN: break; } return commands; }
public static ArchiveUtils.ArchiveType of(String filename) { if (filename == null) return null; String ext = Files.getFileExtension(filename); try { return valueOf(ext.toUpperCase()); } catch (IllegalArgumentException iae) { if (filename.toLowerCase().endsWith(".tar.gz")) { return TGZ; } else if (filename.toLowerCase().endsWith(".tar.bz") || filename.toLowerCase().endsWith(".tar.bz2") || filename.toLowerCase().endsWith(".tar.xz")) { return TBZ; } else { return UNKNOWN; } } }
private ArchiveBuilder(String filename) { this(ArchiveType.of(filename)); named(filename); }