From mboxrd@z Thu Jan 1 00:00:00 1970 From: huang_ying_caritas@163.com Subject: [PATCH 2/2] guix: profiles: create fonts.dir/scale for all fonts directories Date: Sat, 18 Feb 2017 08:44:27 +0800 Message-ID: <20170218004427.12392-2-huang_ying_caritas@163.com> References: <20170218004427.12392-1-huang_ying_caritas@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cet91-00034w-Rw for guix-devel@gnu.org; Fri, 17 Feb 2017 19:45:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cet8w-0003cL-Un for guix-devel@gnu.org; Fri, 17 Feb 2017 19:44:59 -0500 Received: from m12-17.163.com ([220.181.12.17]:45571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cet8w-0003Ye-3n for guix-devel@gnu.org; Fri, 17 Feb 2017 19:44:54 -0500 In-Reply-To: <20170218004427.12392-1-huang_ying_caritas@163.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org From: Huang Ying * guix/profiles.scm (fonts-dir-file): Create fonts.dir/scale files for all fonts directories. Suggested-by: 宋文武 --- guix/profiles.scm | 56 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index de82eae34..7c1b552ad 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -879,7 +879,7 @@ entries. It's used to query the MIME type of a given file." (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)) @@ -890,30 +890,52 @@ files for the truetype fonts of the @var{manifest} entries." #~(begin (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))))) + (guix build union) + (ice-9 ftw)) + (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) + (union-build fonts-dir fonts-dirs + #:log-port (%make-void-port "w") + #:create-all-directory? #t) + (ftw fonts-dir + (lambda (dir statinfo flag) + (and (eq? flag 'directory) + (with-directory-excursion dir + (and (file-exists? fonts-scale-file) + (delete-file fonts-scale-file)) + (and (file-exists? fonts-dir-file) + (delete-file fonts-dir-file)) + (system* mkfontscale) + (system* mkfontdir) + (and (empty-file? fonts-scale-file) + (delete-file fonts-scale-file)) + (and (empty-file? fonts-dir-file) + (delete-file fonts-dir-file)))) + #t))))))) (gexp->derivation "fonts-dir" build #:modules '((guix build utils) - (guix build union)) + (guix build union) + (srfi srfi-26) + (ice-9 ftw)) #:local-build? #t #:substitutable? #f)) -- 2.11.1