[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#990862: infinipath-psm: reproducible builds: Embedded timestamps in libpsm_infinipath.so



On 2021-07-09, Vagrant Cascadian wrote:
> On 2021-07-09, Vagrant Cascadian wrote:
>> 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
>
> ^^^ OopS! that was my debugging attempt to make sure it works when
> SOURCE_DATE_EPOCH is not set.
>
> It *should* be:
>
>   ifdef 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
>
> Will send updated patch...

Corrected patch attached. Sorry for the mixup!


live well,
  vagrant
From 88b66063c5f02ba48f2fc9cfa2ae6cc42c950cc8 Mon Sep 17 00:00:00 2001
From: Vagrant Cascadian <vagrant@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..be40c40 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 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 to: