Source: infinipath-psm
Severity: normal
Tags: patch
User: reproducible-bui...@lists.alioth.debian.org
Usertags: timestamps
X-Debbugs-Cc: reproducible-b...@lists.alioth.debian.org

The build timestamp is embedded in libpsm_infinipath.so.*:

  
https://tests.reproducible-builds.org/debian/rb-pkg/bullseye/amd64/diffoscope-results/infinipath-psm.html

  ./usr/lib/libpsm1/libpsm_infinipath.so.1.16

  $Date:·2022-07-17·21:34·InfiniPath·$
  vs.
  $Date:·2021-06-15·17:13·InfiniPath·$

The attached patch fixes this by changing buildflags.mak to set a
BUILD_DATE variable, which uses SOURCE_DATE_EPOCH for the current value
if set, falling back to the current time/date; two Makefiles are also
adjusted to use BUILD_DATE instead of calling "date" directly.

  https://reproducible-builds.org/docs/source-date-epoch/


With this patch applied, infinipath-psm should be reproducible on
tests.reproducible-builds.org in the testing (currently bullseye) suite,
where build paths are not varied. In the unstable/experimental suites,
varied build paths trigger other issues which could use further
exploration.


Thanks for maintaining infinipath-psm!


live well,
  vagrant
From d9ce27e80d5b0d7028ac20136017147f49a780f4 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagr...@reproducible-builds.org>
Date: Fri, 9 Jul 2021 15:13:24 +0000
Subject: [PATCH] Use the build date from SOURCE_DATE_EPOCH if set, falling
 back to current time.

https://reproducible-builds.org/docs/source-date-epoch/
---
 Makefile       | 2 +-
 buildflags.mak | 8 ++++++++
 ipath/Makefile | 2 +-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d79c4bd..64d6f6b 100644
--- a/Makefile
+++ b/Makefile
@@ -270,7 +270,7 @@ ${TARGLIB}.so.${MAJOR}: ${TARGLIB}.so.${MAJOR}.${MINOR}
 # file around.  Generate it such that the ident command can find it
 # and strings -a | grep InfiniPath does a reasonable job as well.
 ${TARGLIB}.so.${MAJOR}.${MINOR}: ${${TARGLIB}-objs}
-	date +'char psmi_infinipath_revision[] ="$$""Date: %F %R ${rpm_extra_description}InfiniPath $$";' > ${lib_build_dir}/_revision.c
+	printf 'char psmi_infinipath_revision[] ="$$""Date: %s ${rpm_extra_description} InfiniPath $$";\n' "$(BUILD_DATE)" > ${lib_build_dir}/_revision.c
 	$(CC) -c $(BASECFLAGS) $(INCLUDES) _revision.c -o _revision.o
 	$(CC) $(LDFLAGS) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} -shared -Wl,--unique='*fastpath*' \
 		${${TARGLIB}-objs} _revision.o -L$(build_dir)/ipath $(LDLIBS)
diff --git a/buildflags.mak b/buildflags.mak
index 34fdf1c..3e25649 100644
--- a/buildflags.mak
+++ b/buildflags.mak
@@ -96,3 +96,11 @@ endif
 CFLAGS += $(BASECFLAGS) $(if $(filter $(CC),gcc),-Wno-strict-aliasing) \
 	$(if $(PSM_VALGRIND:0=),-DPSM_VALGRIND,-DNVALGRIND)
 
+# Use SOURCE_DATE_EPOCH for build date, falling back to current time
+# https://reproducible-builds.org/docs/source-date-epoch/
+DATE_FMT="+'%F %R'"
+ifdef FIXME_SOURCE_DATE_EPOCH
+    BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "$(DATE_FMT)" 2>/dev/null || date -u "$(DATE_FMT)")
+else
+    BUILD_DATE ?= $(shell date "$(DATE_FMT)")
+endif
diff --git a/ipath/Makefile b/ipath/Makefile
index 8c2cc6e..e627b3d 100644
--- a/ipath/Makefile
+++ b/ipath/Makefile
@@ -70,7 +70,7 @@ ${TARGLIB}.so.${MAJOR}: ${TARGLIB}.so.${MAJOR}.${MINOR}
 # file around.  Generate it such that the ident command can find it
 # and strings -a | grep InfiniPath does a reasonable job as well.
 ${TARGLIB}.so.${MAJOR}.${MINOR}: ${${TARGLIB}-objs}
-	date +'static __attribute__ ((unused)) char __psc_infinipath_revision[] ="$$""Date: %F %R ${rpm_extra_description}InfiniPath $$";' > _revision.c
+	printf 'static __attribute__ ((unused)) char __psc_infinipath_revision[] ="$$""Date: %s ${rpm_extra_description}InfiniPath $$";\n' "$(BUILD_DATE)" > _revision.c
 	$(CC) -c $(BASECFLAGS) $(INCLUDES) _revision.c -o _revision.o
 	$(CC) -o $@ -Wl,-soname=${TARGLIB}.so.${MAJOR} -shared \
 		-Wl,--unique='*fastpath*' \
-- 
2.32.0

Attachment: signature.asc
Description: PGP signature

Reply via email to