RFR: 8264449: Enable reproducible builds with SOURCE_DATE_EPOCH [v5]

John Neffenger jgneff at openjdk.java.net
Mon Nov 22 20:28:18 UTC 2021


On Fri, 17 Sep 2021 22:10:41 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> John Neffenger has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains seven commits:
>> 
>>  - Make build of SDK ZIP bundle reproducible
>>  - Merge branch 'master' into allow-reproducible-builds
>>  - Merge branch 'master' into allow-reproducible-builds
>>  - Include WebKit shared library for Windows
>>    
>>    Enable reproducible builds of the native WebKit shared library for
>>    Windows (jfxwebkit.dll) when SOURCE_DATE_EPOCH is defined.
>>  - Include media shared libraries for Windows
>>    
>>    Enable reproducible builds of the native media shared libraries for
>>    Windows when SOURCE_DATE_EPOCH is defined. The libraries are:
>>    
>>      fxplugins.dll
>>      glib-lite.dll
>>      gstreamer-lite.dll
>>      jfxmedia.dll
>>  - Enable reproducible builds with SOURCE_DATE_EPOCH
>>  - 8238650: Allow to override buildDate with SOURCE_DATE_EPOCH
>
> build.gradle line 559:
> 
>> 557:     buildDate = new java.util.Date(ms)
>> 558: }
>> 559: def buildTimestamp = new java.text.SimpleDateFormat("yyyy-MM-dd-HHmmss").format(buildDate)
> 
> I think it would be useful to format `buildDate` using UTC as the time zone when `SOURCE_DATE_EPOCH` is set.

Indeed. The build now uses the new `java.time.Instant` class to get the instant on the time-line, whether or not `SOURCE_DATE_EPOCH` is set, and creates the timestamp in UTC using the ISO 8601 date and time format.

> build.gradle line 3518:
> 
>> 3516:                         def lFlags = webkitProperties.linkFlags?.join(' ') ?: ''
>> 3517:                         cmakeArgs = "$cmakeArgs -DCMAKE_C_FLAGS='${cFlags}' -DCMAKE_CXX_FLAGS='${cFlags}'"
>> 3518:                         cmakeArgs = "$cmakeArgs -DCMAKE_SHARED_LINKER_FLAGS='${lFlags}'"
> 
> I presume you've tested this both with and without `SOURCE_DATE_EPOCH`?

Well, now I have! �� Thanks.

> build.gradle line 3914:
> 
>> 3912:     tasks.withType(AbstractArchiveTask) {
>> 3913:         if (sourceDateEpoch != null) {
>> 3914:             preserveFileTimestamps = false
> 
> This is a problem given how gradle generates a zip archive when this is set. How hard would it be to force all time stamps to be `SOURCE_DATE_EPOCH`?

It was harder than I had hoped, but I think I found a good solution. The only changes in the ZIP and JAR archives are shown in the `diff` extract below (from `zipinfo -v`):


29c29
<   minimum software version required to extract:   1.0
---
>   minimum software version required to extract:   2.0
33,34c33,34
<   extended local header:                          no
<   file last modified on (DOS date/time):          1980 Feb 1 00:00:00
---
>   extended local header:                          yes
>   file last modified on (DOS date/time):          2021 Nov 16 17:55:42
44c44
<   MS-DOS file attributes (10 hex):                dir 
---
>   MS-DOS file attributes (00 hex):                none

where:

* The minimum software version required to extract is now set to the correct value of 2.0, which is the minimum for file entries compressed with DEFLATE.
* The extended local header is defined but with length zero.
* The timestamp is set to the local date and time in UTC of the instant of the build.
* The MS-DOS file attribute for a directory is not set. It does not appear to be useful, as an entry in a ZIP file is a directory if and only if its name ends with a slash ("/").

These changes are due to Gradle using the Apache Ant `org.apache.tools.zip.ZipEntry` class, while the build now uses the `java.util.zip.ZipEntry` class in OpenJDK to create the archives.

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

PR: https://git.openjdk.java.net/jfx/pull/446


More information about the openjfx-dev mailing list