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/
This commit is contained in:
JojoBoulix 2016-04-06 22:18:27 +02:00
parent aa4cd9daf8
commit 707484790e
1 changed files with 7 additions and 3 deletions

View File

@ -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
if os.getenv("SOURCE_DATE_EPOCH") == nil then
if args.date == 'system' then
ldoc.updatetime = os.date("%Y-%m-%d %H:%M:%S")
else
else
ldoc.updatetime = args.date
end
else
ldoc.updatetime = os.date("!%Y-%m-%d %H:%M:%S",os.getenv("SOURCE_DATE_EPOCH"))
end
local html = require 'ldoc.html'