[pve-devel] [PATCH docs 1/2] export and respect SOURCE_DATE_EPOCH

Fabian Grünbichler f.gruenbichler at proxmox.com
Tue Feb 20 11:10:24 CET 2018


to improve reproducibility of pve-docs, pve-doc-generator and
pve-doc-mediawiki builds, as well as man pages generated by
pve-doc-generator when called via dpkg-buildpackage.

timestamps embedded in the documentation now always reflect the last changelog
entry of the package to which the documentation belongs (pve-docs for html,
epub and pdf, individual packages for man pages).

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
note: the .pdf and .epub files still contain randomly generated IDs which
change on every build, which would require more extensive investigation and
likely patches to other toolchain packages (I haven't checked Buster yet, maybe
some of it is fixed there already).

note: an alternative approach would be to set the man page date to that of
pve-docs as well, but since the synopsis content is more likely to change than
the long form content, this solution seems more appropriate.

 Makefile        | 4 +++-
 asciidoc-pve.in | 8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 32f3fd5..dc776ac 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,8 @@ DOC_DEB=${DOC_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
 MEDIAWIKI_DEB=${MEDIAWIKI_PACKAGE}_${DOCRELEASE}-${PKGREL}_all.deb
 DOC_BUILDDEPS := asciidoc-dblatex, source-highlight, librsvg2-bin
 
+export SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
+SOURCE_DATE_HUMAN := $(shell date -d "@${SOURCE_DATE_EPOCH}")
 
 all: index.html
 
@@ -81,7 +83,7 @@ INDEX_INCLUDES=								\
 	man8-index-table.adoc						\
 	$(sort $(addsuffix .html, ${MANUAL_PAGES}) ${CHAPTER_LIST})
 
-ADOC_STDARG=-b $(shell pwd)/asciidoc/pve-html -f asciidoc/asciidoc-pve.conf -a icons -a data-uri -a "date=$(shell date)" -a "revnumber=${DOCRELEASE}"
+ADOC_STDARG=-b $(shell pwd)/asciidoc/pve-html -f asciidoc/asciidoc-pve.conf -a icons -a data-uri -a "date=${SOURCE_DATE_HUMAN}" -a "revnumber=${DOCRELEASE}" -a footer-style=revdate
 
 BROWSER?=xdg-open
 
diff --git a/asciidoc-pve.in b/asciidoc-pve.in
index 83f59eb..70848ca 100644
--- a/asciidoc-pve.in
+++ b/asciidoc-pve.in
@@ -300,7 +300,12 @@ sub compile_asciidoc {
 
     $leveloffset = - $doctype;
 
-    my $date = `date`;
+    my $date;
+    if (defined($ENV{SOURCE_DATE_EPOCH})) {
+	$date = `date -d "\@$ENV{SOURCE_DATE_EPOCH}"`;
+    } else {
+	$date = `date`;
+    }
     chomp $date;
 
     my $attributes = {
@@ -308,6 +313,7 @@ sub compile_asciidoc {
 	leveloffset => $leveloffset,
 	revnumber => $release,
 	revdate => $date,
+	'footer-style' => 'revdate',
     };
 
     my $mansection = $fileinfo->{mansection}->{$env}->{$infile};
-- 
2.14.2





More information about the pve-devel mailing list