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
|
Description: Switch from __DATE__ and __TIME__ to BUILD_DATE macros for reproducibility
Author: Thomas Stewart <thomas@stewarts.org.uk>
--- w1retap.orig/src/libusblinux300/ds192x.c
+++ w1retap/src/libusblinux300/ds192x.c
@@ -13,6 +13,10 @@ static int WriteScratch(int, uchar *, in
static int CopyScratch(int, int, int);
static int WriteMemory(int, uchar *, int, int);
+#ifndef BUILD_DATE
+#define BUILD_DATE __DATE__ " " __TIME__
+#endif
+
#ifdef TESTMAIN
#include <stdio.h>
#include "../../config.h"
@@ -297,7 +301,7 @@ int main(int argc, char **argv) {
dev = argv[optind];
TRACE(("DS192x tester %s\n", argv[0]));
- TRACE((__FILE__ " " __DATE__ " " __TIME__ "\n"));
+ TRACE((__FILE__ " " BUILD_DATE "\n"));
TRACE(("Based on w1retap " VERSION "\n"));
if (dev == NULL || (serial21 == NULL && serial23 == NULL)) {
--- w1retap.orig/src/w1retap.c
+++ w1retap/src/w1retap.c
@@ -35,6 +35,10 @@
#include "w1retap.h"
+#ifndef BUILD_DATE
+#define BUILD_DATE __DATE__ " " __TIME__
+#endif
+
enum W1_sigflag { W1_NOFLAG = 0, W1_RECONF = (1), W1_READALL = (2), W1_SHOWCF = (4) };
static volatile enum W1_sigflag sigme;
@@ -404,7 +408,7 @@ int main(int argc, char **argv) {
if (w1->verbose) {
fputs("w1retap v" VERSION " (c) 2005-2023 Jonathan Hudson\n", stderr);
- fputs("Built: " __DATE__ " " __TIME__ " gcc " __VERSION__ "\n", stderr);
+ fputs("Built: " BUILD_DATE " gcc " __VERSION__ "\n", stderr);
if (w1->verbose == 2) {
exit(0);
}
--- w1retap.orig/meson.build
+++ w1retap/meson.build
@@ -12,6 +12,15 @@ localedir = join_paths (prefix, get_opti
uname_run = run_command ('uname', check:true)
osname = uname_run.stdout().strip()
+date_exe = find_program('date')
+cmd = run_command('sh', '-c', 'echo $SOURCE_DATE_EPOCH')
+source_date_epoch = cmd.stdout().strip()
+if source_date_epoch == ''
+ source_date_epoch = run_command(date_exe, '+%s').stdout().strip()
+endif
+
+formatted_date = run_command(date_exe, '-u', '-d', '@' + source_date_epoch, '+%Y-%m-%d').stdout().strip()
+
conf = configuration_data ()
conf.set_quoted('PACKAGE', meson.project_name ())
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name ())
@@ -73,7 +82,7 @@ executable(
wdeps
],
include_directories : [ configuration_inc, 'src/libusblinux300' ],
- c_args: ['-D_GNU_SOURCE' ],
+ c_args: ['-D_GNU_SOURCE' , '-DBUILD_DATE="' + formatted_date + '"' ],
link_with : [ owfat, w1common ],
export_dynamic: true,
install_rpath : pkglibdir,
|