gnu: r-qtl2: Move to (gnu packages cran).
[jackhill/guix/guix.git] / guix / build / font-build-system.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
3 ;;; Copyright © 2017 Alex Griffin <a@ajgrf.com>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
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.
11 ;;;
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.
16 ;;;
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/>.
19
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
26 font-build))
27
28 ;; Commentary:
29 ;;
30 ;; Builder-side code of the build procedure for font packages.
31 ;;
32 ;; Code:
33
34 (define gnu:unpack (assoc-ref gnu:%standard-phases 'unpack))
35
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)
40 (list ".ttf" ".otf"))
41 (begin
42 (mkdir "source")
43 (chdir "source")
44 (copy-file source (strip-store-file-name source))
45 #t)
46 (gnu:unpack #:source source)))
47
48 (define* (install #:key outputs #:allow-other-keys)
49 "Install the package contents."
50 (let* ((out (assoc-ref outputs "out"))
51 (source (getcwd))
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)$"))
57 #t))
58
59 (define %standard-phases
60 (modify-phases gnu:%standard-phases
61 (replace 'unpack unpack)
62 (delete 'bootstrap)
63 (delete 'configure)
64 (delete 'check)
65 (delete 'build)
66 (replace 'install install)))
67
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))
72
73 ;;; font-build-system.scm ends here