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

commit ac3b0cfb0e245e3b98b9d07ef351d385acaa1782
Author: Nicolas Goaziou <m...@nicolasgoaziou.fr>
AuthorDate: Wed May 8 16:55:25 2024 +0200

    gnu: texlive-psutils: Build executable.
    
    * gnu/packages/tex.scm (texlive-psutils): Use TEXLIVE-SOURCE to build 
binary.
    [outputs]: Only provide "out".
    [arguments]<#:configure, #:phases>: Build a a single package.  Fix tests.
    [native-inputs]: Add LIBPAPER PKG-CONFIG and TEXLIVE-LIBKPATHSEA.
    
    Change-Id: If6e71586bef3d60b105c2bdf3a7719313ba38b82
---
 gnu/packages/tex.scm | 100 +++++++++++++++++++++++++++++++++++----------------
 1 file changed, 69 insertions(+), 31 deletions(-)

diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
index 295a4099c2..dbcdeb4b91 100644
--- a/gnu/packages/tex.scm
+++ b/gnu/packages/tex.scm
@@ -41797,39 +41797,77 @@ documents generated that use Type 1 fonts.")
 
 (define-public texlive-psutils
   (package
+    (inherit texlive-bin)
     (name "texlive-psutils")
-    (version (number->string %texlive-revision))
-    (source (texlive-origin
-             name version
-             (list "doc/man/man1/epsffit.1"
-                   "doc/man/man1/epsffit.man1.pdf"
-                   "doc/man/man1/extractres.1"
-                   "doc/man/man1/extractres.man1.pdf"
-                   "doc/man/man1/includeres.1"
-                   "doc/man/man1/includeres.man1.pdf"
-                   "doc/man/man1/psbook.1"
-                   "doc/man/man1/psbook.man1.pdf"
-                   "doc/man/man1/psjoin.1"
-                   "doc/man/man1/psjoin.man1.pdf"
-                   "doc/man/man1/psnup.1"
-                   "doc/man/man1/psnup.man1.pdf"
-                   "doc/man/man1/psresize.1"
-                   "doc/man/man1/psresize.man1.pdf"
-                   "doc/man/man1/psselect.1"
-                   "doc/man/man1/psselect.man1.pdf"
-                   "doc/man/man1/pstops.1"
-                   "doc/man/man1/pstops.man1.pdf"
-                   "doc/man/man1/psutils.1"
-                   "doc/man/man1/psutils.man1.pdf"
-                   "dvips/getafm/"
-                   "psutils/"
-                   "scripts/psutils/")
-             (base32
-              "0ba514lz3pc03ll0kb9apdx62mi2yiyd7bnargkp2bbf62dq79cc")))
-    (outputs '("out" "doc"))
-    (build-system texlive-build-system)
+    (source
+     (origin
+       (inherit texlive-source)
+       (modules '((guix build utils)
+                  (ice-9 ftw)))
+       (snippet
+        #~(let ((delete-other-directories
+                 (lambda (root keep)
+                   (with-directory-excursion root
+                     (for-each
+                      delete-file-recursively
+                      (scandir
+                       "."
+                       (lambda (file)
+                         (and (not (member file (append keep '("." ".."))))
+                              (eq? 'directory (stat:type (stat file)))))))))))
+            (delete-other-directories "libs" '())
+            (delete-other-directories "utils" '())
+            (delete-other-directories "texk" '("psutils"))))))
     (arguments
-     (list #:link-scripts #~(list "extractres.pl" "includeres.pl" 
"psjoin.pl")))
+     (substitute-keyword-arguments (package-arguments texlive-bin)
+       ((#:configure-flags flags)
+        #~(cons* "--disable-all-pkgs"
+                 "--enable-psutils"
+                 "--with-system-libpaper"
+                 (delete "--disable-psutils" #$flags)))
+       ((#:phases _)
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'patch-psutils-tests
+              (lambda _
+                ;; This test fails due to a rounding difference with libpaper
+                ;; 1.2: <https://github.com/rrthomas/libpaper/issues/23>.
+                ;;
+                ;; Adjust the expected outcome to account for the minute
+                ;; difference.
+                (substitute* "texk/psutils/tests/playres.ps"
+                  (("844\\.647799") "844.647797"))
+                ;; Test suite also fails because it expects to find
+                ;; "texmf.cnf" in "../kpathsea/" directory, but we removed it
+                ;; in a snippet.  Point to the real "texmf.cnf".
+                (let ((kpathsea
+                       #$(this-package-native-input "texlive-libkpathsea")))
+                  (substitute* "texk/psutils/psutils.test"
+                    (("(TEXMFCNF=).+?;" _ var)
+                     (string-append var
+                                    kpathsea
+                                    "/share/texmf-dist/web2c;"))))))
+            (replace 'check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (with-directory-excursion "texk/psutils"
+                    (invoke "make" "check")))))
+            (replace 'install
+              (lambda* (#:key inputs native-inputs #:allow-other-keys)
+                (with-directory-excursion "texk/psutils"
+                  (invoke "make" "install"))
+                (install-file
+                 (search-input-file (or native-inputs inputs)
+                                    "dvips/getafm/getafm.ps")
+                 (string-append #$output
+                                "/share/texmf-dist/dvips/getafm"))))))))
+    (native-inputs
+     (list libpaper pkg-config texlive-libkpathsea
+           ;; The "getafm.ps" file is not generated during build.  Grab it
+           ;; from TeX Live repository.
+           (texlive-origin
+            name (package-version texlive-bin) (list "dvips/getafm/")
+            (base32
+             "1bka39j1phx5bvvcyvbcgd7hgca19kvr1db0ag8m82wy8mvd1mc2"))))
     (inputs (list perl))
     (home-page "https://ctan.org/pkg/psutils";)
     (synopsis "PostScript utilities")

Reply via email to