From 707484790e63359d2216a05a8ae8750ed5af304b Mon Sep 17 00:00:00 2001 From: JojoBoulix Date: Wed, 6 Apr 2016 22:18:27 +0200 Subject: [PATCH] Honour the SOURCE_DATE_EPOCH environment variable When the environment variable SOURCE_DATE_EPOCH is set, use it as the epoch of the date to be written in the output. This allows to build reproducibly packages depending on LDoc to build their documentation, without any change to their code and build process. See https://reproducible-builds.org/specs/source-date-epoch/ --- ldoc.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ldoc.lua b/ldoc.lua index c4c0bf6..b7eb78e 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -803,10 +803,14 @@ ldoc.title = ldoc.title or args.title ldoc.project = ldoc.project or args.project ldoc.package = args.package:match '%a+' and args.package or nil -if args.date == 'system' then - ldoc.updatetime = os.date("%Y-%m-%d %H:%M:%S") +if os.getenv("SOURCE_DATE_EPOCH") == nil then + if args.date == 'system' then + ldoc.updatetime = os.date("%Y-%m-%d %H:%M:%S") + else + ldoc.updatetime = args.date + end else - ldoc.updatetime = args.date + ldoc.updatetime = os.date("!%Y-%m-%d %H:%M:%S",os.getenv("SOURCE_DATE_EPOCH")) end local html = require 'ldoc.html'