1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
3 ;;; Copyright © 2017 Alex Griffin <a@ajgrf.com>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (guix build font-build-system)
21 #:use-module ((guix build gnu-build-system) #:prefix gnu:)
22 #:use-module (guix build utils)
23 #:use-module (srfi srfi-1)
24 #:use-module (srfi srfi-26)
25 #:export (%standard-phases
30 ;; Builder-side code of the build procedure for font packages.
34 (define gnu:unpack (assoc-ref gnu:%standard-phases 'unpack))
36 (define* (unpack #:key source #:allow-other-keys)
37 "Unpack SOURCE into the build directory. SOURCE may be a compressed
38 archive, or a font file."
39 (if (any (cut string-suffix? <> source)
44 (copy-file source (strip-store-file-name source))
46 (gnu:unpack #:source source)))
48 (define* (install #:key outputs #:allow-other-keys)
49 "Install the package contents."
50 (let* ((out (assoc-ref outputs "out"))
52 (fonts (string-append out "/share/fonts")))
53 (for-each (cut install-file <> (string-append fonts "/truetype"))
54 (find-files source "\\.(ttf|ttc)$"))
55 (for-each (cut install-file <> (string-append fonts "/opentype"))
56 (find-files source "\\.(otf|otc)$"))
59 (define %standard-phases
60 (modify-phases gnu:%standard-phases
61 (replace 'unpack unpack)
66 (replace 'install install)))
68 (define* (font-build #:key inputs (phases %standard-phases)
69 #:allow-other-keys #:rest args)
70 "Build the given font package, applying all of PHASES in order."
71 (apply gnu:gnu-build #:inputs inputs #:phases phases args))
73 ;;; font-build-system.scm ends here