[Reproducible-builds] [sortjar] 01/05: First commit: sort entries in a zip or jar file alphabetically.
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 678d5ecd637ac4caebb2f7b5bfa61241a7195a6c
Author: akwizgran <akwizgran at users.sourceforge.net>
Date: Sat Apr 12 17:45:41 2014 +0100
First commit: sort entries in a zip or jar file alphabetically.
---
.classpath | 6 +++
.gitignore | 1 +
.project | 17 +++++++++
.settings/org.eclipse.jdt.core.prefs | 11 ++++++
src/org/briarproject/sortjar/SortJar.java | 61 +++++++++++++++++++++++++++++++
5 files changed, 96 insertions(+)
diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..8727917
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+bin
diff --git a/.project b/.project
new file mode 100644
index 0000000..8a04a5c
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SortJar</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..416f4fb
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/src/org/briarproject/sortjar/SortJar.java b/src/org/briarproject/sortjar/SortJar.java
new file mode 100644
index 0000000..2ebf082
--- /dev/null
+++ b/src/org/briarproject/sortjar/SortJar.java
@@ -0,0 +1,61 @@
+package org.briarproject.sortjar;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+public class SortJar {
+
+ public static void main(String[] args) {
+ if(args.length != 2 || args[0].equals(args[1])) {
+ System.err.println("Usage: SortJar <input.jar> <output.jar>");
+ System.exit(1);
+ }
+ String input = args[0];
+ String output = args[1];
+ ZipFile in = null;
+ ZipOutputStream out = null;
+ try {
+ // Read and sort the entries
+ Map<String, ZipEntry> entries = new TreeMap<String, ZipEntry>();
+ in = new ZipFile(input);
+ for(ZipEntry e : Collections.list(in.entries()))
+ entries.put(e.getName(), e);
+ // Write the sorted entries
+ out = new ZipOutputStream(new FileOutputStream(output));
+ for(ZipEntry e : entries.values()) {
+ ZipEntry e1 = new ZipEntry(e.getName());
+ e1.setTime(0);
+ out.putNextEntry(e1);
+ InputStream entryIn = in.getInputStream(e);
+ int read;
+ byte[] buf = new byte[4096];
+ while((read = entryIn.read(buf, 0, buf.length)) != -1)
+ out.write(buf, 0, read);
+ out.closeEntry();
+ entryIn.close();
+ }
+ out.close();
+ in.close();
+ } catch(IOException e) {
+ if(in != null) {
+ try {
+ in.close();
+ } catch(IOException ignored) {}
+ }
+ if(out != null) {
+ try {
+ out.close();
+ } catch(IOException ignored) {}
+ }
+ e.printStackTrace();
+ System.exit(2);
+ }
+ }
+}
--
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