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

From: Leo Prikler <[email-masked]>
Date: Sat, 15 May 2021 16:42:29 +0200

* 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
+    (name "texlive-libkpathsea")
+    (source
+     (origin
+       (inherit (package-source texlive-bin))
+       (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"))))))))))
 
 (define texlive-docstrip
   (package
-- 
2.31.1