[libspi-java] 03/05: Add support for SOURCE_DATE_EPOCH for reproducible builds
Tony Mancill
tmancill at moszumanska.debian.org
Mon Aug 14 04:51:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
tmancill pushed a commit to branch master
in repository libspi-java.
commit 6bd852d1441cb50892c42711674a02bede30636e
Author: tony mancill <tmancill at debian.org>
Date: Sun Aug 13 20:35:39 2017 -0700
Add support for SOURCE_DATE_EPOCH for reproducible builds
---
debian/patches/series | 1 +
debian/patches/source-date-epoch.patch | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..f84bed2
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+source-date-epoch.patch
diff --git a/debian/patches/source-date-epoch.patch b/debian/patches/source-date-epoch.patch
new file mode 100644
index 0000000..8aa931e
--- /dev/null
+++ b/debian/patches/source-date-epoch.patch
@@ -0,0 +1,34 @@
+Description: add support SOURCE_DATE_EPOCH
+ See: https://reproducible-builds.org/specs/source-date-epoch/
+Author: tony mancill <tmancill at debian.org>
+Last-Update: 2017-08-13
+
+--- a/src/org/mangosdk/spi/processor/Persistence.java
++++ b/src/org/mangosdk/spi/processor/Persistence.java
+@@ -132,7 +132,7 @@
+ Writer writer = output.openWriter();
+ try {
+ writer.write("# Generated by " + name + "\n");
+- writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date()) + "\n");
++ writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(getBuildDate()) + "\n");
+ writer.write(value);
+ }
+ finally {
+@@ -144,4 +144,17 @@
+ }
+ }
+ }
++
++ // return build timestamp, either the value of SOURCE_DATE_EPOCH
++ // in milliseconds or the current system time in milliseconds
++ // see: https://reproducible-builds.org/specs/source-date-epoch/
++ private long getBuildDate() {
++ try {
++ return Long.valueOf(System.getenv("SOURCE_DATE_EPOCH")) * 1000L;
++ }
++ catch (Exception e) {
++ // ignore any problems retrieving or casting SOURCE_DATE_EPOCH
++ }
++ return System.currentTimeMillis();
++ }
+ }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libspi-java.git
More information about the pkg-java-commits
mailing list