File reproducible-tstamp.patch of Package ant
diff -urEbwB apache-ant-1.9.10.orig/src/main/org/apache/tools/ant/taskdefs/Tstamp.java apache-ant-1.9.10/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
--- apache-ant-1.9.10.orig/src/main/org/apache/tools/ant/taskdefs/Tstamp.java 2024-02-24 14:08:30.351112514 +0100
+++ apache-ant-1.9.10/src/main/org/apache/tools/ant/taskdefs/Tstamp.java 2024-02-24 14:20:57.008356741 +0100
@@ -46,6 +46,8 @@
*/
public class Tstamp extends Task {
+ private static final String ENV_SOURCE_DATE_EPOCH = "SOURCE_DATE_EPOCH";
+
private Vector customFormats = new Vector();
private String prefix = "";
@@ -71,6 +73,20 @@
try {
Date d = getNow();
+ // Honour reproducible builds https://reproducible-builds.org/specs/source-date-epoch/#idm55
+ final String epoch = System.getenv(ENV_SOURCE_DATE_EPOCH);
+ try {
+ if (epoch != null) {
+ // Value of SOURCE_DATE_EPOCH will be an integer, representing seconds.
+ d = new Date(Long.parseLong(epoch) * 1000L);
+ }
+ log("Honouring environment variable " + ENV_SOURCE_DATE_EPOCH + " which has been set to " + epoch);
+ } catch(NumberFormatException e) {
+ // ignore
+ log("Ignoring invalid value '" + epoch + "' for " + ENV_SOURCE_DATE_EPOCH
+ + " environment variable", Project.MSG_DEBUG);
+ }
+
Enumeration i = customFormats.elements();
while (i.hasMoreElements()) {
CustomFormat cts = (CustomFormat) i.nextElement();
Only in apache-ant-1.9.10/src/main/org/apache/tools/ant/taskdefs: Tstamp.java.orig
Only in apache-ant-1.9.10/src/main/org/apache/tools/ant/taskdefs: Tstamp.java.rej