Subject: bug#40783: GNU FreeFont silent build failure

From: Leo Famulari <[email-masked]>
Date: Wed, 22 Apr 2020 17:51:26 -0400

The GNU FreeFont package is still using system* instead of invoke in its
install phase, and this is failing silently:

------
mkdir /gnu/store/1nfp73g3s15dhpqjrbfsihk7jrcbbl1p-font-gnu-freefont-20120503/share/doc/font-gnu-freefont-20120503
cp -a README AUTHORS CREDITS COPYING ChangeLog INSTALL  /gnu/store/1nfp73g3s15dhpqjrbfsihk7jrcbbl1p-font-gnu-freefont-20120503/share/doc/font-gnu-freefont-20120503
cp -a notes/usage.txt /gnu/store/1nfp73g3s15dhpqjrbfsihk7jrcbbl1p-font-gnu-freefont-20120503/share/doc/font-gnu-freefont-20120503/USAGE
cp -a notes/troubleshooting.txt /gnu/store/1nfp73g3s15dhpqjrbfsihk7jrcbbl1p-font-gnu-freefont-20120503/share/doc/font-gnu-freefont-20120503/TROUBLESHOOTING
tar czvf freefont-ttf-20200422.tar.gz freefont-20200422/
tar: freefont-20200422: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
make: *** [Makefile:64: ttftar] Error 2
phase `install' succeeded after 0.2 seconds
------

Notice that it is using the current date. It doesn't work to use the
Unix epoch or the version of the package: 20120503 (see attached).

We should figure out what this is trying to accomplish, fix it, and
switch to invoke.

The fonts are getting installed AFAICT.
>From a3c8951e2a8a1dc76aa184272fcb107c90246518 Mon Sep 17 00:00:00 2001
From: Raghav Gururajan <[email-masked]>
Date: Sun, 19 Apr 2020 00:51:54 -0400
Subject: [PATCH] gnu: GNU FreeFont: Add otf and woff font formats.

* gnu/packages/fonts.scm (font-gnu-freefont)[arguments]: Add otf and woff font
formats.
* gnu/packages/genealogy.scm (gramps)[inputs]: Change input name of GNU
Freefont.

Signed-off-by: Leo Famulari <[email-masked]>
---
 gnu/packages/fonts.scm     | 68 ++++++++++++++++++++++++++------------
 gnu/packages/genealogy.scm |  2 +-
 2 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 9ab5587b98..f1cabf9202 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -32,6 +32,7 @@
 ;;; Copyright © 2020 Amin Bandali <[email-masked]>
 ;;; Copyright © 2020 Michael Rohleder <[email-masked]>
 ;;; Copyright © 2020 John Soo <[email-masked]>
+;;; Copyright © 2020 Raghav Gururajan <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -232,9 +233,9 @@ The Lato 2.010 family supports more than 100 Latin-based languages, over
 50 Cyrillic-based languages as well as Greek and IPA phonetics.")
     (license license:silofl1.1)))
 
-(define-public font-gnu-freefont-ttf
+(define-public font-gnu-freefont
   (package
-    (name "font-gnu-freefont-ttf")
+    (name "font-gnu-freefont")
     (version "20120503")
     (source (origin
              (method url-fetch)
@@ -245,25 +246,50 @@ The Lato 2.010 family supports more than 100 Latin-based languages, over
                "0yk58blhcd4hm7nyincmqq4jrzjjk82wif2zmk1l3y2m4vif4qhd"))))
     (build-system gnu-build-system)
     (arguments
-     `(#:phases (modify-phases %standard-phases
-                  (delete 'configure)
-                  (replace 'install
-                   (lambda _
-                     (let ((doc-dir  (string-append %output "/share/doc/"
-                                                    ,name "-" ,version))
-                           (font-dir (string-append %output
-                                                    "/share/fonts/truetype")))
-                       (mkdir-p doc-dir)
-                       (substitute* "Makefile"
-                         (("\\$\\(TMPDIR\\)") doc-dir)
-                         (("sfd/\\*.ttf") ""))
-                       (system* "make" "ttftar")
-                       (mkdir-p font-dir)
-                       (for-each (lambda (file)
-                                   (install-file file font-dir))
-                                 (filter
-                                   (lambda (file) (string-suffix? "ttf" file))
-                                   (find-files "." "")))))))
+     `(#:modules ((srfi srfi-19) ; make-time, et cetera
+                  (guix build utils)
+                  (guix build gnu-build-system))
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (replace 'install
+          (lambda _
+            (let ((doc-dir  (string-append %output "/share/doc/"
+                                           ,name "-" ,version))
+                  (ttf-font-dir (string-append %output
+                                               "/share/fonts/ttf"))
+                  (otf-font-dir (string-append %output
+                                               "/share/fonts/otf"))
+                  (woff-font-dir (string-append %output
+                                                "/share/fonts/woff")))
+              (mkdir-p doc-dir)
+              (substitute* "Makefile"
+                (("\\$\\(TMPDIR\\)") doc-dir)
+                (("sfd/\\*.ttf") "")
+                (("sfd/\\*.otf") "")
+                (("sfd/\\*.woff") ""))
+              ;; XXX The FreeFont Makefile tries to use the current time and
+              ;; date as names for generated files, and fails silently. But the
+              ;; fonts are still installed, so don't use INVOKE for now.
+              (system* "make" "ttftar" "otftar" "wofftar")
+              (mkdir-p ttf-font-dir)
+              (mkdir-p otf-font-dir)
+              (mkdir-p woff-font-dir)
+              (for-each (lambda (file)
+                          (install-file file ttf-font-dir))
+                        (filter
+                          (lambda (file) (string-suffix? "ttf" file))
+                          (find-files "." "")))
+              (for-each (lambda (file)
+                          (install-file file otf-font-dir))
+                        (filter
+                          (lambda (file) (string-suffix? "otf" file))
+                          (find-files "." "")))
+              (for-each (lambda (file)
+                          (install-file file woff-font-dir))
+                        (filter
+                          (lambda (file) (string-suffix? "woff" file))
+                          (find-files "." "")))))))
        #:test-target "tests"))
     ;; replace python 3 with python 2
     ;; python 3 support commits aren't yet released in 20120503
diff --git a/gnu/packages/genealogy.scm b/gnu/packages/genealogy.scm
index 869f69add8..79b24ed048 100644
--- a/gnu/packages/genealogy.scm
+++ b/gnu/packages/genealogy.scm
@@ -55,7 +55,7 @@
        ("intltool" ,intltool)))
     (inputs
      `(("cairo" ,cairo)
-       ("font-gnu-freefont-ttf" ,font-gnu-freefont-ttf)
+       ("font-gnu-freefont" ,font-gnu-freefont)
        ("geocode-glib" ,geocode-glib)
        ("gexiv2" ,gexiv2)
        ("ghostscript" ,ghostscript)
-- 
2.26.2