File: reproducible-build.patch

package info (click to toggle)
freefilesync 12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,432 kB
  • sloc: cpp: 64,801; ansic: 431; makefile: 217
file content (62 lines) | stat: -rw-r--r-- 1,869 bytes parent folder | download
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
55
56
57
58
59
60
61
62
Description: Permit reproducible builds by use of SOURCE_DATE_EPOCH
 Currently the code relies on __DATE__ and __TIME__ macros.
 .
 This prevents to have reproducible build because these values changes every
 time we compile.
 .
 To achieve reproducible builds, make use of SOURCE_DATE_EPOCH as proposed
 on https://reproducible-builds.org
 .
 See:
  - https://reproducible-builds.org/docs/
  - https://reproducible-builds.org/docs/source-date-epoch/
Author: Fab Stz <fabstz-it@yahoo.fr>
Origin: self
Forwarded: https://freefilesync.org/forum/viewtopic.php?t=9686
Last-Update: 2022-08-11

--- a/FreeFileSync/Source/Makefile
+++ b/FreeFileSync/Source/Makefile
@@ -39,6 +39,10 @@
 LDFLAGS += `$(PKG_CONFIG) --libs libselinux`
 endif
 
+ifneq ($(SOURCE_DATE_EPOCH),)
+cxxFlags += -DSOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
+endif
+
 cppFiles=
 cppFiles+=application.cpp
 cppFiles+=base_tools.cpp
--- a/FreeFileSync/Source/RealTimeSync/Makefile
+++ b/FreeFileSync/Source/RealTimeSync/Makefile
@@ -16,6 +16,10 @@
 #treat as system headers so that warnings are hidden:
 CXXFLAGS  += -isystem/usr/include/gtk-3.0
 
+ifneq ($(SOURCE_DATE_EPOCH),)
+cxxFlags += -DSOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
+endif
+
 cppFiles=
 cppFiles+=application.cpp
 cppFiles+=config.cpp
--- a/zen/time.h
+++ b/zen/time.h
@@ -251,8 +251,16 @@
 inline
 TimeComp getCompileTime()
 {
+#ifdef SOURCE_DATE_EPOCH
+    time_t build_date = SOURCE_DATE_EPOCH;
+    tm *ltm = std::localtime(&build_date);
+    char compileTime[100];
+    std::strftime(compileTime, 100, "%b %d %Y %T", ltm); //e.g. "Aug  1 2017 01:32:26"
+#else
     //https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html
     char compileTime[] = __DATE__ " " __TIME__; //e.g. "Aug  1 2017 01:32:26"
+#endif
+
     if (compileTime[4] == ' ') //day is space-padded, but %d expects zero-padding
         compileTime[4] = '0';