[PATCH] guix: Restore profile hook for TeX Live font maps.

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Ricardo Wurmus
Owner
unassigned
Submitted by
Ricardo Wurmus
Severity
normal
R
R
Ricardo Wurmus wrote on 28 Jan 2022 19:18
(address . guix-patches@gnu.org)(name . Ricardo Wurmus)(address . rekado@elephly.net)
20220128181801.14998-1-rekado@elephly.net
* gnu/packages/tex.scm (texlive-default-updmap.cfg): New variable.
* guix/profiles.scm (texlive-configuration): Rename this...
(texlive-font-maps): ...to this; update to run updmap-sys on the contents of
the profile to generate only font maps.
(%default-profile-hooks): Add texlive-font-maps.
* guix/status.scm (hook-message): Rename unused texlive-configuration to
texlive-font-maps.
---
gnu/packages/tex.scm | 12 ++++++
guix/profiles.scm | 99 +++++++++++++++++++-------------------------
guix/status.scm | 4 +-
3 files changed, 56 insertions(+), 59 deletions(-)

Toggle diff (175 lines)
diff --git a/gnu/packages/tex.scm b/gnu/packages/tex.scm
index 89f60f89d5..72437ce2f6 100644
--- a/gnu/packages/tex.scm
+++ b/gnu/packages/tex.scm
@@ -4314,6 +4314,18 @@ (define-public texlive-base
'()
default-packages)))))
+(define-public texlive-default-updmap.cfg
+ (origin
+ (method url-fetch)
+ (uri (string-append "https://tug.org/svn/texlive/tags/"
+ %texlive-tag "/Master/texmf-dist/web2c/updmap.cfg"
+ "?revision=" (number->string %texlive-revision)))
+ (file-name (string-append "updmap.cfg-"
+ (number->string %texlive-revision)))
+ (sha256
+ (base32
+ "0zhpyld702im6352fwp41f2hgfkpj2b4j1kfsjqbkijlcmvb6w2c"))))
+
;;; TODO: Add a TeX Live profile hook computing fonts maps (and others?)
;;; configuration from the packages in the profile, similar to what's done
;;; below.
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 1d354ecb78..403dbc18ed 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1738,8 +1738,8 @@ (define (manual-database/optional manifest)
(manual-database manifest)
(return #f))))
-(define (texlive-configuration manifest)
- "Return a derivation that builds a TeXlive configuration for the entries in
+(define (texlive-font-maps manifest)
+ "Return a derivation that builds the TeX Live font maps for the entries in
MANIFEST."
(define entry->texlive-input
(match-lambda
@@ -1768,72 +1768,56 @@ (define build
;; Build a modifiable union of all texlive inputs. We do this so
;; that TeX live can resolve the parent and grandparent directories
;; correctly. There might be a more elegant way to accomplish this.
- (union-build #$output
+ (union-build "/tmp/texlive"
'#$(append-map entry->texlive-input
(manifest-entries manifest))
#:create-all-directories? #t
#:log-port (%make-void-port "w"))
- (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"))
-
- ;; XXX: This is annoying, but it's necessary because texlive-bin
- ;; does not provide wrapped executables.
- (setenv "PATH"
- (string-append #$(file-append coreutils "/bin")
- ":"
- #$(file-append sed "/bin")))
- (setenv "PERL5LIB" #$(file-append texlive-bin "/share/tlpkg"))
- (setenv "TEXMF" (string-append #$output "/share/texmf-dist"))
-
- ;; Remove invalid maps from config file.
- (let* ((web2c (string-append #$output "/share/texmf-config/web2c/"))
- (maproot (string-append #$output "/share/texmf-dist/fonts/map/"))
- (updmap.cfg (string-append web2c "updmap.cfg")))
- (mkdir-p web2c)
-
- ;; Some profiles may already have this file, which prevents us
- ;; from copying it. Since we need to generate it from scratch
- ;; anyway, we delete it here.
- (when (file-exists? updmap.cfg)
- (delete-file updmap.cfg))
- (copy-file #$updmap.cfg updmap.cfg)
- (make-file-writable updmap.cfg)
- (let* ((port (open-pipe* OPEN_WRITE
- #$(file-append texlive-bin "/bin/updmap-sys")
- "--syncwithtrees"
- "--nohash"
- "--force"
- (string-append "--cnffile=" web2c "updmap.cfg"))))
- (display "Y\n" port)
- (when (not (zero? (status:exit-val (close-pipe port))))
- (error "failed to filter updmap.cfg")))
-
- ;; Generate font maps.
- (invoke #$(file-append texlive-bin "/bin/updmap-sys")
- (string-append "--cnffile=" web2c "updmap.cfg")
- (string-append "--dvipdfmxoutputdir="
- maproot "updmap/dvipdfmx/")
- (string-append "--dvipsoutputdir="
- maproot "updmap/dvips/")
- (string-append "--pdftexoutputdir="
- maproot "updmap/pdftex/")))))
- #t)))
+
+ ;; XXX: This is annoying, but it's necessary because texlive-bin
+ ;; does not provide wrapped executables.
+ (setenv "PATH"
+ (string-append #$(file-append coreutils "/bin")
+ ":"
+ #$(file-append sed "/bin")))
+ (setenv "PERL5LIB" #$(file-append texlive-bin "/share/tlpkg"))
+ (setenv "GUIX_TEXMF" "/tmp/texlive/share/texmf-dist")
+
+ ;; Remove invalid maps from config file.
+ (let* ((web2c (string-append #$output "/share/texmf-dist/web2c/"))
+ (maproot (string-append #$output "/share/texmf-dist/fonts/map/"))
+ (updmap.cfg (string-append web2c "updmap.cfg")))
+ (mkdir-p web2c)
+ (copy-file #$updmap.cfg updmap.cfg)
+ (make-file-writable updmap.cfg)
+ (let* ((port (open-pipe* OPEN_WRITE
+ #$(file-append texlive-bin "/bin/updmap-sys")
+ "--syncwithtrees"
+ "--nohash"
+ "--force"
+ (string-append "--cnffile=" updmap.cfg))))
+ (display "Y\n" port)
+ (when (not (zero? (status:exit-val (close-pipe port))))
+ (error "failed to filter updmap.cfg")))
+
+ ;; Generate font maps.
+ (invoke #$(file-append texlive-bin "/bin/updmap-sys")
+ (string-append "--cnffile=" updmap.cfg)
+ (string-append "--dvipdfmxoutputdir="
+ maproot "dvipdfmx/updmap")
+ (string-append "--dvipsoutputdir="
+ maproot "dvips/updmap")
+ (string-append "--pdftexoutputdir="
+ maproot "pdftex/updmap"))))))
(mlet %store-monad ((texlive-base (manifest-lookup-package manifest "texlive-base")))
(if texlive-base
- (gexp->derivation "texlive-configuration" build
+ (gexp->derivation "texlive-font-maps" build
#:substitutable? #f
#:local-build? #t
#:properties
`((type . profile-hook)
- (hook . texlive-configuration)))
+ (hook . texlive-font-maps)))
(return #f))))
(define %default-profile-hooks
@@ -1849,6 +1833,7 @@ (define %default-profile-hooks
glib-schemas
gtk-icon-themes
gtk-im-modules
+ texlive-font-maps
xdg-desktop-database
xdg-mime-database))
diff --git a/guix/status.scm b/guix/status.scm
index eefe18365f..fba28765df 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -395,8 +395,8 @@ (define (hook-message hook-type)
(G_ "building XDG MIME database..."))
('fonts-dir
(G_ "building fonts directory..."))
- ('texlive-configuration
- (G_ "building TeX Live configuration..."))
+ ('texlive-font-maps
+ (G_ "building TeX Live font maps..."))
('manual-database
(G_ "building database for manual pages..."))
('package-cache ;package cache generated by 'guix pull'
--
2.34.0
L
L
Ludovic Courtès wrote on 1 Feb 2022 00:02
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 53613@debbugs.gnu.org)
87iltz8q6m.fsf@gnu.org
Hi!

Ricardo Wurmus <rekado@elephly.net> skribis:

Toggle quote (8 lines)
> * gnu/packages/tex.scm (texlive-default-updmap.cfg): New variable.
> * guix/profiles.scm (texlive-configuration): Rename this...
> (texlive-font-maps): ...to this; update to run updmap-sys on the contents of
> the profile to generate only font maps.
> (%default-profile-hooks): Add texlive-font-maps.
> * guix/status.scm (hook-message): Rename unused texlive-configuration to
> texlive-font-maps.

Out of curiosity, what does it fix, and how does it relate to past
changes in this area (looks like ‘texlive-configuration’ was added, then
removed, then reintroduced)?

I’m asking for documentation purposes because I trust your judgment
anyway. :-)

Thanks,
Ludo’.
R
R
Ricardo Wurmus wrote on 1 Feb 2022 00:08
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 53613@debbugs.gnu.org)
87pmo78p0r.fsf@elephly.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (17 lines)
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
>> * gnu/packages/tex.scm (texlive-default-updmap.cfg): New variable.
>> * guix/profiles.scm (texlive-configuration): Rename this...
>> (texlive-font-maps): ...to this; update to run updmap-sys on the contents of
>> the profile to generate only font maps.
>> (%default-profile-hooks): Add texlive-font-maps.
>> * guix/status.scm (hook-message): Rename unused texlive-configuration to
>> texlive-font-maps.
>
> Out of curiosity, what does it fix, and how does it relate to past
> changes in this area (looks like ‘texlive-configuration’ was added, then
> removed, then reintroduced)?
>
> I’m asking for documentation purposes because I trust your judgment
> anyway. :-)

The profile hook was called “texlive-configuration” because it would
create a customized texmf.cnf, the main configuration file for the whole
TeX Live tree.

Back then I saw no other way to support a modular TeX Live tree than to
operate on the texlive-* packages that have actually been installed in
the profile, build a union directory (hence the procedure name
“texlive-union”, which did the same thing but for packages), and then
install a texmf.cnf file that declared the prefix of the TeX Live tree
to be the union directory.

This was what the “texlive-configuration” hook primarily accomplished:
build the union, patch and install texmf.cnf. It then proceeded to
operate on that union directory and generated font maps based on the
fonts that had actually been installed.

This approach had multiple disadvantages, the worst of which was that
you could only really have one TeX Live tree. Maxim addressed this in
commit 04a0b1e09abce99857e7930336421ca6d15ae630, where texmf.cnf was
modified *once* and for all in texlive-bin to reference the GUIX_TEXMF
variable to determine the root of the tree. This made much of
“texlive-configuration” (and “texlive-union”) obsolete, because we
didn’t need to have any union directories at all, because we had no need
for a customized per-profile variant of texmf.cnf.

Unfortunately, this change threw out the font-map-sized baby with the
texmf.cnf-infested bath water. The effect of that was barely noticeable
because font maps are weird and aren’t always used. Besides, we had a
couple of other font-related problems (e.g. invalid assumptions about
directory links in kpathsea), which masked this newly introduced
problem.

This patch pulls the baby out of the drain: we’re again generating font
maps (such as pdftex.map) based on the contents of the profile.

An alternative would be to install fully featured static font maps,
which would almost always be completely wrong, because they would refer
to fonts that haven’t been installed. The profile hook ensures a) that
the expected font map files exist and b) that they contain nothing
beyond valid entries that correspond to the profile contents.

Does this really solve problems? I don’t know. I think it’s the right
thing to do (and thus makes our modular TeX Live less wrong), but it
didn’t solve mysteries like that koma-script bug that seems to be
related to a missing font map file. The koma-script bug remains because
the font map file is ignored.

So … there’s more to fixing everything that’s wrong with fonts in our
modular TeX Live, but we’ve been chipping at it with commits like
4d2c861dfbd49f0e1619fda5dbf18e4cb5bca1d0,
2a5ed25c412e162505b2b371d00987fd158a91d4, and the like — this is
another one of these small things that should get us closer to the
platonic ideal of fonts with TeX Live. I hope.

--
Ricardo
L
L
Ludovic Courtès wrote on 1 Feb 2022 10:22
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 53613@debbugs.gnu.org)
87r18n54cc.fsf@gnu.org
Howdy!

Ricardo Wurmus <rekado@elephly.net> skribis:

[...]

Toggle quote (10 lines)
> Unfortunately, this change threw out the font-map-sized baby with the
> texmf.cnf-infested bath water. The effect of that was barely noticeable
> because font maps are weird and aren’t always used. Besides, we had a
> couple of other font-related problems (e.g. invalid assumptions about
> directory links in kpathsea), which masked this newly introduced
> problem.
>
> This patch pulls the baby out of the drain: we’re again generating font
> maps (such as pdftex.map) based on the contents of the profile.

Oh, I see, makes perfect sense.

Should some of this go in the commit log?

[...]

Toggle quote (6 lines)
> Does this really solve problems? I don’t know. I think it’s the right
> thing to do (and thus makes our modular TeX Live less wrong), but it
> didn’t solve mysteries like that koma-script bug that seems to be
> related to a missing font map file. The koma-script bug remains because
> the font map file is ignored.

I didn’t see how the koma-script bug could relate to fonts but your
explanation at https://issues.guix.gnu.org/33094 looks plausible to my
(untrained) eye.

Thanks for explaining and fixing this!

Ludo’.
L
L
Ludovic Courtès wrote on 10 Feb 2022 22:20
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 53613@debbugs.gnu.org)
87r18a2zby.fsf_-_@gnu.org
Hello!

Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (18 lines)
> Ricardo Wurmus <rekado@elephly.net> skribis:
>
> [...]
>
>> Unfortunately, this change threw out the font-map-sized baby with the
>> texmf.cnf-infested bath water. The effect of that was barely noticeable
>> because font maps are weird and aren’t always used. Besides, we had a
>> couple of other font-related problems (e.g. invalid assumptions about
>> directory links in kpathsea), which masked this newly introduced
>> problem.
>>
>> This patch pulls the baby out of the drain: we’re again generating font
>> maps (such as pdftex.map) based on the contents of the profile.
>
> Oh, I see, makes perfect sense.
>
> Should some of this go in the commit log?

To be clear, I think you can go ahead and commit it, possibly with an
extra comment if you feel so inclined.

Thanks again,
Ludo’.
R
R
Ricardo Wurmus wrote on 10 Feb 2022 22:39
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 53613-done@debbugs.gnu.org)
87iltmv1no.fsf@elephly.net
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (25 lines)
> Hello!
>
> Ludovic Courtès <ludo@gnu.org> skribis:
>
>> Ricardo Wurmus <rekado@elephly.net> skribis:
>>
>> [...]
>>
>>> Unfortunately, this change threw out the font-map-sized baby with the
>>> texmf.cnf-infested bath water. The effect of that was barely noticeable
>>> because font maps are weird and aren’t always used. Besides, we had a
>>> couple of other font-related problems (e.g. invalid assumptions about
>>> directory links in kpathsea), which masked this newly introduced
>>> problem.
>>>
>>> This patch pulls the baby out of the drain: we’re again generating font
>>> maps (such as pdftex.map) based on the contents of the profile.
>>
>> Oh, I see, makes perfect sense.
>>
>> Should some of this go in the commit log?
>
> To be clear, I think you can go ahead and commit it, possibly with an
> extra comment if you feel so inclined.

That’s how I understood it. I did go ahead and pushed it with an
explanation in the commit message.

Thanks for the review!

--
Ricardo
Closed
?