summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch')
-rw-r--r--meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch41
1 files changed, 41 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch b/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch
new file mode 100644
index 0000000000..32e529d483
--- /dev/null
+++ b/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch
@@ -0,0 +1,41 @@
1From dd7925397b84c2a327cd4594edba9f7ca5acef61 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 26 Sep 2025 14:02:23 +0800
4Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable
5
6Implement the SOURCE_DATE_EPOCH specification[1] for reproducible
7builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the
8current time.
9
10[1] https://reproducible-builds.org/specs/source-date-epoch/
11
12Upstream-Status: Submitted [https://github.com/mlcommons/inference/pull/2345]
13
14Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
15---
16 version_generator.py | 9 +++++++--
17 1 file changed, 7 insertions(+), 2 deletions(-)
18
19diff --git a/version_generator.py b/version_generator.py
20index 2e75243..5202da9 100644
21--- a/version_generator.py
22+++ b/version_generator.py
23@@ -110,8 +110,13 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
24 # Write the version into the function definition
25 ofile.write(func_def("Version", f"\"{version_contents}\""))
26
27- date_time_now_local = datetime.datetime.now().isoformat()
28- date_time_now_utc = datetime.datetime.utcnow().isoformat()
29+ if os.environ.get('SOURCE_DATE_EPOCH', False):
30+ source_date_epoch = int(os.environ['SOURCE_DATE_EPOCH'])
31+ date_time_now_local = datetime.datetime.fromtimestamp(source_date_epoch).isoformat()
32+ date_time_now_utc = datetime.datetime.fromtimestamp(source_date_epoch, tz=datetime.timezone.utc).isoformat()
33+ else:
34+ date_time_now_local = datetime.datetime.now().isoformat()
35+ date_time_now_utc = datetime.datetime.utcnow().isoformat()
36 ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"'))
37 ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"'))
38
39--
402.34.1
41