File: reproducible-build.patch

package info (click to toggle)
rmlint 2.10.2-0.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,180 kB
  • sloc: ansic: 15,671; python: 9,312; sh: 474; xml: 111; makefile: 72
file content (90 lines) | stat: -rw-r--r-- 3,104 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From: Carlos Maddela <e7appew@gmail.com>
Date: Sat, 14 Jan 2017 05:46:33 +1100
Subject: Make builds reproducible.

Description: Make builds reproducible.
 * Use environment variables BUILD_DATE and BUILD_TIME, in place
   of __DATE__ and __TIME__.
 * Use Debian revision number in place of git revision number.
Author: Carlos Maddela <e7appew@gmail.com>
Forwarded: not-needed
Last-Update: 2019-12-30
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
---
 SConstruct      | 15 ++++++++++++---
 lib/SConscript  |  4 +++-
 lib/cmdline.c   |  2 +-
 lib/config.h.in |  2 ++
 4 files changed, 18 insertions(+), 5 deletions(-)

--- a/SConstruct
+++ b/SConstruct
@@ -90,13 +90,16 @@
 
 
 def check_git_rev(context):
-    context.Message('Checking for git revision... ')
+    context.Message('Checking for Debian revision... ')
     rev = STATIC_GIT_REV
 
     try:
-        rev = subprocess.check_output('git log --pretty=format:"%h" -n 1', shell=True)
+        # Use universal_newlines to ensure result is returned as str while
+        # remaining Python version-agnostic.
+        rev = subprocess.check_output('dpkg-parsechangelog -S Version', shell=True, universal_newlines=True).rstrip()
+        rev = rev.split('-', 1)[1]
     except subprocess.CalledProcessError:
-        print('Unable to find git revision.')
+        print('Unable to find Debian revision.')
     except AttributeError:
         # Patch for some special sandbox permission problems.
         # See https://github.com/sahib/rmlint/issues/143#issuecomment-139929733
@@ -767,6 +770,12 @@
 SConsEnvironment.InstallPerm = InstallPerm
 
 # Your extra checks here
+
+conf.env['BUILD_DATE'] = os.environ['BUILD_DATE'] \
+    if 'BUILD_DATE' in os.environ else 'UNKNOWN'
+conf.env['BUILD_TIME'] = os.environ['BUILD_TIME'] \
+    if 'BUILD_TIME' in os.environ else 'UNKNOWN'
+
 env = conf.Finish()
 
 def get_cpu_count():
--- a/lib/SConscript
+++ b/lib/SConscript
@@ -43,7 +43,9 @@
             VERSION_MINOR=VERSION_MINOR,
             VERSION_PATCH=VERSION_PATCH,
             VERSION_NAME=VERSION_NAME,
-            VERSION_GIT_REVISION=env['gitrev'].strip()
+            VERSION_GIT_REVISION=env['gitrev'].strip(),
+            BUILD_DATE=env['BUILD_DATE'],
+            BUILD_TIME=env['BUILD_TIME']
         )
 
         handle.write(config_h)
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -62,7 +62,7 @@
 
 static void rm_cmd_show_version(void) {
     fprintf(stderr, "version %s compiled: %s at [%s] \"%s\" (rev %s)\n", RM_VERSION,
-            __DATE__, __TIME__, RM_VERSION_NAME, RM_VERSION_GIT_REVISION);
+            RM_BUILD_DATE, RM_BUILD_TIME, RM_VERSION_NAME, RM_VERSION_GIT_REVISION);
 
     /* Make a list of all supported features from the macros in config.h */
     /* clang-format off */
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -34,6 +34,8 @@
 #define RM_VERSION_PATCH {VERSION_PATCH}
 #define RM_VERSION_NAME  "{VERSION_NAME}"
 #define RM_VERSION_GIT_REVISION "{VERSION_GIT_REVISION}"
+#define RM_BUILD_DATE "{BUILD_DATE}"
+#define RM_BUILD_TIME "{BUILD_TIME}"
 
 #define RM_MANPAGE_USE_PAGER (1)