Subject: [bug#48443] [PATCH 1/2] gnu: Add texlive-libkpathsea.

From: Thiago Jung Bauermann <[email-masked]>
Date: Mon, 12 Jul 2021 21:32:47 -0300

Hello Leo,

I have very little experience creating Guix packages, but I spent
some time working on the TeX Live ones recently so hopefully my comments 
and suggestions below are helpful.

I like adding a separate package for libkpathsea, and it’s what other 
distros such as Debian and Ubuntu do. Thank you for implementing it. I just 
have a few comments below:

Em sábado, 15 de maio de 2021, às 11:42:29 -03, Leo Prikler escreveu:
> * gnu/packages/tex.scm (texlive-libkpathsea): New variable.
> ---
>  gnu/packages/tex.scm | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
> index b9eeb0e792..3e8384eaad 100644
> --- a/gnu/packages/tex.scm
> +++ b/gnu/packages/tex.scm
> @@ -457,6 +457,38 @@ This package contains the binaries.")
>     (license (license:fsf-free
> "https://www.tug.org/texlive/copying.html")) (home-page
> "https://www.tug.org/texlive/")))
> 
> +(define-public texlive-libkpathsea
> +  (package/inherit texlive-bin

According to a recent message from Ludo¹, ‘package/inherit’ is meant to be 
used in specific situations, and IIUC it doesn’t apply here:

> It should also be (package (inherit …) …) rather than (package/inherit
> …).  The latter is only useful when defining variants of a package (same
> version, same code) where the same security updates would apply.

I also wonder whether inheriting from texlive-bin is the best option. One 
disadvantage is that it makes this package too sensitive to changes in 
texlive-bin. As an example, it doesn’t work anymore with the version in 
core-updates because in the branch, the ‘postint’ phase has been renamed to 
‘post-install’. Also, I assume many texlive-bin inputs aren’t needed for 
texlive-kpathsea, causing unnecessary work when building
texlive-libkpathsea and packages depending on it such as evince.

In addition, if it were a separate package then texlive-bin could be made 
to use it, rather than shipping its own copy.

> +    (name "texlive-libkpathsea")
> +    (source
> +     (origin
> +       (inherit (package-source texlive-bin))

Perhaps a ‘texlive-source-src’ variable analogous to ‘texlive-extra-src’ 
and ‘texlive-texmf-src’ would be useful?

> +       (snippet
> +        `(begin
> +           ,(origin-snippet (package-source texlive-bin))
> +           (with-directory-excursion "texk"
> +             (let ((preserved-directories '("." ".." "kpathsea")))
> +               (for-each
> +                delete-file-recursively
> +                (scandir "."
> +                         (lambda (file)
> +                           (and (not (member file
> preserved-directories)) +                                (eq? 'directory
> (stat:type (stat file))))))))))))) +    (arguments
> +     (substitute-keyword-arguments (package-arguments texlive-bin)
> +       ((#:configure-flags flags)
> +        `(cons* "--disable-all-pkgs" "--enable-kpathsea"
> +                "--enable-shared" ,flags))
> +       ((#:phases phases)
> +        `(modify-phases ,phases
> +           (delete 'configure-ghostscript-executable)
> +           (delete 'use-code-for-new-poppler)
> +           (delete 'patch-dvisvgm-build-files)
> +           (delete 'disable-failing-test)
> +           (replace 'postint
> +             (lambda* (#:key inputs outputs #:allow-other-keys)
> +               (with-directory-excursion "texk/kpathsea"
> +                 (invoke "make" "install"))))))))))

If you decide to continue inheriting from texlive-bin, you’d also need to 
change the synopsis and description.

-- 
Thanks,
Thiago

¹ https://lists.gnu.org/archive/html/guix-patches/2021-07/msg00610.html