mirror of https://github.com/apache/jclouds.git
added statement to rebase dist packages
This commit is contained in:
parent
758e01a4d2
commit
cd98f16408
|
@ -171,6 +171,26 @@ public class Statements {
|
||||||
return new PipeHttpResponseToTarxpzfIntoDirectory(method, endpoint, headers, directory);
|
return new PipeHttpResponseToTarxpzfIntoDirectory(method, endpoint, headers, directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* like {@link #extractTargzIntoDirectory(URI, String)} except that it
|
||||||
|
* flattens the first directory in the archive
|
||||||
|
*
|
||||||
|
* For example, {@code apache-maven-3.0.4-bin.tar.gz} normally extracts
|
||||||
|
* directories like {@code ./apache-maven-3.0.4/bin}. This command eliminates
|
||||||
|
* the intermediate directory, in the example {@code ./apache-maven-3.0.4/}
|
||||||
|
*
|
||||||
|
* @param tgz remote ref to download
|
||||||
|
* @param dest path where the files in the intermediate directory will end
|
||||||
|
*/
|
||||||
|
public static Statement extractTargzAndFlattenIntoDirectory(URI tgz, String dest) {
|
||||||
|
return new StatementList(ImmutableSet.<Statement> builder()
|
||||||
|
.add(exec("mkdir /tmp/$$"))
|
||||||
|
.add(extractTargzIntoDirectory(tgz, "/tmp/$$"))
|
||||||
|
.add(exec("mkdir -p " + dest))
|
||||||
|
.add(exec("mv /tmp/$$/*/* " + dest))
|
||||||
|
.add(exec("rm -rf /tmp/$$")).build());
|
||||||
|
}
|
||||||
|
|
||||||
public static Statement extractTargzIntoDirectory(URI targz, String directory) {
|
public static Statement extractTargzIntoDirectory(URI targz, String directory) {
|
||||||
return extractTargzIntoDirectory("GET", targz, ImmutableMultimap.<String, String> of(), directory);
|
return extractTargzIntoDirectory("GET", targz, ImmutableMultimap.<String, String> of(), directory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,4 +49,19 @@ public class StatementsTest {
|
||||||
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.tar.gz |(mkdir -p /opt/minecraft &&cd /opt/minecraft &&tar -xpzf -)\n");
|
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft_server.tar.gz |(mkdir -p /opt/minecraft &&cd /opt/minecraft &&tar -xpzf -)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testExtractTargzAndFlattenIntoDirectoryUNIX() {
|
||||||
|
Statement save = Statements
|
||||||
|
.extractTargzAndFlattenIntoDirectory(
|
||||||
|
URI.create("http://www.us.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz"),
|
||||||
|
"/usr/local/maven");
|
||||||
|
assertEquals(
|
||||||
|
save.render(OsFamily.UNIX),
|
||||||
|
"mkdir /tmp/$$\n" +
|
||||||
|
"curl -q -s -S -L --connect-timeout 10 --max-time 600 --retry 20 -X GET http://www.us.apache.org/dist/maven/binaries/apache-maven-3.0.4-bin.tar.gz |(mkdir -p /tmp/$$ &&cd /tmp/$$ &&tar -xpzf -)\n" +
|
||||||
|
"mkdir -p /usr/local/maven\n" +
|
||||||
|
"mv /tmp/$$/*/* /usr/local/maven\n" +
|
||||||
|
"rm -rf /tmp/$$\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue