File: timestamp_from_changelog.patch

package info (click to toggle)
jalview 2.11.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 445,392 kB
  • sloc: java: 365,549; xml: 2,989; sh: 1,511; perl: 336; lisp: 139; python: 116; makefile: 81; haskell: 60
file content (44 lines) | stat: -rw-r--r-- 1,726 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
Description: putting the timestamp of the latest debian/changelog entry instead
 of the one of compile time, in order to enhance build reproducibility
Author: Pierre Gruet <pgt@debian.org>
Forwarded: not-needed
Last-Update: 2023-10-08

--- a/build.gradle
+++ b/build.gradle
@@ -7,6 +7,7 @@
 import org.gradle.api.internal.PropertiesTransformer
 import org.gradle.util.ConfigureUtil
 import java.security.MessageDigest
+import java.text.SimpleDateFormat
 import java.util.regex.Matcher
 import java.util.concurrent.Executors
 import java.util.concurrent.Future
@@ -80,7 +81,26 @@
 ext {
   jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
   jalviewDirRelativePath = jalviewDir
-  date = new Date()
+
+  // Verbose and maybe not efficient hack to put the changelog date into the
+  // "date" variable, which will be used to insert e.g. years in doc files.
+  // This is to make the build reproducible.
+  def outBAdate = new ByteArrayOutputStream()
+  exec {
+    commandLine 'dpkg-parsechangelog', '-Stimestamp'
+    standardOutput = outBAdate
+  }
+  dateWithEOL = outBAdate.toString()
+  dateWithoutEOL = dateWithEOL.substring(0, dateWithEOL.length() - 1)
+
+  def outBA = new ByteArrayOutputStream()
+  exec {
+    commandLine 'date', '--utc', "--date=@${dateWithoutEOL}", '+"%d/%m/%Y-%H:%M:%S"'
+    standardOutput = outBA
+  }
+  toParseWithEOLAndQuotes = outBA.toString()
+  toParseWithoutEOLAndQuotes = toParseWithEOLAndQuotes.substring(1, toParseWithEOLAndQuotes.length() - 2)
+  date = new SimpleDateFormat("dd/MM/yyyy-HH:mm:ss").parse(toParseWithoutEOLAndQuotes)
 
   // default to "default". Currently only has different cosmetics for "develop", "release", "default"
   propertiesChannelName = "default"