[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26941: New font-build-system
From: |
Arun Isaac |
Subject: |
bug#26941: New font-build-system |
Date: |
Sun, 28 May 2017 00:07:38 +0530 |
>> A side issue: I feel that the `install-file' procedure should print out
>> what it's doing to stdout (or some log port). Something like:
>>
>> (format #t "~a -> ~a~%" source destination)
>>
>> This would save us the trouble of implementing this log printing
>> everywhere `install-file' is called. For example, this could be very
>> useful in the 'install' phase of the font-build-sytem. WDYT?
>
> Do we really need to print something in the first place? :-) Some
> procedures in (guix build utils) do that, indeed, but I’m not sure it’s
> useful for something as simple as ‘install-file’. Thoughts?
Yes, I think it is really important. Without the verbose output, one
will have to stare at a blank screen, guessing at what is
happening. Long verbose output feels reassuring that something is going
on. :-) Also, verbose output for `install-file' might help in debugging
correct source/destination paths.
>> The patches migrating the font packages to the font-build-system are not
>> properly complete. I'll send them in after more work. For now, please
>> find attached the patch for the font-build-system alone.
The four font packages (inconsolata, dejavu, ubuntu and bitstream-vera)
are also ready.
>> * Makefile.am (MODULES): Add 'guix/build-system/font.scm' and
>> 'guix/build/font-build-system.scm'.
>> * guix/build-system/font.scm: New file.
>> * guix/build/font-build-system.scm: New file.
>
> Please mention guix.texi as well.
Done!
>> address@hidden {Scheme Variable} font-build-system
>> +This variable is exported by @code{(guix build-system font)}. It
>> +implements an installation procedure for font packages. It copies font
> ^
> I’d write:
>
> … for font packages where upstream provides pre-compiled TrueType,
> OpenType, etc. font files that merely need to be copied into place
>
> This is to distinguish from fonts that we build from a FontForge
> (whatever it’s called today) source.
Done!
>> + ,@(let ((compression (resolve-module '(gnu packages
>> compression))))
>> + (map (match-lambda
>> + ((name package)
>> + (list name (module-ref compression
>> package))))
>> + `(("tar" tar)
>> + ("gzip" gzip)
>> + ("bzip2" bzip2)
>> + ("xz" xz))))))
>
> This works, but since ‘tar’ is defined in (gnu packages base), it’s
> better to take it from there.
Done! I have also included "unzip" because several font packages come as
zip archives. WDYT?
> Also, prefer ‘resolve-interface’ over ‘resolve-module’: the former
> provides access to public/exported bindings only, whereas the latter
> provides access to both public and private bindings.
Done!
> Do some of the candidate packages provide Type1 fonts? If not, this is
> perfect; if we do, then in a future patch we can extend it to support
> Type1 as well.
I haven't come across Type1 fonts yet. After pushing these patches
(after I hear your thoughts on "unzip"), I'll start migrating the other
font packages. When I come across Type1 fonts, I'll extend the
font-build-system as well.
>From a0bda2fc48c6d2c7809805251154c49e8be76d67 Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Mon, 15 May 2017 20:08:57 +0530
Subject: [PATCH 1/5] build-system: Add 'font-build-system'.
* Makefile.am (MODULES): Add 'guix/build-system/font.scm' and
'guix/build/font-build-system.scm'.
* guix/build-system/font.scm: New file.
* guix/build/font-build-system.scm: New file.
* doc/guix.texi (Build Systems): Add 'font-build-system'.
---
Makefile.am | 2 +
doc/guix.texi | 8 +++
guix/build-system/font.scm | 130 +++++++++++++++++++++++++++++++++++++++
guix/build/font-build-system.scm | 71 +++++++++++++++++++++
4 files changed, 211 insertions(+)
create mode 100644 guix/build-system/font.scm
create mode 100644 guix/build/font-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index c2fc2642a..3925f3e2d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,6 +76,7 @@ MODULES = \
guix/build-system/cmake.scm \
guix/build-system/dub.scm \
guix/build-system/emacs.scm \
+ guix/build-system/font.scm \
guix/build-system/asdf.scm \
guix/build-system/glib-or-gtk.scm \
guix/build-system/gnu.scm \
@@ -101,6 +102,7 @@ MODULES = \
guix/build/cmake-build-system.scm \
guix/build/dub-build-system.scm \
guix/build/emacs-build-system.scm \
+ guix/build/font-build-system.scm \
guix/build/asdf-build-system.scm \
guix/build/git.scm \
guix/build/hg.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 0d389261a..7cbfdecba 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3627,6 +3627,14 @@ package is installed in its own directory under
@file{share/emacs/site-lisp/guix.d}.
@end defvr
address@hidden {Scheme Variable} font-build-system
+This variable is exported by @code{(guix build-system font)}. It
+implements an installation procedure for font packages where upstream
+provides pre-compiled TrueType, OpenType, etc. font files that merely
+need to be copied into place. It copies font files to standard
+locations in the output directory.
address@hidden defvr
+
Lastly, for packages that do not need anything as sophisticated, a
``trivial'' build system is provided. It is trivial in the sense that
it provides basically no support: it does not pull any implicit inputs,
diff --git a/guix/build-system/font.scm b/guix/build-system/font.scm
new file mode 100644
index 000000000..f448c302c
--- /dev/null
+++ b/guix/build-system/font.scm
@@ -0,0 +1,130 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <address@hidden>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system font)
+ #:use-module (guix utils)
+ #:use-module (guix packages)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (ice-9 match)
+ #:export (%font-build-system-modules
+ font-build
+ font-build-system))
+
+;; Commentary:
+;;
+;; Standard build procedure for fonts. This is implemented as an extension of
+;; 'gnu-build-system'.
+;;
+;; Code:
+
+(define %font-build-system-modules
+ ;; Build-side modules imported by default.
+ `((guix build font-build-system)
+ ,@%gnu-build-system-modules))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ '(#:target #:inputs #:native-inputs))
+
+ (bag
+ (name name)
+ (system system)
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ,(list "tar" (module-ref (resolve-interface '(gnu packages
base)) 'tar))
+ ,(list "unzip" (module-ref (resolve-interface '(gnu
packages zip)) 'unzip))
+ ,@(let ((compression (resolve-interface '(gnu packages
compression))))
+ (map (match-lambda
+ ((name package)
+ (list name (module-ref compression package))))
+ `(("gzip" gzip)
+ ("bzip2" bzip2)
+ ("xz" xz))))))
+ (build-inputs native-inputs)
+ (outputs outputs)
+ (build font-build)
+ (arguments (strip-keyword-arguments private-keywords arguments))))
+
+(define* (font-build store name inputs
+ #:key source
+ (tests? #t)
+ (test-target "test")
+ (configure-flags ''())
+ (phases '(@ (guix build font-build-system)
+ %standard-phases))
+ (outputs '("out"))
+ (search-paths '())
+ (system (%current-system))
+ (guile #f)
+ (imported-modules %font-build-system-modules)
+ (modules '((guix build font-build-system)
+ (guix build utils))))
+ "Build SOURCE with INPUTS."
+ (define builder
+ `(begin
+ (use-modules ,@modules)
+ (font-build #:name ,name
+ #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:configure-flags ,configure-flags
+ #:system ,system
+ #:test-target ,test-target
+ #:tests? ,tests?
+ #:phases ,phases
+ #:outputs %outputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:inputs %build-inputs)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:inputs inputs
+ #:system system
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define font-build-system
+ (build-system
+ (name 'font)
+ (description "The build system for font packages")
+ (lower lower)))
+
+;;; font.scm ends here
diff --git a/guix/build/font-build-system.scm b/guix/build/font-build-system.scm
new file mode 100644
index 000000000..cca1e93f0
--- /dev/null
+++ b/guix/build/font-build-system.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <address@hidden>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build font-build-system)
+ #:use-module ((guix build gnu-build-system) #:prefix gnu:)
+ #:use-module (guix build utils)
+ #:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-26)
+ #:export (%standard-phases
+ font-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the build procedure for font packages.
+;;
+;; Code:
+
+(define gnu:unpack (assoc-ref gnu:%standard-phases 'unpack))
+
+(define* (unpack #:key source #:allow-other-keys)
+ "Unpack SOURCE into the build directory. SOURCE may be a compressed
+archive, or a font file."
+ (if (any (cut string-suffix? <> source)
+ (list ".ttf" ".otf"))
+ (begin
+ (mkdir "source")
+ (chdir "source")
+ (copy-file source (strip-store-file-name source))
+ #t)
+ (gnu:unpack #:source source)))
+
+(define* (install #:key outputs #:allow-other-keys)
+ "Install the package contents."
+ (let* ((out (assoc-ref outputs "out"))
+ (source (getcwd))
+ (fonts (string-append out "/share/fonts")))
+ (for-each (cut install-file <> (string-append fonts "/truetype"))
+ (find-files source "\\.ttf$"))
+ (for-each (cut install-file <> (string-append fonts "/opentype"))
+ (find-files source "\\.otf$"))
+ #t))
+
+(define %standard-phases
+ (modify-phases gnu:%standard-phases
+ (replace 'unpack unpack)
+ (delete 'configure)
+ (delete 'check)
+ (delete 'build)
+ (replace 'install install)))
+
+(define* (font-build #:key inputs (phases %standard-phases)
+ #:allow-other-keys #:rest args)
+ "Build the given font package, applying all of PHASES in order."
+ (apply gnu:gnu-build #:inputs inputs #:phases phases args))
+
+;;; font-build-system.scm ends here
--
2.12.2
>From 0e2f27328064e9d2fdf3e6d618f2433d70fca2c8 Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Mon, 15 May 2017 20:16:04 +0530
Subject: [PATCH 2/5] gnu: font-inconsolata: Use 'font-build-system'.
* gnu/packages/fonts.scm (font-inconsolata): Switch to 'font-build-system'.
---
gnu/packages/fonts.scm | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 03a1f6f79..8e938819e 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -42,6 +42,7 @@
#:use-module (guix packages)
#:use-module (guix download)
#:use-module (guix git-download)
+ #:use-module (guix build-system font)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (gnu packages base)
@@ -64,18 +65,7 @@
(sha256
(base32
"06js6znbcf7swn8y3b8ki416bz96ay7d3yvddqnvi88lqhbfcq8m"))))
- (build-system trivial-build-system)
- (arguments
- `(#:modules ((guix build utils))
- #:builder (begin
- (use-modules (guix build utils))
- (let ((font-dir (string-append %output
- "/share/fonts/opentype"))
- (source (assoc-ref %build-inputs "source")))
- (mkdir-p font-dir)
- (copy-file source
- (string-append font-dir "/"
"inconsolata.otf"))))))
- (native-inputs `(("source" ,source)))
+ (build-system font-build-system)
(home-page "http://levien.com/type/myfonts/inconsolata.html")
(synopsis "Monospace font")
(description "A monospace font, designed for code listings and the like,
--
2.12.2
>From a9e020690af63b06efee2fc16ddcf5e89a08fa50 Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Mon, 15 May 2017 20:18:08 +0530
Subject: [PATCH 3/5] gnu: font-ubuntu: Use 'font-build-system'.
* gnu/packages/fonts.scm (font-ubuntu): Switch to 'font-build-system'.
---
gnu/packages/fonts.scm | 29 +----------------------------
1 file changed, 1 insertion(+), 28 deletions(-)
diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 8e938819e..cf9855496 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -84,34 +84,7 @@ in print. With attention to detail for high resolution
rendering.")
(sha256
(base32
"0hjvq2x758dx0sfwqhzflns0ns035qm7h6ygskbx1svzg517sva5"))))
- (build-system trivial-build-system)
- (arguments
- `(#:modules ((guix build utils))
- #:builder (begin
- (use-modules (guix build utils)
- (srfi srfi-26))
-
- (let ((PATH (string-append (assoc-ref %build-inputs
- "unzip")
- "/bin"))
- (font-dir (string-append %output
- "/share/fonts/truetype"))
- (doc-dir (string-append %output "/share/doc/"
- ,name "-" ,version)))
- (setenv "PATH" PATH)
- (system* "unzip" (assoc-ref %build-inputs "source"))
-
- (mkdir-p font-dir)
- (mkdir-p doc-dir)
- (chdir (string-append "ubuntu-font-family-" ,version))
- (for-each (lambda (ttf)
- (install-file ttf font-dir))
- (find-files "." "\\.ttf$"))
- (for-each (lambda (doc)
- (install-file doc doc-dir))
- (find-files "." "\\.txt$"))))))
- (native-inputs `(("source" ,source)
- ("unzip" ,unzip)))
+ (build-system font-build-system)
(home-page "http://font.ubuntu.com/")
(synopsis "The Ubuntu Font Family")
(description "The Ubuntu Font Family is a unique, custom designed font
--
2.12.2
>From 55a7d8a1aa2ea5c4d6a5a121db28f14162f5ea75 Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Mon, 15 May 2017 20:19:33 +0530
Subject: [PATCH 4/5] gnu: font-dejavu: Use 'font-build-system'.
* gnu/packages/fonts.scm (font-dejavu): Switch to 'font-build-system'.
---
gnu/packages/fonts.scm | 43 ++++++++-----------------------------------
1 file changed, 8 insertions(+), 35 deletions(-)
diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index cf9855496..fcc31deeb 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -108,42 +108,15 @@ TrueType (TTF) files.")
(base32
"1mqpds24wfs5cmfhj57fsfs07mji2z8812i5c4pi5pbi738s977s"))))
(build-system trivial-build-system)
+ (build-system font-build-system)
(arguments
- `(#:modules ((guix build utils))
- #:builder (begin
- (use-modules (guix build utils))
-
- (let ((tar (string-append (assoc-ref %build-inputs
- "tar")
- "/bin/tar"))
- (PATH (string-append (assoc-ref %build-inputs
- "bzip2")
- "/bin"))
- (font-dir (string-append
- %output "/share/fonts/truetype"))
- (conf-dir (string-append
- %output "/share/fontconfig/conf.avail"))
- (doc-dir (string-append
- %output "/share/doc/" ,name "-" ,version)))
- (setenv "PATH" PATH)
- (system* tar "xvf" (assoc-ref %build-inputs "source"))
-
- (mkdir-p font-dir)
- (mkdir-p conf-dir)
- (mkdir-p doc-dir)
- (chdir (string-append "dejavu-fonts-ttf-" ,version))
- (for-each (lambda (ttf)
- (install-file ttf font-dir))
- (find-files "ttf" "\\.ttf$"))
- (for-each (lambda (conf)
- (install-file conf conf-dir))
- (find-files "fontconfig" "\\.conf$"))
- (for-each (lambda (doc)
- (install-file doc doc-dir))
- (find-files "." "\\.txt$|^[A-Z][A-Z]*$"))))))
- (native-inputs `(("source" ,source)
- ("tar" ,tar)
- ("bzip2" ,bzip2)))
+ `(#:phases
+ (modify-phases %standard-phases
+ (add-after 'install 'install-conf
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((conf-dir (string-append (assoc-ref outputs "out")
+ "/share/fontconfig/conf.avail")))
+ (copy-recursively "fontconfig" conf-dir)))))))
(home-page "http://dejavu-fonts.org/")
(synopsis "Vera font family derivate with additional characters")
(description "DejaVu provides an expanded version of the Vera font family
--
2.12.2
>From c7fc2b4c75b96e476d85806ef975b92fdbbad582 Mon Sep 17 00:00:00 2001
From: Arun Isaac <address@hidden>
Date: Mon, 15 May 2017 20:20:26 +0530
Subject: [PATCH 5/5] gnu: font-bitstream-vera: Use 'font-build-system'.
* gnu/packages/fonts.scm (font-bitstream-vera): Switch to 'font-build-system'.
---
gnu/packages/fonts.scm | 33 +--------------------------------
1 file changed, 1 insertion(+), 32 deletions(-)
diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index fcc31deeb..954c58818 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -140,38 +140,7 @@ provide serif, sans and monospaced variants.")
(sha256
(base32
"1p3qs51x5327gnk71yq8cvmxc6wgx79sqxfvxcv80cdvgggjfnyv"))))
- (build-system trivial-build-system)
- (arguments
- `(#:modules ((guix build utils))
- #:builder (begin
- (use-modules (guix build utils)
- (srfi srfi-26))
-
- (let ((tar (string-append (assoc-ref %build-inputs
- "tar")
- "/bin/tar"))
- (PATH (string-append (assoc-ref %build-inputs
- "bzip2")
- "/bin"))
- (font-dir (string-append %output
- "/share/fonts/truetype"))
- (doc-dir (string-append %output "/share/doc/"
- ,name "-" ,version)))
- (setenv "PATH" PATH)
- (system* tar "xvf" (assoc-ref %build-inputs "source"))
-
- (mkdir-p font-dir)
- (mkdir-p doc-dir)
- (chdir (string-append "ttf-bitstream-vera-" ,version))
- (for-each (lambda (ttf)
- (install-file ttf font-dir))
- (find-files "." "\\.ttf$"))
- (for-each (lambda (doc)
- (install-file doc doc-dir))
- (find-files "." "\\.TXT$"))))))
- (native-inputs `(("source" ,source)
- ("tar" ,tar)
- ("bzip2" ,bzip2)))
+ (build-system font-build-system)
(home-page "http://www.gnome.org/fonts/")
(synopsis "Bitstream Vera sans-serif typeface")
(description "Vera is a sans-serif typeface from Bitstream, Inc. This
--
2.12.2