[Git][reproducible-builds/reproducible-website][master] Add a Meson/Python alternative for generating SOURCE_DATE_EPOCH.

Chris Lamb (@lamby) gitlab at salsa.debian.org
Tue Mar 11 13:11:54 UTC 2025



Chris Lamb pushed to branch master at Reproducible Builds / reproducible-website


Commits:
1e2be408 by Chris Lamb at 2025-03-11T13:11:41+00:00
Add a Meson/Python alternative for generating SOURCE_DATE_EPOCH.

- - - - -


1 changed file:

- _docs/source-date-epoch.md


Changes:

=====================================
_docs/source-date-epoch.md
=====================================
@@ -142,6 +142,27 @@ formatted_date = run_command(date_exe, '-u', '-d', '@' + source_date_epoch, '+%Y
 
 The above will work only with GNU `date`. See the POSIX shell example on how to support BSD date variants.
 
+#### Alternative version
+
+You could also use Python (or similar) to generate the formatted date:
+
+```meson
+python = import('python').find_installation('python3')
+
+datetime = '''
+import os
+import time
+
+print(time.strftime(
+    "%Y-%m-%d",
+    time.gmtime(int(os.environ.get('SOURCE_DATE_EPOCH', time.time())))
+))
+'''
+
+formatted_date = run_command(python, '-c', datetime, check: true).stdout().strip()
+```
+
+
 ### Dockerfile
 
 The `SOURCE_DATE_EPOCH` argument value is automaticallly propagated from the `SOURCE_DATE_EPOCH` environment value



View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/1e2be40879c2044f611492f2b821e1c7913fb2bc

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reproducible-website/-/commit/1e2be40879c2044f611492f2b821e1c7913fb2bc
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20250311/f3984f06/attachment.htm>


More information about the rb-commits mailing list