font-build-system.scm 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. (define-module (guix build font-build-system)
  20. #:use-module ((guix build gnu-build-system) #:prefix gnu:)
  21. #:use-module (guix build utils)
  22. #:use-module (srfi srfi-1)
  23. #:use-module (srfi srfi-26)
  24. #:export (%standard-phases
  25. font-build))
  26. ;; Commentary:
  27. ;;
  28. ;; Builder-side code of the build procedure for font packages.
  29. ;;
  30. ;; Code:
  31. (define gnu:unpack (assoc-ref gnu:%standard-phases 'unpack))
  32. (define* (unpack #:key source #:allow-other-keys)
  33. "Unpack SOURCE into the build directory. SOURCE may be a compressed
  34. archive, or a font file."
  35. (if (any (cut string-suffix? <> source)
  36. (list ".ttf" ".otf"))
  37. (begin
  38. (mkdir "source")
  39. (chdir "source")
  40. (copy-file source (strip-store-file-name source))
  41. #t)
  42. (gnu:unpack #:source source)))
  43. (define* (install #:key outputs #:allow-other-keys)
  44. "Install the package contents."
  45. (let* ((out (assoc-ref outputs "out"))
  46. (source (getcwd))
  47. (fonts (string-append out "/share/fonts")))
  48. (for-each (cut install-file <> (string-append fonts "/truetype"))
  49. (find-files source "\\.(ttf|ttc)$"))
  50. (for-each (cut install-file <> (string-append fonts "/opentype"))
  51. (find-files source "\\.(otf|otc)$"))
  52. #t))
  53. (define %standard-phases
  54. (modify-phases gnu:%standard-phases
  55. (replace 'unpack unpack)
  56. (delete 'bootstrap)
  57. (delete 'configure)
  58. (delete 'check)
  59. (delete 'build)
  60. (replace 'install install)))
  61. (define* (font-build #:key inputs (phases %standard-phases)
  62. #:allow-other-keys #:rest args)
  63. "Build the given font package, applying all of PHASES in order."
  64. (apply gnu:gnu-build #:inputs inputs #:phases phases args))
  65. ;;; font-build-system.scm ends here