[bug#34118] guix: Add guard to texlive-configuration profile hook.

Message ID 20190117210217.18351-1-mail@cbaines.net
State Accepted
Commit cf22e99f0252a4712ab94d630dc4914c9a89f18d
Headers show
Series [bug#34118] guix: Add guard to texlive-configuration profile hook. | expand

Checks

Context Check Description
cbaines/applying patch fail Apply failed

Commit Message

Christopher Baines Jan. 17, 2019, 9:02 p.m. UTC
It is possible to generate a profile where this hook will crash, as the
texmf.cnf file does not exist to be patched by substitute*. A simple example
is the profile just containing texlive-fonts-txfonts.

* guix/profiles.scm (texlive-configuration): Check that the texmf.cnf file
exists before trying to change it.
---
 guix/profiles.scm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Comments

Ludovic Courtès Jan. 18, 2019, 3:51 p.m. UTC | #1
Hello,

Christopher Baines <mail@cbaines.net> skribis:

> It is possible to generate a profile where this hook will crash, as the
> texmf.cnf file does not exist to be patched by substitute*. A simple example
> is the profile just containing texlive-fonts-txfonts.
>
> * guix/profiles.scm (texlive-configuration): Check that the texmf.cnf file
> exists before trying to change it.

LGTM, thanks!

Ludo'.
Christopher Baines Jan. 18, 2019, 4:19 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:

> Hello,
>
> Christopher Baines <mail@cbaines.net> skribis:
>
>> It is possible to generate a profile where this hook will crash, as the
>> texmf.cnf file does not exist to be patched by substitute*. A simple example
>> is the profile just containing texlive-fonts-txfonts.
>>
>> * guix/profiles.scm (texlive-configuration): Check that the texmf.cnf file
>> exists before trying to change it.
>
> LGTM, thanks!

Great, I've pushed this to master now.

Patch

diff --git a/guix/profiles.scm b/guix/profiles.scm
index d22539bdb2..598e0acf62 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1363,12 +1363,15 @@  MANIFEST."
                                       (manifest-entries manifest))
                        #:create-all-directories? #t
                        #:log-port (%make-void-port "w"))
-          (substitute* (string-append #$output
-                                      "/share/texmf-dist/web2c/texmf.cnf")
-            (("^TEXMFROOT = .*")
-             (string-append "TEXMFROOT = " #$output "/share\n"))
-            (("^TEXMF = .*")
-             "TEXMF = $TEXMFROOT/share/texmf-dist\n"))
+          (let ((texmf.cnf (string-append
+                            #$output
+                            "/share/texmf-dist/web2c/texmf.cnf")))
+            (when (file-exists? texmf.cnf)
+              (substitute* texmf.cnf
+                (("^TEXMFROOT = .*")
+                 (string-append "TEXMFROOT = " #$output "/share\n"))
+                (("^TEXMF = .*")
+                 "TEXMF = $TEXMFROOT/share/texmf-dist\n"))))
           #t)))
 
     (with-monad %store-monad