File: reproducible-timestamps.patch

package info (click to toggle)
bnd 5.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 44,092 kB
  • sloc: java: 249,039; xml: 90,727; sh: 655; perl: 153; makefile: 95; python: 47; javascript: 9
file content (54 lines) | stat: -rw-r--r-- 2,086 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Description: Use the value of the SOURCE_DATE_EPOCH variable for the timestamps generated by BND
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Macro.java
@@ -865,6 +865,10 @@
 			reporter.warning("Too many arguments for tstamp: %s", Arrays.toString(args));
 		}
 
+		if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+			now = 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"));
+		}
+
 		SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
 		sdf.setTimeZone(tz);
 		return sdf.format(new Date(now));
@@ -883,6 +887,11 @@
 		} else {
 			now = System.currentTimeMillis();
 		}
+
+		if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+			now = 1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"));
+		}
+
 		return now;
 	}
 
--- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java
+++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Jar.java
@@ -112,7 +112,7 @@
 	private String												lastModifiedReason;
 	private boolean												doNotTouchManifest;
 	private boolean												nomanifest;
-	private boolean												reproducible;
+	private boolean												reproducible = true;
 	private Compression											compression				= Compression.DEFLATE;
 	private boolean												closed;
 	private String[]											algorithms;
--- a/settings.gradle
+++ b/settings.gradle
@@ -51,11 +51,7 @@
    * If the git workspace is clean, the build time is the time of the head commit.
    * If the git workspace is dirty, the build time is the current time.
    */
-  if ('git diff --no-ext-diff --quiet'.execute().waitFor() == 0) {
-    workspace.setProperty(Constants.TSTAMP, 'git show --no-patch --format=%ct000'.execute().text.trim())
-  } else {
-    workspace.setProperty(Constants.TSTAMP, Long.toString(System.currentTimeMillis()))
-  }
+  workspace.setProperty(Constants.TSTAMP, System.getProperty("SOURCE_DATE_EPOCH") != null ? System.getProperty("SOURCE_DATE_EPOCH") : Long.toString(System.currentTimeMillis()))
 }
 
 apply plugin: 'biz.aQute.bnd.workspace'