RFR: 8277069: [REDO] JDK-8276743 Make openjdk build Zip Archive generation "reproducible"

Magnus Ihse Bursie ihse at openjdk.java.net
Thu Dec 2 19:05:22 UTC 2021


On Thu, 2 Dec 2021 14:55:14 GMT, Magnus Ihse Bursie <ihse at openjdk.org> wrote:

> This is basically Andrew's old patch that was backed out, with a single change: I'm using  ZipFile instead of ZipInputStream to read in the original zip. The latter is not capable of reading the extended attributes that contain the unix permissions. (Why this is so, is not fully clear to me. What's worse, it's by no means clear from the documentation. We should probably file a follow-up bug to improve the Javadoc for ZipInputStream, warning the users to stay away if they can.)
> 
> I have also added the possibility to opt-out of reproducible building by an argument to SetupZipArchive. This is used in the closed Oracle part of the build, where we create some temporary zip files that are later discarded, and not part of the deliverables. This saves us some unnecessary overhead.

I tried to find a way to make GitHub display the difference wrt the original, backed out, patch, but utterly failed. So here's a simple diff. This is the only way in which this patch differs from the original.


--- ./make/jdk/src/classes/build/tools/makezipreproducible/MakeZipReproducible.java	2021-12-02 19:57:38.000000000 +0100
+++ ../../jdk-ALT/open/make/jdk/src/classes/build/tools/makezipreproducible/MakeZipReproducible.java	2021-12-02 15:11:22.000000000 +0100
@@ -162,13 +162,8 @@

     // Process input zip file and add to sorted entries set
     boolean processInputEntries(File inFile) throws IOException {
-        try (FileInputStream fis = new FileInputStream(inFile);
-             ZipInputStream  zis = new ZipInputStream(fis)) {
-            ZipEntry entry;
-            while ((entry = zis.getNextEntry()) != null) {
-                entries.put(entry.getName(), entry);
-            }
-        }
+        ZipFile zipFile = new ZipFile(inFile);
+        zipFile.stream().forEach(entry -> entries.put(entry.getName(), entry));

         return true;
     }

-------------

PR: https://git.openjdk.java.net/jdk/pull/6673



More information about the build-dev mailing list