ngz pushed a commit to branch tex-team
in repository guix.

commit a88bb3c01d8f82c61b2f2083a181948c6e299488
Author: Nicolas Goaziou <m...@nicolasgoaziou.fr>
AuthorDate: Mon May 13 09:30:16 2024 +0200

    gnu: texlive-bibtex8: Build executable.
    
    * gnu/packages/tex.scm (texlive-bibtex8-bin): New variable.
    (texlive-bibtex8)[arguments]<#:phases>: Include executable.
    [native-inputs]: Add TEXLIVE-BIBTEX8-BIN.
    
    Change-Id: Ibf5ea7150d9bb6a8979a22f736886ebded2427a5
---
 gnu/packages/tex.scm | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 76 insertions(+)

diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
index ce3853de17..41d94f9964 100644
--- a/gnu/packages/tex.scm
+++ b/gnu/packages/tex.scm
@@ -33610,6 +33610,71 @@ Japanese, for XeLaTeX.")
     (description "This package provides a BibLaTeX and Biber cheat sheet.")
     (license license:lppl1.3+)))
 
+(define texlive-bibtex8-bin
+  (package
+    (inherit texlive-bin)
+    (name "texlive-bibtex8-bin")
+    (source
+     (origin
+       (inherit texlive-source)
+       (modules '((guix build utils)
+                  (ice-9 ftw)))
+       (snippet
+        #~(let ((delete-other-directories
+                 (lambda (root dirs with-files?)
+                   (with-directory-excursion root
+                     (for-each
+                      delete-file-recursively
+                      (scandir
+                       "."
+                       (lambda (file)
+                         (and (not (member file (append '("." "..") dirs)))
+                              (or with-files?
+                                  (eq? 'directory (stat:type (stat 
file))))))))))))
+            (delete-other-directories "libs" '() #f)
+            (delete-other-directories "utils" '() #f)
+            ;; Tests require "texmf.cnf" to be present in the tree.  Also test
+            ;; data is spread across multiple directories, which need to be
+            ;; preserved.
+            (delete-other-directories "texk" '("bibtex-x" "kpathsea" "tests" 
"web2c") #f)
+            (delete-other-directories "texk/web2c" '("tests") #t)
+            (with-directory-excursion "texk/kpathsea"
+              (for-each
+               delete-file-recursively
+               (scandir "." (lambda (f)
+                              (not (member f '("." ".." "texmf.cnf")))))))))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments texlive-bin)
+       ((#:configure-flags flags)
+        #~(cons* "--enable-bibtex-x"
+                 "--enable-bibtex8"
+                 "--disable-bibtexu"
+                 (delete "--enable-web2c" #$flags)))
+       ((#:phases _)
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'locate-libkpathsea
+              (lambda _
+                (let ((kpathsea #$(this-package-input "texlive-libkpathsea")))
+                  (substitute* "texk/bibtex-x/Makefile.in"
+                    (("(KPATHSEA_LIBS =).*" _ lead)
+                     (format #f "~a \"-L~a/lib -lkpathsea\"\n" lead 
kpathsea))))))
+            (add-after 'unpack 'skip-bibtexu-test
+              ;; This package does not build "bibtexu" binary; the test below
+              ;; is therefore bound to fail.  Skip that part.
+              (lambda _
+                (substitute* "texk/bibtex-x/tests/bibtex8u-mem.test"
+                  (("\\./bibtexu .*") "exit 0\n"))))
+            (replace 'check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (with-directory-excursion "texk/bibtex-x"
+                    (invoke "make" "check")))))
+            (replace 'install
+              (lambda _
+                (with-directory-excursion "texk/bibtex-x"
+                  (invoke "make" "install"))))))))
+    (inputs '())))
+
 (define-public texlive-bibtex8
   (package
     (name "texlive-bibtex8")
@@ -33623,6 +33688,17 @@ Japanese, for XeLaTeX.")
               "1ywv5rdk08dnrqr09pnjzff37x2c9m5i1wjzfsjnvm068is58c7s")))
     (outputs '("out" "doc"))
     (build-system texlive-build-system)
+    (arguments
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'install 'install-bin
+                 (lambda _
+                   (let ((source
+                          #$(this-package-native-input "texlive-bibtex8-bin")))
+                     (copy-recursively (string-append source "/bin")
+                                       (string-append #$output "/bin"))))))))
+
+    (native-inputs (list texlive-bibtex8-bin))
     (home-page "https://ctan.org/pkg/bibtex8";)
     (synopsis "BibTeX variant supporting 8-bit encodings")
     (description

Reply via email to