[ant] 01/03: Added support for the SOURCE_DATE_EPOCH variable in the Tstamp task

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Mar 28 09:44:38 UTC 2016


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository ant.

commit 36c5bf10b1cd6246e63889d4273c37a736fa5fa0
Author: Emmanuel Bourg <ebourg at apache.org>
Date:   Mon Mar 28 01:45:52 2016 +0200

    Added support for the SOURCE_DATE_EPOCH variable in the Tstamp task
---
 debian/changelog                                   |  1 +
 .../patches/0009-reproducible-timestamp-task.patch | 79 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 81 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 457f9fa..c37fa28 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
 ant (1.9.6-2) UNRELEASED; urgency=medium
 
+  * Added support for the SOURCE_DATE_EPOCH variable in the Tstamp task
   * Restored the XSL files in /usr/share/ant/etc which were removed
     in the version 1.7.1-1 (LP: #563899)
   * Install the missing ant-junit4 pom
diff --git a/debian/patches/0009-reproducible-timestamp-task.patch b/debian/patches/0009-reproducible-timestamp-task.patch
new file mode 100644
index 0000000..9a1b6b9
--- /dev/null
+++ b/debian/patches/0009-reproducible-timestamp-task.patch
@@ -0,0 +1,79 @@
+Description: Add support for the SOURCE_DATE_EPOCH variable in the Tstamp task
+Author: Emmanuel Bourg <ebourg at apache.org>
+Forwarded: no
+--- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
++++ b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
+@@ -70,20 +70,51 @@
+         try {
+             Date d = new Date();
+ 
++            boolean reproducibleBuild = false;
++
++            if (System.getenv("SOURCE_DATE_EPOCH") != null) {
++                try {
++                    java.util.Calendar calendar = java.util.Calendar.getInstance( java.util.TimeZone.getTimeZone("UTC") );
++                    calendar.setTimeInMillis(Long.parseLong( System.getenv("SOURCE_DATE_EPOCH") ) * 1000);
++                    d = calendar.getTime();
++                    reproducibleBuild = true;
++
++                } catch (Exception e) {
++                    log("Unable to parse the SOURCE_DATE_EPOCH variable: " + System.getenv("SOURCE_DATE_EPOCH"), e, Project.MSG_WARN);
++                }
++            }
++
+             Enumeration i = customFormats.elements();
+             while (i.hasMoreElements()) {
+                 CustomFormat cts = (CustomFormat) i.nextElement();
++                if (reproducibleBuild) {
++                    if (cts.getTimezone() == null) {
++                        cts.setTimezone("UTC");
++                    }
++                    if (cts.getLanguage() == null) {
++                        cts.setLocale("en_US");
++                    }
++                }
+                 cts.execute(getProject(), d, getLocation());
+             }
+ 
+             SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd");
++            if (reproducibleBuild) {
++                dstamp.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
++            }
+             setProperty("DSTAMP", dstamp.format(d));
+ 
+             SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm");
++            if (reproducibleBuild) {
++                tstamp.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
++            }
+             setProperty("TSTAMP", tstamp.format(d));
+ 
+             SimpleDateFormat today
+                 = new SimpleDateFormat ("MMMM d yyyy", Locale.US);
++            if (reproducibleBuild) {
++                today.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
++            }
+             setProperty("TODAY", today.format(d));
+ 
+         } catch (Exception e) {
+@@ -183,6 +214,10 @@
+             }
+         }
+ 
++        String getLanguage() {
++            return language;
++        }
++
+         /**
+          * The timezone to use for displaying time.
+          * The values are as defined by the Java TimeZone class.
+@@ -193,6 +228,10 @@
+             timeZone = TimeZone.getTimeZone(id);
+         }
+ 
++        TimeZone getTimezone() {
++            return timeZone;
++        }
++
+         /**
+          * The numeric offset to the current time.
+          * @param offset the offset to use.
diff --git a/debian/patches/series b/debian/patches/series
index a5299b8..bdad8ed 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@
 0006-fix-ANT_HOME-path.patch
 0007-use-build.classpath.patch
 0008-junit4-replace-assumeFalse.patch
+0009-reproducible-timestamp-task.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/ant.git



More information about the pkg-java-commits mailing list