File: 0011-reproducible-propertyfile-task.patch

package info (click to toggle)
ant 1.10.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,560 kB
  • sloc: java: 146,466; xml: 39,751; sh: 504; perl: 135; javascript: 65; python: 53; jsp: 38; makefile: 35
file content (26 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Improves the reproducibility of the propertyfile task for the Debian
 builds by using the date specified by the SOURCE_DATE_EPOCH variable in the
 header of the .properties file generated
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/main/org/apache/tools/ant/util/DateUtils.java
+++ b/src/main/org/apache/tools/ant/util/DateUtils.java
@@ -227,6 +227,10 @@
      */
     public static String getDateForHeader() {
         Calendar cal = Calendar.getInstance();
+        if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+            cal.setTime(new Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))));
+        }
         TimeZone tz = cal.getTimeZone();
         int offset = tz.getOffset(cal.get(Calendar.ERA),
                                   cal.get(Calendar.YEAR),
@@ -247,6 +251,7 @@
         }
         tzMarker.append(minutes);
         synchronized (DATE_HEADER_FORMAT_INT) {
+            DATE_HEADER_FORMAT_INT.setTimeZone(tz);
             return DATE_HEADER_FORMAT_INT.format(cal.getTime()) + tzMarker.toString();
         }
     }