Package: apiguardian
Severity: normal
Tags: patch
User: [email protected]
Usertags: timestamps timezone
X-Debbugs-Cc: [email protected]

The shipped apiguardian-api-1.1.0.jar embeds the time, date and timezone
in the build:

  
https://tests.reproducible-builds.org/debian/rb-pkg/bullseye/amd64/diffoscope-results/apiguardian.html

  /usr/share/java/apiguardian-api-1.1.0.jar

  Build-Date:·2022-07-12\xd     
  vs.
  Build-Date:·2021-06-09\xd

  Build-Time:·01:53:17.318-1200\xd
  vs.
  Build-Time:·21:34:59.146+1400\xd


The attached patch modifies build.gradle to set the timezone to UTC when
the SOURCE_DATE_EPOCH environment variable is defined, and use
SOURCE_DATE_EPOCH to set the timestamp.

With this patch applied, apiguardian should become reproducible in the
tests.reproducible-builds.org infrastructure.


Thanks for maintaining apiguardian!


live well,
  vagrant
From 6e50539b3aef7df874d8890c9dcdb19123189cc9 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <[email protected]>
Date: Thu, 8 Jul 2021 23:53:10 +0000
Subject: [PATCH] debian/patches: Support reproducible timestamps in the .jar
 file.

Patch build.gradle to use SOURCE_DATE_EPOCH to avoid embedding
timestamp in .jar file.

https://reproducible-builds.org/docs/source-date-epoch/
---
 .../03-reproducible-builds-timestamp.patch    | 25 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 debian/patches/03-reproducible-builds-timestamp.patch

diff --git a/debian/patches/03-reproducible-builds-timestamp.patch b/debian/patches/03-reproducible-builds-timestamp.patch
new file mode 100644
index 0000000..4999dd9
--- /dev/null
+++ b/debian/patches/03-reproducible-builds-timestamp.patch
@@ -0,0 +1,25 @@
+Add support for SOURCE_DATE_EPOCH to avoid embedding timestamp in .jar
+file.
+
+https://reproducible-builds.org/docs/source-date-epoch/
+
+Index: apiguardian/build.gradle
+===================================================================
+--- apiguardian.orig/build.gradle
++++ apiguardian/build.gradle
+@@ -8,7 +8,14 @@ plugins {
+ 	id 'signing'
+ }
+ 
+-Date buildTimeAndDate = new Date()
++// https://reproducible-builds.org/docs/source-date-epoch/
++String source_date_epoch = System.getenv("SOURCE_DATE_EPOCH");
++if (source_date_epoch != null) {
++   TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
++}
++Date buildTimeAndDate = source_date_epoch == null ?
++    new Date() :
++    new Date(1000 * Long.parseLong(source_date_epoch))
+ ext {
+ 	buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
+ 	buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
diff --git a/debian/patches/series b/debian/patches/series
index e7ac9c0..fb1a683 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 01-ignore-versioning-plugin.patch
 02-ignore-github-pages-plugin.patch
+03-reproducible-builds-timestamp.patch
-- 
2.32.0

Attachment: signature.asc
Description: PGP signature

__
This is the maintainer address of Debian's Java team
<https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-java-maintainers>.
 Please use
[email protected] for discussions and questions.

Reply via email to