File reproducible.patch of Package libgda

merged upstream:
https://gitlab.gnome.org/GNOME/libgda/-/merge_requests/192

From c9837a3438622d49fe6a727d2512e0f0bb3827d7 Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
Date: Wed, 2 Feb 2022 14:25:57 +0100
Subject: [PATCH] Allow to override build date with SOURCE_DATE_EPOCH

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

Also use UTC to be independent of timezone.
---
 meson.build | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 62b465941..bc4cecace 100644
--- a/meson.build
+++ b/meson.build
@@ -321,10 +321,18 @@ found_jdbc = false
 dates = compiler.run('''
 #include<glib.h>
 #include <glib/gprintf.h>
+#include <stdlib.h>
 
 void main (void) {
   GDateTime *dt;
-  dt = g_date_time_new_now_local ();
+  char *source_date_epoch;
+  gint64 epoch;
+  /* This assumes that the SOURCE_DATE_EPOCH environment variable will contain
+     a correct, positive integer */
+  if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
+    (epoch = (time_t)strtoll(source_date_epoch, NULL, 10)) <= 0 ||
+    (dt = g_date_time_new_from_unix_utc(epoch)) == NULL)
+       dt = g_date_time_new_now_utc ();
   g_print (g_date_time_format(dt, "%F"));
 }
 ''',
-- 
GitLab

openSUSE Build Service is sponsored by