Update patches for reproducible doc builds to match upstream

This commit is contained in:
Ben Hutchings 2015-08-16 21:19:41 +02:00
parent 7e2d688bde
commit d97fca4d0a
9 changed files with 147 additions and 173 deletions

View File

@ -0,0 +1,31 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Wed, 8 Jul 2015 20:06:44 +0100
Subject: DocBook: Don't store mtime (or name) in compressed man pages
Bug-Debian: https://bugs.debian.org/769844
Forwarded: http://thread.gmane.org/gmane.linux.documentation/31870/focus=31872
The mtime on a man page is the build time. As gzip stores the mtime
and original name in the compressed file by default, this makes
compressed man pages unreproducible. Neither of these are important
metadata in this case, so turn this off.
Reported-by: Jérémy Bobbio <lunar@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
Documentation/DocBook/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index b6a6a2e..11a4145 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -56,7 +56,7 @@ htmldocs: $(HTML)
MAN := $(patsubst %.xml, %.9, $(BOOKS))
mandocs: $(MAN)
- find $(obj)/man -name '*.9' | xargs gzip -f
+ find $(obj)/man -name '*.9' | xargs gzip -nf
installmandocs: mandocs
mkdir -p /usr/local/man/man9/

View File

@ -1,125 +0,0 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Wed, 08 Jul 2015 00:32:38 +0100
Subject: DocBook: Fix duplicate man pages
Bug-Debian: https://bugs.debian.org/769844
Some kernel-doc sections are included in multiple DocBook files. This
means the mandocs target will generate the same manual page multiple
times with different metadata (author name/address and manual title,
taken from the including DocBook file). If it's invoked in a parallel
build, the output is nondeterminstic.
For each section that is duplicated, mark the less specific manual's
inclusion as 'extra' and exclude it during conversion to manual pages.
Use xmlif for this, as that is bundled with xmlto which we already
use.
I would have preferred to use more conventional markup for this, but
each of the following approaches failed:
1. Wrap the extra inclusions with a new element and add a template to
the stylesheet to include/exclude them. Unfortunately DocBook XSL
doesn't seem to support foreign elements at an intermediate level
in the document tree.
2. Use DocBook profiling. This works but requires passing an absolute
path to the profile stylesheet to xmlto, so it's not portable.
3. Use SGML marked sections. docbook2x can handle these but xmlto
chokes on them.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -56,6 +56,13 @@ htmldocs: $(HTML)
MAN := $(patsubst %.xml, %.9, $(BOOKS))
mandocs: $(MAN)
+ @dups=$$(sed -n 's/.*<refname>\([^<]*\)<\/refname>.*/\1/p' \
+ $(obj)/*.xml.noextra | sort | uniq -d); \
+ if [ -n "$$dups" ]; then \
+ echo >&2 "The following manual pages are generated more than once:"; \
+ printf >&2 '%s\n' "$$dups"; \
+ exit 1; \
+ fi
find $(obj)/man -name '*.9' | xargs gzip -nf
installmandocs: mandocs
@@ -150,7 +157,7 @@ quiet_cmd_db2html = HTML $@
cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
quiet_cmd_db2man = MAN $@
- cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; fi
+ cmd_db2man = if grep -q refentry $<; then xmlif excludeextra=1 <$< >$<.noextra && xmlto man $(XMLTOFLAGS) -o $(obj)/man $<.noextra ; fi
%.9 : %.xml
@(which xmlto > /dev/null 2>&1) || \
(echo "*** You need to install xmlto ***"; \
@@ -217,6 +224,7 @@ clean-files := $(DOCBOOKS) \
$(patsubst %.xml, %.ps, $(DOCBOOKS)) \
$(patsubst %.xml, %.pdf, $(DOCBOOKS)) \
$(patsubst %.xml, %.html, $(DOCBOOKS)) \
+ $(patsubst %, %.noextra, $(DOCBOOKS)) \
$(patsubst %.xml, %.9, $(DOCBOOKS)) \
$(index)
--- a/Documentation/DocBook/gadget.tmpl
+++ b/Documentation/DocBook/gadget.tmpl
@@ -488,7 +488,10 @@ These are the same types and constants u
side drivers (and usbcore).
</para>
+<?xmlif if excludeextra='1'?>
+<?xmlif else?>
!Iinclude/linux/usb/ch9.h
+<?xmlif fi?>
</sect1>
<sect1 id="core"><title>Core Objects and Methods</title>
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -58,8 +58,11 @@
<sect1><title>String Conversions</title>
!Elib/vsprintf.c
+<?xmlif if excludeextra='1'?>
+<?xmlif else?>
!Finclude/linux/kernel.h kstrtol
!Finclude/linux/kernel.h kstrtoul
+<?xmlif fi?>
!Elib/kstrtox.c
</sect1>
<sect1><title>String Manipulation</title>
@@ -178,7 +181,10 @@ X!Ekernel/module.c
<chapter id="hardware">
<title>Hardware Interfaces</title>
<sect1><title>Interrupt Handling</title>
+<?xmlif if excludeextra='1'?>
+<?xmlif else?>
!Ekernel/irq/manage.c
+<?xmlif fi?>
</sect1>
<sect1><title>DMA Channels</title>
--- a/Documentation/DocBook/device-drivers.tmpl
+++ b/Documentation/DocBook/device-drivers.tmpl
@@ -194,8 +194,13 @@ X!Edrivers/pnp/system.c
<chapter id="snddev">
<title>Sound Devices</title>
+<?xmlif if excludeextra='1'?>
+<?xmlif else?>
!Iinclude/sound/core.h
+<?xmlif fi?>
!Esound/sound_core.c
+<?xmlif if excludeextra='1'?>
+<?xmlif else?>
!Iinclude/sound/pcm.h
!Esound/core/pcm.c
!Esound/core/device.c
@@ -211,6 +216,7 @@ X!Edrivers/pnp/system.c
!Esound/core/hwdep.c
!Esound/core/pcm_native.c
!Esound/core/memalloc.c
+<?xmlif fi?>
<!-- FIXME: Removed for now since no structured comments in source
X!Isound/sound_firmware.c
-->

View File

@ -0,0 +1,50 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Thu, 6 Aug 2015 22:18:32 +0100
Subject: DocBook: Fix non-determinstic installation of duplicate man pages
Bug-Debian: https://bugs.debian.org/769844
Forwarded: http://thread.gmane.org/gmane.linux.kernel/1997951/focus=32450
Some kernel-doc sections are included in multiple DocBook files. This
means the mandocs target will generate the same manual page multiple
times with different metadata (author name/address and manual title,
taken from the including DocBook file). If it's invoked in a parallel
build, the output is non-determinstic.
Build the manual pages in a separate subdirectory per DocBook file,
then sort and de-duplicate when installing them (which is serialised).
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
Documentation/DocBook/Makefile | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 11a4145..198e9b5 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -60,7 +60,9 @@ mandocs: $(MAN)
installmandocs: mandocs
mkdir -p /usr/local/man/man9/
- install $(obj)/man/*.9.gz /usr/local/man/man9/
+ find $(obj)/man -name '*.9.gz' -printf '%h %f\n' | \
+ sort -k 2 -k 1 | uniq -f 1 | sed -e 's: :/:' | \
+ xargs install -t /usr/local/man/man9/
###
#External programs used
@@ -150,12 +152,12 @@ quiet_cmd_db2html = HTML $@
cp $(PNG-$(basename $(notdir $@))) $(patsubst %.html,%,$@); fi
quiet_cmd_db2man = MAN $@
- cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man $< ; fi
+ cmd_db2man = if grep -q refentry $<; then xmlto man $(XMLTOFLAGS) -o $(obj)/man/$(*F) $< ; fi
%.9 : %.xml
@(which xmlto > /dev/null 2>&1) || \
(echo "*** You need to install xmlto ***"; \
exit 1)
- $(Q)mkdir -p $(obj)/man
+ $(Q)mkdir -p $(obj)/man/$(*F)
$(call cmd,db2man)
@touch $@

View File

@ -1,10 +1,24 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Tue, 07 Jul 2015 17:23:54 +0100
Subject: DocBook: generate consistent IDs
Date: Wed, 8 Jul 2015 20:06:51 +0100
Subject: DocBook: Generate consistent IDs
Bug-Debian: https://bugs.debian.org/769844
Forwarded: http://thread.gmane.org/gmane.linux.documentation/31870/focus=31873
By default, DocBook XSL uses a non-deterministic function to generate
IDs for HTML elements where it can't take a name from the input
document. However, it has the option to generate 'consistent'
(deterministic) IDs instead. Enable this to make the HTML pages
reproducible.
Reported-by: Jérémy Bobbio <lunar@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
Documentation/DocBook/stylesheet.xsl | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/DocBook/stylesheet.xsl b/Documentation/DocBook/stylesheet.xsl
index 85b2527..3bf4ecf 100644
--- a/Documentation/DocBook/stylesheet.xsl
+++ b/Documentation/DocBook/stylesheet.xsl
@@ -5,6 +5,7 @@

View File

@ -1,24 +0,0 @@
From: Jérémy Bobbio <lunar@debian.org>
Date: Wed, 7 Jan 2015 20:49:51 +0100
Subject: parse kernel-doc deterministically
Bug-Debian: https://bugs.debian.org/769844
Regular expressions for highlights in kernel-doc are stored in a Perl
hash. These hashes are ordered differently for each Perl run. This will
prevent kernel-doc to behave deterministically when parsing
“@foo()” as in some runs it will be interpreted as a parameter and
in the others it will be interpreted as a function.
We now sort the %highlights hash to get the same behavior on every run.
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2587,7 +2587,7 @@ $kernelversion = get_kernel_version();
# generate a sequence of code that will splice in highlighting information
# using the s// operator.
-foreach my $pattern (keys %highlights) {
+foreach my $pattern (sort keys %highlights) {
# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
$dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
}

View File

@ -1,16 +0,0 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Mon, 06 Jul 2015 23:34:54 +0100
Subject: remove timestamps from compressed man pages
Bug-Debian: https://bugs.debian.org/769844
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -56,7 +56,7 @@ htmldocs: $(HTML)
MAN := $(patsubst %.xml, %.9, $(BOOKS))
mandocs: $(MAN)
- find $(obj)/man -name '*.9' | xargs gzip -f
+ find $(obj)/man -name '*.9' | xargs gzip -nf
installmandocs: mandocs
mkdir -p /usr/local/man/man9/

View File

@ -0,0 +1,34 @@
From: Jérémy Bobbio <lunar@debian.org>
Date: Wed, 8 Jul 2015 20:06:33 +0100
Subject: scripts/kernel-doc: parse kernel-doc deterministically
Bug-Debian: https://bugs.debian.org/769844
Forwarded: http://thread.gmane.org/gmane.linux.documentation/31870/focus=31871
Regular expressions for highlights in kernel-doc are stored in a Perl
hash. These hashes are ordered differently for each Perl run. This will
prevent kernel-doc to behave deterministically when parsing “@foo()” as
in some runs it will be interpreted as a parameter and in the others it
will be interpreted as a function.
We now sort the %highlights hash to get the same behavior on every run.
Signed-off-by: Jérémy Bobbio <lunar@debian.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
scripts/kernel-doc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 9922e66..71ada00 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2587,7 +2587,7 @@ $kernelversion = get_kernel_version();
# generate a sequence of code that will splice in highlighting information
# using the s// operator.
-foreach my $pattern (keys %highlights) {
+foreach my $pattern (sort keys %highlights) {
# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
$dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
}

View File

@ -1,10 +1,20 @@
From: Ben Hutchings <ben@decadent.org.uk>
Date: Wed, 08 Jul 2015 02:37:21 +0100
Subject: kernel-doc: Use $KBUILD_BUILD_TIMESTAMP as man page date
Date: Wed, 8 Jul 2015 20:07:16 +0100
Subject: scripts/kernel-doc: Use $KBUILD_BUILD_TIMESTAMP as man page date
Bug-Debian: https://bugs.debian.org/769844
Forwarded: http://thread.gmane.org/gmane.linux.documentation/31870/focus=31875
Together with the preceding changes, this allows man pages to be built
reproducibly.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
scripts/kernel-doc | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 71ada00..0ac1a07 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -253,11 +253,20 @@ my %highlights = %highlights_man;

View File

@ -70,11 +70,11 @@ bugfix/all/net-mv643xx-disable-tso-by-default.patch
debian/emmc-don-t-initialize-partitions-on-rpmb-flagged-areas.patch
# Reproducible docs
bugfix/all/make-highlights-deterministic-in-kernel-doc.patch
bugfix/all/remove-timestamps-from-compressed-man-pages.patch
bugfix/all/scripts-kernel-doc-parse-kernel-doc-deterministicall.patch
bugfix/all/docbook-don-t-store-mtime-or-name-in-compressed-man-.patch
bugfix/all/docbook-generate-consistent-ids.patch
bugfix/all/docbook-fix-duplicate-man-pages.patch
bugfix/all/kernel-doc-set-man-page-date.patch
bugfix/all/docbook-fix-non-determinstic-installation-of-duplica.patch
bugfix/all/scripts-kernel-doc-use-kbuild_build_timestamp-as-man.patch
# Miscellaneous features
features/all/efi-autoload-efi-pstore.patch