Subject: Re: [bug#59313] [PATCH] gnu: linux-libre: Enable building html and info doc.

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 20 Nov 2022 19:57:18 -0500

Hi,

Christopher Baines <[email-masked]> writes:

> Maxim Cournoyer <[email-masked]> writes:
>
>> * gnu/packages/patches/linux-libre-infodocs-target.patch: New file.
>> * gnu/local.mk (dist_patch_DATA): Register it.
>> (linux-libre-6.0-source, linux-libre-5.15-source, linux-libre-5.10-source)
>> (linux-libre-5.4-source, linux-libre-4.19-source)
>> (linux-libre-4.9-source): Apply above patch.
>> * gnu/packages/linux.scm (make-linux-libre): Add new patch in the default
>> patches used.  Add a BUILD-DOC? argument.
>> (make-linux-libre*): Add a BUILD-DOC? argument.
>> [outputs]: New field.
>> [phases]: Conditionally add the build-doc and install-doc phases.
>> [native-inputs]: Conditionally add graphviz, python, python-sphinx,
>> python-sphinx-rtd-theme, texinfo and which.
>> ---
>>  gnu/local.mk                                  |   3 +-
>>  gnu/packages/linux.scm                        | 280 ++++++++++--------
>>  .../patches/linux-libre-infodocs-target.patch |  88 ++++++
>>  3 files changed, 253 insertions(+), 118 deletions(-)
>>  create mode 100644 gnu/packages/patches/linux-libre-infodocs-target.patch
>
> Hi,
>
> Looking at https://qa.guix.gnu.org/issue/59313 this seems to break the
> build of [email-masked] on x86_64-linux and
> [email-masked] on aarch64-linux, plus maybe some
> other things.

Thanks for pointing that!  The data service is proving useful again!
:-).

I've made the following changes, which I'll send as v2 shortly:

--8<---------------cut here---------------start------------->8---
1 file changed, 26 insertions(+), 17 deletions(-)
gnu/packages/linux.scm | 43 ++++++++++++++++++++++++++-----------------

modified   gnu/packages/linux.scm
@@ -108,8 +108,9 @@ (define-module (gnu packages linux)
   #:use-module (gnu packages docbook)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages elf)
-  #:use-module (gnu packages flex)
   #:use-module (gnu packages file)
+  #:use-module (gnu packages flex)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gcc)
@@ -516,25 +517,21 @@ (define-public linux-libre-5.4-source
                              %linux-libre-arm-export-__sync_icache_dcache-patch
                              ;; Pinebook Pro patch from linux-next,
                              ;; can be dropped for linux-libre 5.7
-                             (search-patches
-                              "linux-libre-support-for-Pinebook-Pro.patch"
-                              "linux-libre-infodocs-target.patch"))))
+                             (search-patch
+                              "linux-libre-support-for-Pinebook-Pro.patch"))))
 
 (define-public linux-libre-4.19-source
   (source-with-patches linux-libre-4.19-pristine-source
                        (list %boot-logo-patch
-                             %linux-libre-arm-export-__sync_icache_dcache-patch
-                             (search-patch "linux-libre-infodocs-target.patch"))))
+                             %linux-libre-arm-export-__sync_icache_dcache-patch)))
 
 (define-public linux-libre-4.14-source
   (source-with-patches linux-libre-4.14-pristine-source
-                       (list %boot-logo-patch
-                             (search-patch "linux-libre-infodocs-target.patch"))))
+                       (list %boot-logo-patch)))
 
 (define-public linux-libre-4.9-source
   (source-with-patches linux-libre-4.9-pristine-source
-                       (list %boot-logo-patch
-                             (search-patch "linux-libre-infodocs-target.patch"))))
+                       (list %boot-logo-patch)))
 
 
 ;;;
@@ -767,6 +764,11 @@ (define (config->string options)
 ;;; Kernel package utilities.
 ;;;
 
+(define (doc-supported? version)
+  ;; Versions older than 5.10 have different enough build scripts that the
+  ;; infodocs patch doesn't apply.
+  (version>=? version "5.10"))
+
 (define* (make-linux-libre version gnu-revision hash-string supported-systems
                            #:key
                            (extra-version #f)
@@ -775,11 +777,13 @@ (define* (make-linux-libre version gnu-revision hash-string supported-systems
                            (configuration-file #f)
                            (defconfig "defconfig")
                            (extra-options %default-extra-linux-options)
+                           (build-doc? (doc-supported? version))
                            (patches
-                            (list %boot-logo-patch
-                                  (search-patch
-                                   "linux-libre-infodocs-target.patch")))
-                           (build-doc? #t))
+                            `(,%boot-logo-patch
+                              ,@(if build-doc?
+                                    (list (search-patch
+                                           "linux-libre-infodocs-target.patch"))
+                                    '()))))
   (make-linux-libre* version gnu-revision
                      (origin
                        (method url-fetch)
@@ -801,7 +805,9 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
                             (configuration-file #f)
                             (defconfig "defconfig")
                             (extra-options %default-extra-linux-options)
-                            (build-doc? #t))
+                            (build-doc? (doc-supported? version)))
+  (when (and build-doc? (not (doc-supported? version)))
+    (error "unsupported 'build-doc?' for kernels <5.10"))
   (package
     (name (if extra-version
               (string-append "linux-libre-" extra-version)
@@ -948,8 +954,11 @@ (define* (make-linux-libre* version gnu-revision source supported-systems
 
        ;; For generating the documentation.
        ,@(if build-doc?
-             `(("graphviz" ,graphviz)
-               ("python" ,python)
+             ;; TODO: remove fontconfig after the 5.10 kernel is dropped.
+             ;; Also replace python-wrapper by python at that time.
+             `(("fontconfig" ,fontconfig)
+               ("graphviz" ,graphviz)
+               ("python" ,python-wrapper)
                ("python-sphinx" ,python-sphinx)
                ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
                ("texinfo" ,texinfo)
--8<---------------cut here---------------end--------------->8---

Any kernel older than 5.10 is now untouched.

-- 
Thanks,
Maxim