From 1a8e49d9ba6973e5247590070d1185e1a55950a7 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Sat, 30 Nov 2024 19:16:00 +0100 Subject: [PATCH] Allow custom man build date via SOURCE_DATE_EPOCH (#2096) Allows making man1/conky.1 in 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. --- doc/render.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/render.py b/doc/render.py index 5210ea31..aa4cdd96 100755 --- a/doc/render.py +++ b/doc/render.py @@ -2,6 +2,7 @@ import sys import os +import time import yaml import datetime @@ -16,12 +17,16 @@ with open(os.path.join(base_path, "variables.yaml")) as file: with open(os.path.join(base_path, "lua.yaml")) as file: lua = yaml.safe_load(file) +build_date = datetime.datetime.fromtimestamp( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time())), + tz=datetime.timezone.utc, +) data = { "config_settings": config_settings, "variables": variables, "lua": lua, - "date": datetime.date.today().isoformat(), - "copyright_year": datetime.date.today().year, + "date": build_date.date().isoformat(), + "copyright_year": build_date.year, } from jinja2 import Environment, FileSystemLoader, select_autoescape