Subject: [PATCH] Add patch to make eccodes reproducible

From: Jochen Sprickerhof <[email-masked]>
Date: Fri, 31 Jul 2026 08:03:43 +0200

---
 ...DATE_EPOCH-in-ecbuild_get_date.cmake.patch | 38 +++++++++++++++++++
 debian/patches/series                         |  1 +
 2 files changed, 39 insertions(+)
 create mode 100644 debian/patches/0007-Support-SOURCE_DATE_EPOCH-in-ecbuild_get_date.cmake.patch

diff --git a/debian/patches/0007-Support-SOURCE_DATE_EPOCH-in-ecbuild_get_date.cmake.patch b/debian/patches/0007-Support-SOURCE_DATE_EPOCH-in-ecbuild_get_date.cmake.patch
new file mode 100644
index 0000000..212bbfe
--- /dev/null
+++ b/debian/patches/0007-Support-SOURCE_DATE_EPOCH-in-ecbuild_get_date.cmake.patch
@@ -0,0 +1,38 @@
+From: Jochen Sprickerhof <[email-masked]>
+Date: Fri, 31 Jul 2026 08:02:50 +0200
+Subject: Support SOURCE_DATE_EPOCH in ecbuild_get_date.cmake
+
+---
+ cmake/ecbuild_get_date.cmake | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/cmake/ecbuild_get_date.cmake b/cmake/ecbuild_get_date.cmake
+index ffe2f43..9e29894 100644
+--- a/cmake/ecbuild_get_date.cmake
++++ b/cmake/ecbuild_get_date.cmake
+@@ -21,7 +21,11 @@
+ 
+ macro(ecbuild_get_date RESULT)
+     if(UNIX)
+-        execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
++        if($ENV{SOURCE_DATE_EPOCH})
++            execute_process(COMMAND "date" "+%d/%m/%Y" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" OUTPUT_VARIABLE ${RESULT})
++        else()
++            execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
++        endif()
+         string(REGEX REPLACE "(..)/(..)/(....).*" "\\3.\\2.\\1" ${RESULT} ${${RESULT}})
+     else()
+         ecbuild_error("date not implemented")
+@@ -43,7 +47,11 @@ endmacro(ecbuild_get_date)
+ 
+ macro(ecbuild_get_timestamp RESULT)
+     if(UNIX)
+-        execute_process(COMMAND "date" "+%Y/%m/%d/%H/%M/%S" OUTPUT_VARIABLE _timestamp)
++        if($ENV{SOURCE_DATE_EPOCH})
++            execute_process(COMMAND "date" "+%Y/%m/%d/%H/%M/%S" "-u" "-d" "@$ENV{SOURCE_DATE_EPOCH}" OUTPUT_VARIABLE _timestamp)
++        else()
++            execute_process(COMMAND "date" "+%Y/%m/%d/%H/%M/%S" OUTPUT_VARIABLE _timestamp)
++        endif()
+         string(REGEX REPLACE "(....)/(..)/(..)/(..)/(..)/(..).*" "\\1\\2\\3\\4\\5\\6" ${RESULT} ${_timestamp})
+     else()
+         ecbuild_warn("This is NOT UNIX - timestamp not implemented")
diff --git a/debian/patches/series b/debian/patches/series
index e233d2d..a1fcc9e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -5,3 +5,4 @@ find-proj4.patch
 g++14.patch
 # disable-rpaths.patch
 reproducibility.patch
+0007-Support-SOURCE_DATE_EPOCH-in-ecbuild_get_date.cmake.patch
-- 
2.53.0