Subject: [PATCH RFC 4/4] gnu: Add perl-tex-autotex.

From: Liliana Marie Prikler <[email-masked]>
Date: Sun, 18 Feb 2024 00:16:07 +0100

* gnu/packages/perl-tex.scm (perl-tex-autotex): New variable.
---
 gnu/packages/perl-tex.scm | 56 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/perl-tex.scm b/gnu/packages/perl-tex.scm
index 315d34856f..c2f04547ad 100644
--- a/gnu/packages/perl-tex.scm
+++ b/gnu/packages/perl-tex.scm
@@ -19,9 +19,13 @@
 (define-module (gnu packages perl-tex)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
+  #:use-module (guix gexp)
   #:use-module (guix download)
   #:use-module (guix build-system perl)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bash)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages mail)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages tex))
 
@@ -42,3 +46,55 @@ (define-public perl-arxiv
     (description "This package contains perl modules with utility procedures
 used by other perl software at arXiv.org, most notably AutoTeX.")
     (license license:perl-license)))
+
+(define-public perl-tex-autotex
+  (package
+   (name "perl-tex-autotex")
+   (version "0.906.0")
+   (source
+    (origin
+     (method url-fetch)
+     (uri (string-append
+           "mirror://cpan/authors/id/T/TS/TSCHWAND/TeX-AutoTeX-v" version
+           ".tar.gz"))
+     (sha256
+      (base32 "1iz64g0a22kb8h8gpkqrc9yxdyr3lvylznvlkpf2a9xanfjr5fki"))))
+   (build-system perl-build-system)
+   (arguments
+    (list
+     #:phases
+     #~(modify-phases %standard-phases
+         (add-after 'unpack 'patch-config
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* "lib/TeX/AutoTeX/Config.pm"
+               (("(\\$DEFAULT_BRANCH[ ]*=).*;" all assign)
+                ;; XXX: Get year or smth
+                (string-append assign " 'texlive/guix';"))
+               (("/opt/texlive/[0-9]*/bin/arch")
+                (dirname (search-input-file inputs "/bin/tex")))
+               (("^(\\$AUTOTEX_ENV_PATH[ ]*=).*;" all assign)
+                (string-append assign " '"
+                               (string-join
+                                (map (lambda (bin)
+                                       (dirname (search-input-file inputs bin)))
+                                     '("/bin/sh"
+                                       "/bin/sed"
+                                       ;; coreutils
+                                       "/bin/yes"))
+                                ":")
+                               "';"))
+               (("/usr/bin/sendmail")
+                (search-input-file inputs "/bin/sendmail"))))))))
+   (inputs (list bash-minimal coreutils sed sendmail
+                 texlive-scheme-basic))
+   (propagated-inputs (list perl-arxiv perl-cam-pdf perl-class-accessor
+                            perl-error))
+   (native-inputs (list perl-module-build))
+   (home-page "https://metacpan.org/release/TeX-AutoTeX")
+   (synopsis "Automatically process (La-)TeX sources")
+   (description "AutoTeX is the basis for arXiv's automatic (La-)TeX
+processing.  The normal use is to point it at a directory with an assortment
+of files in it, and the @code{process} method will attempt to generate DVI,
+PostScript, or PDF from the input based on heuristics.  The resulting file(s)
+remain in the same directory.")
+   (license license:gpl3+)))
-- 
2.41.0