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 <morten@linderud.pw>
This commit is contained in:
Morten Linderud 2020-07-13 15:07:00 +02:00 committed by Nick Craig-Wood
parent 07b2ce4ab2
commit 67098511db
1 changed files with 5 additions and 2 deletions

View File

@ -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