yasm: improve reproducibility

Place reproducible build date in source files instead of
actual build date if SOURCE_DATE_EPOCH available.

Signed-off-by: Oleh Matiusha <omatiush@cisco.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Oleh Matiusha 2024-02-27 13:59:12 +00:00 committed by Khem Raj
parent 26a287e260
commit f5cc9f272a
No known key found for this signature in database
GPG Key ID: BB053355919D3314
3 changed files with 78 additions and 0 deletions

View File

@ -0,0 +1,35 @@
From eb164bb201c0f792fa8aa78270c47294065183a3 Mon Sep 17 00:00:00 2001
From: Oleh Matiusha <omatiush@cisco.com>
Date: Tue, 6 Feb 2024 09:33:11 +0000
Subject: [PATCH 1/2] yasm: Set build date to SOURCE_DATE_EPOCH
If SOURCE_DATE_EPOCH is set, use it to generate a reproducible
string for BUILD_DATE.
Signed-off-by: Oleh Matiusha <omatiush@cisco.com>
---
configure.ac | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/configure.ac b/configure.ac
index 2823ecd..eeb51ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,14 @@ AM_WITH_DMALLOC
#
AC_CHECK_HEADERS([strings.h libgen.h unistd.h direct.h sys/stat.h])
+# Use reproducible build date and time
+if test "$SOURCE_DATE_EPOCH"; then
+ DATE_FMT="%d %b %Y %H:%M:%S"
+ BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT")
+ AC_DEFINE_UNQUOTED([BUILD_DATE], ["$BUILD_DATE"], [Use reproducidle build date])
+fi
+
+
#
# Checks for typedefs, structures, and compiler characteristics.
#
--
2.33.0

View File

@ -0,0 +1,40 @@
From 19fffab74a201dc41c3da7e74d86eafa8f68bbc6 Mon Sep 17 00:00:00 2001
From: Oleh Matiusha <omatiush@cisco.com>
Date: Tue, 6 Feb 2024 09:34:26 +0000
Subject: [PATCH] yasm: Use BUILD_DATE for reproducibility
Use reproducible build date instead of compilation time and date.
Signed-off-by: Oleh Matiusha <omatiush@cisco.com>
---
tools/re2c/parser.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/re2c/parser.c b/tools/re2c/parser.c
index 02d5c66..1c90aee 100644
--- a/tools/re2c/parser.c
+++ b/tools/re2c/parser.c
@@ -5,6 +5,7 @@
#include "tools/re2c/globals.h"
#include "tools/re2c/parse.h"
#include "tools/re2c/parser.h"
+#include "config.h"
int yylex(void);
static RegExp *parse_expr(void);
@@ -233,7 +234,11 @@ void parse(FILE *i, FILE *o){
peektok = NONE;
fputs("/* Generated by re2c 0.9.1-C on ", o);
+#ifndef BUILD_DATE
fprintf(o, "%-24s", ctime(&now));
+#else
+ fprintf(o, "%-24s", BUILD_DATE " ");
+#endif
fputs(" */\n", o); oline+=2;
in = Scanner_new(i);
--
2.33.0

View File

@ -14,6 +14,8 @@ SRC_URI = "git://github.com/yasm/yasm.git;branch=master;protocol=https \
file://0001-Do-not-use-AC_HEADER_STDC.patch \ file://0001-Do-not-use-AC_HEADER_STDC.patch \
file://CVE-2023-31975.patch \ file://CVE-2023-31975.patch \
file://CVE-2023-37732.patch \ file://CVE-2023-37732.patch \
file://0001-yasm-Set-build-date-to-SOURCE_DATE_EPOCH.patch \
file://0002-yasm-Use-BUILD_DATE-for-reproducibility.patch \
" "
S = "${WORKDIR}/git" S = "${WORKDIR}/git"
@ -30,3 +32,4 @@ do_configure:prepend() {
# Don't include $CC (which includes path to sysroot) in generated header. # Don't include $CC (which includes path to sysroot) in generated header.
sed -i -e "s/^echo \"\/\* generated \$ac_cv_stdint_message \*\/\" >>\$ac_stdint$"// ${S}/m4/ax_create_stdint_h.m4 sed -i -e "s/^echo \"\/\* generated \$ac_cv_stdint_message \*\/\" >>\$ac_stdint$"// ${S}/m4/ax_create_stdint_h.m4
} }