[Reproducible-builds] [sortjar] 04/05: Accept an optional timestamp on the command line.
Drew Fisher
zarvox-guest at moszumanska.debian.org
Sat Aug 30 18:43:10 UTC 2014
This is an automated email from the git hooks/post-receive script.
zarvox-guest pushed a commit to branch master
in repository sortjar.
commit bced82534918beb11128ce6d1316301f743fbb8e
Author: akwizgran <akwizgran at users.sourceforge.net>
Date: Thu Apr 17 17:42:59 2014 +0100
Accept an optional timestamp on the command line.
---
src/org/briarproject/sortjar/SortJar.java | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/org/briarproject/sortjar/SortJar.java b/src/org/briarproject/sortjar/SortJar.java
index 0956f10..0e14eb8 100644
--- a/src/org/briarproject/sortjar/SortJar.java
+++ b/src/org/briarproject/sortjar/SortJar.java
@@ -4,6 +4,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
+import java.util.Date;
import java.util.Map;
import java.util.TreeMap;
import java.util.jar.JarEntry;
@@ -12,11 +13,23 @@ import java.util.jar.JarOutputStream;
public class SortJar {
+ @SuppressWarnings("deprecation")
public static void main(String[] args) {
- if(args.length != 2 || args[0].equals(args[1])) {
- System.err.println("Usage: SortJar <input.jar> <output.jar>");
+ if(args.length < 2 || args.length > 3 || args[0].equals(args[1])) {
+ System.err.println("Usage: SortJar <in.jar> <out.jar> [date]");
System.exit(1);
}
+ long timestamp = 0;
+ if(args.length == 3) {
+ String date = args[2];
+ try {
+ timestamp = Date.parse(date);
+ System.out.println("Setting timestamp to " + date);
+ } catch(IllegalArgumentException e) {
+ System.err.println("Could not parse date: " + date);
+ System.exit(2);
+ }
+ }
String input = args[0], output = args[1];
try {
// Read and sort the entries
@@ -29,7 +42,7 @@ public class SortJar {
new FileOutputStream(output));
for(JarEntry e : entries.values()) {
JarEntry e1 = new JarEntry(e.getName());
- e1.setTime(0);
+ e1.setTime(timestamp);
out.putNextEntry(e1);
InputStream entryIn = in.getInputStream(e);
int read;
@@ -41,9 +54,10 @@ public class SortJar {
}
out.close();
in.close();
+ System.out.println("Sorted " + entries.size() + " entries");
} catch(IOException e) {
e.printStackTrace();
- System.exit(2);
+ System.exit(3);
}
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/sortjar.git
More information about the Reproducible-builds
mailing list