From: Huang Ying <huang.ying.caritas@gmail.com>
To: guix-devel@gnu.org
Cc: guix-patches@gnu.org
Subject: [PATCH -v3 2/2] guix: profiles: create fonts.dir/scale for all fonts directories
Date: Sun, 12 Mar 2017 19:53:59 +0800 [thread overview]
Message-ID: <20170312115359.23318-2-huang.ying.caritas@gmail.com> (raw)
In-Reply-To: <20170312115359.23318-1-huang.ying.caritas@gmail.com>
* guix/profiles.scm (fonts-dir-file): Create fonts.dir/scale files for all
fonts directories.
---
guix/profiles.scm | 60 ++++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 44 insertions(+), 16 deletions(-)
diff --git a/guix/profiles.scm b/guix/profiles.scm
index de82eae34..6fb101154 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -877,9 +877,12 @@ entries. It's used to query the MIME type of a given file."
#:substitutable? #f)
(return #f))))
+;; Several font packages may install font files into same directory, so
+;; fonts.dir and fonts.scale file should be generated here, instead of in
+;; packages.
(define (fonts-dir-file manifest)
"Return a derivation that builds the @file{fonts.dir} and @file{fonts.scale}
-files for the truetype fonts of the @var{manifest} entries."
+files for the fonts of the @var{manifest} entries."
(define mkfontscale
(module-ref (resolve-interface '(gnu packages xorg)) 'mkfontscale))
@@ -891,29 +894,54 @@ files for the truetype fonts of the @var{manifest} entries."
(use-modules (srfi srfi-26)
(guix build utils)
(guix build union))
- (let ((ttf-dirs (filter file-exists?
- (map (cut string-append <>
- "/share/fonts/truetype")
- '#$(manifest-inputs manifest)))))
+ (let ((fonts-dirs (filter file-exists?
+ (map (cut string-append <>
+ "/share/fonts")
+ '#$(manifest-inputs manifest)))))
(mkdir #$output)
- (if (null? ttf-dirs)
+ (if (null? fonts-dirs)
(exit #t)
- (let* ((fonts-dir (string-append #$output "/share/fonts"))
- (ttf-dir (string-append fonts-dir "/truetype"))
+ (let* ((share-dir (string-append #$output "/share"))
+ (fonts-dir (string-append share-dir "/fonts"))
(mkfontscale (string-append #+mkfontscale
"/bin/mkfontscale"))
(mkfontdir (string-append #+mkfontdir
- "/bin/mkfontdir")))
- (mkdir-p fonts-dir)
- (union-build ttf-dir ttf-dirs
- #:log-port (%make-void-port "w"))
- (with-directory-excursion ttf-dir
- (exit (and (zero? (system* mkfontscale))
- (zero? (system* mkfontdir))))))))))
+ "/bin/mkfontdir"))
+ (empty-file? (lambda (filename)
+ (call-with-ascii-input-file filename
+ (lambda (p)
+ (eqv? #\0 (read-char p))))))
+ (fonts-dir-file "fonts.dir")
+ (fonts-scale-file "fonts.scale"))
+ (mkdir-p share-dir)
+ ;; Create all sub-directories, because we may create fonts.dir
+ ;; and fonts.scale files in the sub-directories.
+ (union-build fonts-dir fonts-dirs
+ #:log-port (%make-void-port "w")
+ #:create-all-directories? #t)
+ (let ((directories (find-files fonts-dir
+ (lambda (file stat)
+ (eq? 'directory (stat:type stat)))
+ #:directories? #t)))
+ (for-each (lambda (dir)
+ (with-directory-excursion dir
+ (when (file-exists? fonts-scale-file)
+ (delete-file fonts-scale-file))
+ (when (file-exists? fonts-dir-file)
+ (delete-file fonts-dir-file))
+ (unless (and (zero? (system* mkfontscale))
+ (zero? (system* mkfontdir)))
+ (exit #f))
+ (when (empty-file? fonts-scale-file)
+ (delete-file fonts-scale-file))
+ (when (empty-file? fonts-dir-file)
+ (delete-file fonts-dir-file))))
+ directories)))))))
(gexp->derivation "fonts-dir" build
#:modules '((guix build utils)
- (guix build union))
+ (guix build union)
+ (srfi srfi-26))
#:local-build? #t
#:substitutable? #f))
--
2.12.0
next prev parent reply other threads:[~2017-03-12 11:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-12 11:53 [PATCH -v3 1/2] build: union: Add create-all-directories? parameter to union-build Huang Ying
2017-03-12 11:53 ` Huang Ying [this message]
2017-03-15 21:37 ` bug#26075: " Danny Milosavljevic
2017-03-24 11:53 ` Huang, Ying
2017-03-26 10:55 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170312115359.23318-2-huang.ying.caritas@gmail.com \
--to=huang.ying.caritas@gmail.com \
--cc=guix-devel@gnu.org \
--cc=guix-patches@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.