From 67098511db6dfa74ec3b34f1c02d15a3fbf4c3c2 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Mon, 13 Jul 2020 15:07:00 +0200 Subject: [PATCH] make_manual: Support SOURCE_DATE_EPOCH The documentation contains an embedded datetime which do not read SOURCE_DATE_EPOCH. This makes the documentation unreproducible when distribution tries to recreate previous build of the package. This patch ensures we attempt to read the environment variable before default to the current build time. Signed-off-by: Morten Linderud --- bin/make_manual.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/make_manual.py b/bin/make_manual.py index 5899642dd..725d99b73 100755 --- a/bin/make_manual.py +++ b/bin/make_manual.py @@ -6,6 +6,7 @@ conversion into man pages etc. import os import re +import time from datetime import datetime docpath = "docs/content" @@ -156,17 +157,19 @@ def read_commands(docpath): if command != "rclone.md": docs.append(read_command(command)) return "\n".join(docs) - + def main(): check_docs(docpath) command_docs = read_commands(docpath).replace("\\", "\\\\") # escape \ so we can use command_docs in re.sub + build_date = datetime.utcfromtimestamp( + int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) with open(outfile, "w") as out: out.write("""\ %% rclone(1) User Manual %% Nick Craig-Wood %% %s -""" % datetime.now().strftime("%b %d, %Y")) +""" % build_date.strftime("%b %d, %Y")) for doc in docs: contents = read_doc(doc) # Substitute the commands into doc.md