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

Signed-off-by: Oleh Matiusha <omati...@cisco.com>
---
 ...-Set-build-date-to-SOURCE_DATE_EPOCH.patch | 35 ++++++++++++++++
 ...m-Use-BUILD_DATE-for-reproducibility.patch | 40 +++++++++++++++++++
 meta-oe/recipes-devtools/yasm/yasm_git.bb     |  3 ++
 3 files changed, 78 insertions(+)
 create mode 100644 
meta-oe/recipes-devtools/yasm/yasm/0001-yasm-Set-build-date-to-SOURCE_DATE_EPOCH.patch
 create mode 100644 
meta-oe/recipes-devtools/yasm/yasm/0002-yasm-Use-BUILD_DATE-for-reproducibility.patch

diff --git 
a/meta-oe/recipes-devtools/yasm/yasm/0001-yasm-Set-build-date-to-SOURCE_DATE_EPOCH.patch
 
b/meta-oe/recipes-devtools/yasm/yasm/0001-yasm-Set-build-date-to-SOURCE_DATE_EPOCH.patch
new file mode 100644
index 000000000..e65c9853e
--- /dev/null
+++ 
b/meta-oe/recipes-devtools/yasm/yasm/0001-yasm-Set-build-date-to-SOURCE_DATE_EPOCH.patch
@@ -0,0 +1,35 @@
+From eb164bb201c0f792fa8aa78270c47294065183a3 Mon Sep 17 00:00:00 2001
+From: Oleh Matiusha <omati...@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 <omati...@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
+
diff --git 
a/meta-oe/recipes-devtools/yasm/yasm/0002-yasm-Use-BUILD_DATE-for-reproducibility.patch
 
b/meta-oe/recipes-devtools/yasm/yasm/0002-yasm-Use-BUILD_DATE-for-reproducibility.patch
new file mode 100644
index 000000000..665f3afc9
--- /dev/null
+++ 
b/meta-oe/recipes-devtools/yasm/yasm/0002-yasm-Use-BUILD_DATE-for-reproducibility.patch
@@ -0,0 +1,40 @@
+From 19fffab74a201dc41c3da7e74d86eafa8f68bbc6 Mon Sep 17 00:00:00 2001
+From: Oleh Matiusha <omati...@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 <omati...@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
+
diff --git a/meta-oe/recipes-devtools/yasm/yasm_git.bb 
b/meta-oe/recipes-devtools/yasm/yasm_git.bb
index 079f805d6..216b77766 100644
--- a/meta-oe/recipes-devtools/yasm/yasm_git.bb
+++ b/meta-oe/recipes-devtools/yasm/yasm_git.bb
@@ -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://CVE-2023-31975.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"
@@ -30,3 +32,4 @@ do_configure:prepend() {
      # 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
 }
+
-- 
2.33.0

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#109044): 
https://lists.openembedded.org/g/openembedded-devel/message/109044
Mute This Topic: https://lists.openembedded.org/mt/104602703/21656
Group Owner: openembedded-devel+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to