all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arun Isaac <arunisaac@systemreboot.net>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 26941@debbugs.gnu.org
Subject: bug#26941: New font-build-system
Date: Sat, 20 May 2017 02:11:05 +0530	[thread overview]
Message-ID: <6e069e5e.AEEAKxWCyNEAAAAAAAAAAAPB0agAAAACwQwAAAAAAAW9WABZH1iD@mailjet.com> (raw)
In-Reply-To: <87y3tw4kw3.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 4485 bytes --]


> It would be nice to install README, COPYING, and LICENSE if they exist.
> It’s okay to not do that as a first step though.

I don't see the utility in installing these files. But, if we're not
doing them in this initial font-build-system, I suppose we can debate
later.

> Nitpick: the “build:” prefix in subject line is meant to refer to the
> configure/Makefile machinery of Guix itself.  I would use
>
>   build-system: Add 'font-build-system'.

Done!

>> +  (and (not target)                               ;XXX: no cross-compilation
>> +       (bag
>> +         (name name)
>> +         (system system)
>> +         (host-inputs `(,@(if source
>> +                              `(("source" ,source))
>> +                              '())
>> +                        ,@inputs
>> +
>> +                        ;; Keep the standard inputs of 'gnu-build-system'.
>> +                        ,@(standard-packages)))
>> +         (build-inputs native-inputs)
>> +         (outputs outputs)
>> +         (build font-build)
>> +         (arguments (strip-keyword-arguments private-keywords arguments)))))
>
> I would remove (and (not target) …).  After all, we know that the result
> is architecture-independent data, so we can build it natively regardless
> of whether TARGET is true.

Done!

> Also, (standard-packages) is way more than needed (it includes the whole
> toolchain, etc.; see build-system/gnu.scm).  Here all we need is tar,
> gzip, bzip2, and xz.

I have attempted something for this. I'm not sure I did it the correct
way. Do let me know.

I actually have very little understanding of what's going on in
guix/build-system/font.scm. I just copied guix/build-system/emacs.scm
and modified it a little. Can I find documentation of `bag' fields
somewhere in the manual?

> Could you updated it accordingly?
>
>> +(define* (install #:key outputs #:allow-other-keys)
>> +  "Install the package contents."
>> +  (let* ((out (assoc-ref outputs "out"))
>> +         (src-dir (getcwd))
>> +         (fonts-dir (string-append out "/share/fonts")))
>
> I’d avoid abbreviations in identifiers.  So “source” or
> “source-directory”, etc.

Done!

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?

> One last thing: could you add an entry for ‘font-build-system’ in
> guix.texi under “Build Systems”?

I have added a short description. Is it too short? Should I elaborate?

>> From d5a745fddf7b6512e4b5c317c19dc8cd3f9a8efe Mon Sep 17 00:00:00 2001
>> From: Arun Isaac <arunisaac@systemreboot.net>
>> 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'.
>
> [...]
>
>> From e0af4ce17f0e99f72926f93b5d5ed99df57cf06a Mon Sep 17 00:00:00 2001
>> From: Arun Isaac <arunisaac@systemreboot.net>
>> 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'.
>
> [...]
>
>> From c557da3c5167de0cb5714c5f545b07ac8cd55dae Mon Sep 17 00:00:00 2001
>> From: Arun Isaac <arunisaac@systemreboot.net>
>> 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'.
>
> [...]
>
>> From f302764eb627726548a89438b8c3b6a8ff5988d4 Mon Sep 17 00:00:00 2001
>> From: Arun Isaac <arunisaac@systemreboot.net>
>> 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(-)
>
> Really pleasant to see all these deletions.  :-)

Many more sweet deletions will follow once the font-build-system is
complete! :-)

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.


[-- Attachment #2: 0001-build-system-Add-font-build-system.patch --]
[-- Type: text/x-patch, Size: 10152 bytes --]

From 11cd5cf6188316bafd246e64d875e22423227e5e Mon Sep 17 00:00:00 2001
From: Arun Isaac <arunisaac@systemreboot.net>
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.
---
 Makefile.am                      |   2 +
 doc/guix.texi                    |   6 ++
 guix/build-system/font.scm       | 129 +++++++++++++++++++++++++++++++++++++++
 guix/build/font-build-system.scm |  71 +++++++++++++++++++++
 4 files changed, 208 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 7c07d1b2b..bc60dd7a3 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 b4a59e793..2a7acb201 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3626,6 +3626,12 @@ package is installed in its own directory under
 @file{share/emacs/site-lisp/guix.d}.
 @end defvr
 
+@defvr {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
+files to standard locations in the output directory.
+@end 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..0d38dcbd6
--- /dev/null
+++ b/guix/build-system/font.scm
@@ -0,0 +1,129 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; 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
+                   ,@(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))))))
+    (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..77e180419
--- /dev/null
+++ b/guix/build/font-build-system.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
+;;;
+;;; 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


  reply	other threads:[~2017-05-19 20:42 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-15 15:06 bug#26941: New font-build-system Arun Isaac
2017-05-16 20:17 ` Ludovic Courtès
2017-05-19 20:41   ` Arun Isaac [this message]
     [not found]   ` <fcac084e.AEEAKxWCyNIAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZH1iD@mailjet.com>
2017-05-23 11:33     ` Ludovic Courtès
2017-05-27 18:37       ` Arun Isaac
2017-05-28 18:44         ` User-Friendlyness of Guix and non-scaryness, printing messages Danny Milosavljevic
2017-05-28 19:01           ` Danny Milosavljevic
2017-05-28 20:35             ` Danny Milosavljevic
2017-05-28 20:58               ` Danny Milosavljevic
2017-05-30 15:11                 ` Ludovic Courtès
2017-05-28 19:20           ` Leo Famulari
2017-05-28 19:40             ` Danny Milosavljevic
2017-05-28 19:47               ` Leo Famulari
2017-05-28 21:12               ` Ludovic Courtès
2017-05-31 22:26                 ` Danny Milosavljevic
2017-06-01 21:41                   ` Ludovic Courtès
2017-05-30  8:24               ` Ricardo Wurmus
2017-06-16 11:42                 ` Danny Milosavljevic
2017-06-17 20:16                   ` Ludovic Courtès
2017-05-30  1:47             ` "guix system" summary output? Danny Milosavljevic
2017-05-30 11:05               ` Danny Milosavljevic
2017-05-30 15:47               ` Ludovic Courtès
2017-05-30  8:17             ` User-Friendlyness of Guix and non-scaryness, printing messages Roel Janssen
2017-05-30 13:56               ` Arun Isaac
2017-05-30 14:32                 ` Christopher Allan Webber
2017-05-30 15:58                   ` Arun Isaac
2017-05-30 15:13                 ` Ludovic Courtès
2017-05-28 19:30           ` ng0
     [not found]       ` <9591bf82.AEUAKjfDcSkAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZKceD@mailjet.com>
2017-05-28 12:38         ` bug#26941: New font-build-system Ludovic Courtès
2017-05-28 13:15           ` Arun Isaac
2017-05-30 21:19             ` Ricardo Wurmus
     [not found]           ` <37b2bd65.AEMAKxmsz0MAAAAAAAAAAAOzWv8AAAACwQwAAAAAAAW9WABZKs1c@mailjet.com>
2017-05-29  8:51             ` Ludovic Courtès
2017-06-01 13:17 ` Brendan Tildesley
2017-06-01 15:15   ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6e069e5e.AEEAKxWCyNEAAAAAAAAAAAPB0agAAAACwQwAAAAAAAW9WABZH1iD@mailjet.com \
    --to=arunisaac@systemreboot.net \
    --cc=26941@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.